Skip to content

Commit d632341

Browse files
Fix DS-CNN Cortex-M input memory format (pytorch#21485)
### Summary The shared DS-CNN model wrapper returned a contiguous NCHW example input, while the Cortex-M backend requires channels-last inputs. This caused the nightly Cortex-M FVP run to abort in `cortex_m::quantized_depthwise_conv2d.out` with `input must be channels_last`. Convert the example input to channels-last, matching the existing Cortex-M DS-CNN tests and backend contract. The tensor values and eager model output are unchanged. ### Test plan Ran `python -m py_compile examples/models/mlperf_tiny/ds_cnn.py` and `git diff --check`. Loaded the patched wrapper and verified input stride `(490, 1, 10, 1)`, eager output shape `(1, 12)`, and the exported user-input stride `(490, 1, 10, 1)`. Authored with Claude.
1 parent 4e285f4 commit d632341

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎examples/models/mlperf_tiny/ds_cnn.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,6 @@ def get_eager_model(self) -> torch.nn.Module:
8383
return DSCNNKWS().eval()
8484

8585
def get_example_inputs(self):
86-
return (torch.rand(1, 1, 49, 10) * 2 - 1,)
86+
return (
87+
(torch.rand(1, 1, 49, 10) * 2 - 1).to(memory_format=torch.channels_last),
88+
)

0 commit comments

Comments
 (0)