{"record":{"id":"0090541f1f5b03c3","repo":"hpcaitech/Open-Sora","slug":"unsupported-input-dimension-x-dim","errorCode":null,"errorMessage":"Unsupported input dimension: {x.dim()}","messagePattern":"Unsupported input dimension: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"opensora/models/dc_ae/models/nn/ops.py","lineNumber":227,"sourceCode":"            x = x.view(B, self.out_channels, group_size, H, W)\n            x = x.mean(dim=2)\n        elif x.dim() == 5:  # [B, C, T, H, W]\n            _, _, T, _, _ = x.shape\n            if self.temporal_downsample and T != 1:  # 3d pixel unshuffle\n                x = pixel_unshuffle_3d(x, self.factor)\n                assert self.in_channels * self.factor**3 % self.out_channels == 0\n                group_size = self.in_channels * self.factor**3 // self.out_channels\n            else:  # 2d pixel unshuffle\n                x = x.permute(0, 2, 1, 3, 4)  # [B, T, C, H, W]\n                x = F.pixel_unshuffle(x, self.factor)\n                x = x.permute(0, 2, 1, 3, 4)  # [B, C, T, H, W]\n                assert self.in_channels * self.factor**2 % self.out_channels == 0\n                group_size = self.in_channels * self.factor**2 // self.out_channels\n            B, C, T, H, W = x.shape\n            x = x.view(B, self.out_channels, group_size, T, H, W)\n            x = x.mean(dim=2)\n        else:\n            raise ValueError(f\"Unsupported input dimension: {x.dim()}\")\n        return x\n\n    def __repr__(self):\n        return f\"PixelUnshuffleChannelAveragingDownSampleLayer(in_channels={self.in_channels}, out_channels={self.out_channels}, factor={self.factor}), temporal_downsample={self.temporal_downsample}\"\n\n\nclass ConvPixelShuffleUpSampleLayer(nn.Module):\n    def __init__(\n        self,\n        in_channels: int,\n        out_channels: int,\n        kernel_size: int,\n        factor: int,\n    ):\n        super().__init__()\n        self.factor = factor\n        out_ratio = factor**2\n        self.conv = ConvLayer(","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/hpcaitech/Open-Sora/blob/7ad6a96a135feb81f755c84fb391818718f6beb2/opensora/models/dc_ae/models/nn/ops.py#L209-L245","documentation":"PixelUnshuffleChannelAveragingDownSampleLayer.forward only handles 4D (B,C,H,W) and 5D (B,C,T,H,W) inputs; other rank tensors raise this ValueError. The branch chosen also depends on temporal_downsample, so an incorrectly shaped tensor (e.g. an unbroadcast feature map or a 3D tensor) fails this check.","triggerScenarios":"Feeding a tensor with dim() != 4 and != 5 into the averaging shortcut layer, e.g. a per-frame 3D tensor or a 6D tensor from prior reshaping; occurs during encoder forward/downsample shortcut computation.","commonSituations":"Custom preprocessing that squeezes the batch or time dimension; feeding single images without a batch dim; intermediate reshapes that change tensor rank before the autoencoder.","solutions":["Ensure input is 4D (B,C,H,W) or 5D (B,C,T,H,W) with an explicit batch dimension","Check upstream transforms for squeeze/view calls that drop a dimension","For single samples pass x.unsqueeze(0)"],"exampleFix":"# before\nx = frame_3d  # (C,H,W)\ny = layer(x)\n# after\nx = frame_3d.unsqueeze(0)  # (1,C,H,W)\ny = layer(x)","handlingStrategy":"type-guard","validationCode":"if x.dim() not in (4, 5):\n    raise ValueError(f'expected 4D/5D input, got {tuple(x.shape)}')","typeGuard":"def is_valid_offload_shape(x: torch.Tensor) -> bool:\n    return x.dim() in (4, 5)","tryCatchPattern":null,"preventionTips":["Always carry an explicit batch dimension through the pipeline","Add shape assertions at stage boundaries","Log tensor shapes in debug builds to catch rank drift early"],"tags":["tensor-shape","dc-ae","validation","pytorch"],"backgroundTag":"invalid-tensor-shape","analyzedSha":"7ad6a96a135feb81f755c84fb391818718f6beb2","analyzedAt":"2026-08-28T16:58:37.171Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}