Identity

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

identity_demo.py
import svetoviz_webgpu as sv

# 1. Define Identity Module
# A placeholder that returns the input unchanged
identity_layer = nn.Identity()

def terminal_callback(buffer, message, images, files):
    # Forward pass
    output = identity_layer(input_tensor)

    # Verify the data is identical
    is_same = torch.equal(input_tensor, output)

    buffer.send_system_message(f"Input Shape: {list(input_tensor.shape)}")
    buffer.send_system_message(f"Data Integrity: {'Identical' if is_same else 'Modified'}")
    buffer.send_system_message("Status: Input passed through as a pure 'No-Op'.")

# 2. Start the interactive session
sv.pytorch_web(module=identity_layer, terminal_callback=terminal_callback)
Structural Utility
Upsample activations
The Identity module is primarily used for conditional architecture design. It serves as a "No-Op" replacement for layers that are toggled off, such as in residual skip connections or when pruning a network without changing its structural definition.