The standard WTConv2d class from fast_wtconv.wtconv automatically detects your hardware (CUDA for NVIDIA GPUs or MPS for Apple Silicon) and selects the appropriate optimized kernel. This makes it a drop-in replacement for original WTConv layers.
Initialization Parameters:
in_channels: Number of input channels.out_channels: Number of output channels.kernel_size: Size of the convolution kernel.stride: Stride of the convolution.wt_levels: Number of wavelet levels.
import torch
from fast_wtconv.wtconv import WTConv2d
# Initialize layer
# Parameters: in_channels, out_channels, kernel_size, stride, wt_levels
layer = WTConv2d(64, 64, kernel_size=5, wt_levels=2)
# Move to device (CUDA or MPS)
device = 'cuda' if torch.cuda.is_available() else 'mps'
layer = layer.to(device)
# Forward pass
x = torch.randn(1, 64, 224, 224).to(device)
output = layer(x)