Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions backends/cortex_m/passes/aten_to_cortex_m_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from executorch.backends.cortex_m.utils import (
build_activation_lut,
is_channels_last,
is_foldable_alpha,
quantize_multiplier_aot,
quantize_val,
Expand Down Expand Up @@ -461,6 +462,16 @@ def _get_convolution_replacement(
cast(int, conv_args[8]),
)

if not explicit_nhwc:
input_tensor = get_first_fake_tensor(cast(Node, x))
if input_tensor is None or not is_channels_last(input_tensor):
# cortex_m::quantized_conv2d / quantized_depthwise_conv2d require
# channels-last inputs and outputs; replacing a channels-first conv
# produces a graph that fails at runtime with
# "input and output must be channels_last" (#23812).
# Leave the node un-replaced so it falls back to portable ops.
return None

if transposed:
return _get_transpose_conv2d_replacement(node, dialect_pass)

Expand Down