Skip to content

Commit ba4c005

Browse files
authored
Cortex-M: check the output dim order in quantized_conv2d (pytorch#21752)
### Summary The output channels_last guard tested the input tensor, so an NCHW output would reach arm_convolve_wrapper_s8 and produce silently transposed results. The depthwise and transpose-conv kernels already validate their own outputs. Also drops the local kChannelsLastDimOrder/channels_last_order pair, which became dead when is_channels_last_tensor moved into cortex_m_ops_common.h and grew its own copy. Authored with assistance from Claude Code.
1 parent bf2103d commit ba4c005

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

‎backends/cortex_m/ops/op_quantized_conv2d.cpp‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ bool validate_conv2d_arguments(
3535

3636
// Check for channels_last dim_order (NHWC: 0, 2, 3, 1)
3737
// Skip check if channels == 1, as dim_order is ambiguous in that case
38-
constexpr executorch::aten::DimOrderType kChannelsLastDimOrder[] = {
39-
0, 2, 3, 1};
40-
executorch::aten::ArrayRef<executorch::aten::DimOrderType>
41-
channels_last_order(kChannelsLastDimOrder, 4);
42-
4338
if (input.size(1) > 1 && !is_channels_last_tensor(input)) {
4439
ET_LOG(
4540
Error,
@@ -48,7 +43,7 @@ bool validate_conv2d_arguments(
4843
return false;
4944
}
5045

51-
if (output.size(1) > 1 && !is_channels_last_tensor(input)) {
46+
if (output.size(1) > 1 && !is_channels_last_tensor(output)) {
5247
ET_LOG(
5348
Error,
5449
"quantized_conv2d_out: output must have channels_last dim_order (NHWC)");

0 commit comments

Comments
 (0)