torch.Tensor Visualization

Svetoviz supports torch.Tensor visualization exactly like standard NumPy arrays.

Single torch.Tensor Inspection

Use tensor() to project a single torch.Tensor into the 3D scene. The gap_size parameter allows you to control the visual spacing between high-dimensional slices, making it easier to identify patterns across tensors.

single_tensor.py
import svetoviz_webgpu as sv

data = torch.rand((4, 4, 256, 256), dtype=torch.float32)
sv.tensor(data, gap_size=10)
Single Tensor Visualization

Visualizing Multiple Data Types

Svetoviz supports the full spectrum of torch dtypes - from standard integers and floats to complex numbers and booleans. Using tensors(), you can pass a list of torch.Tensor with varying shapes and types.

multi_type_demo.py
import svetoviz_webgpu as sv

sv.tensors([
    # integers
    torch.randint(0, 2, (2, 72, 72), dtype=torch.bool),
    torch.randint(np.iinfo(np.int8).min, np.iinfo(np.int8).max, (2, 60, 60), dtype=torch.int8),
    torch.randint(np.iinfo(np.int16).min, np.iinfo(np.int16).max, (4, 8, 16, 16), dtype=torch.int16),
    torch.randint(np.iinfo(np.int32).min, np.iinfo(np.int32).max, (4, 4, 64, 64), dtype=torch.int32),
    torch.randint(np.iinfo(np.int64).min, np.iinfo(np.int64).max, (4, 2, 32, 64), dtype=torch.int64),
    torch.randint(np.iinfo(np.uint8).min, np.iinfo(np.uint8).max, (2, 3, 128, 128), dtype=torch.uint8),
    torch.randint(np.iinfo(np.uint16).min, np.iinfo(np.uint16).max, (16, 128, 128), dtype=torch.uint16),
    torch.randint(np.iinfo(np.uint32).min, np.iinfo(np.uint32).max, (4, 4, 64, 64), dtype=torch.uint32),
    torch.frombuffer(np.random.bytes(4 * 2 * 32 * 64 * 8), dtype=torch.uint64).reshape(4, 2, 32, 64),

    # floats
    (torch.rand(256, 256, dtype=torch.float32) * torch.finfo(torch.float16).max).to(torch.float16),
    (torch.rand(256, 256, dtype=torch.float32) * torch.finfo(torch.bfloat16).max).to(torch.bfloat16),
    (torch.rand(256, 256, dtype=torch.float32) * torch.finfo(torch.float32).max).to(torch.float32),
    (torch.rand(256, 256, dtype=torch.float64) * torch.finfo(torch.float64).max).to(torch.float64),

    # complex numbers
    torch.complex(
        torch.rand(32, 32),
        torch.rand(32, 32)).to(torch.complex32) * torch.finfo(torch.complex32).max,
    torch.complex(
        torch.rand(32, 32),
        torch.rand(32, 32)).to(torch.complex64) * torch.finfo(torch.complex64).max,
    torch.complex(
        torch.rand(32, 32),
        torch.rand(32, 32)).to(torch.complex128) * torch.finfo(torch.complex128).max
], gap_size=32)

                
Multi-Type Tensor Visualization

Axis Ordering & Spatial Mapping

torch.Tensor visualization inherits all features from standard NumPy views, including stacking, ordering, colormaps, and large tensor support. TensorView is also the primary view used for rendering PyTorch models.

Tensor gradient