ChannelShuffle

https://pytorch.org/docs/stable/generated/torch.nn.ChannelShuffle.html

channel_shuffle_demo.py
import svetoviz_webgpu as sv

# 1. Prepare 12-channel input (Batch=1, Channels=12, H, W)
input_tensor = base_tensor.repeat(4, 1, 1).unsqueeze(0)

# 2. Define ChannelShuffle
# Splits 12 channels into 3 groups and interleaves them
shuffle = nn.ChannelShuffle(groups=3)

def terminal_callback(buffer, message, images, files):
    output = shuffle(input_tensor)

    buffer.send_system_message(f"Input Channels: {input_tensor.shape[1]}")
    buffer.send_system_message(f"Groups: {shuffle.groups}")
    buffer.send_system_message("Logic: Reshape(G, C/G) -> Transpose -> Flatten")
    buffer.send_system_message("Status: Cross-channel information flow enabled.")

# 3. Start the interactive session
sv.pytorch_web(module=shuffle, terminal_callback=terminal_callback)
Grouped Channel Interleaving
Upsample activations
Channel Shuffle is a core component of the ShuffleNet architecture. It allows information to flow between different groups in grouped convolutions, overcoming the "representation bottleneck" caused by group isolation.