Skip to content

[Fix][Relax] Preserve stack axes in ConvertLayout - #20989

Open
DiadkoShmek wants to merge 1 commit into
apache:mainfrom
DiadkoShmek:DiadkoShmek/fix-relax-stack-layout
Open

DiadkoShmek wants to merge 1 commit into
apache:mainfrom
DiadkoShmek:DiadkoShmek/fix-relax-stack-layout

Conversation

@DiadkoShmek

Copy link
Copy Markdown

Closes #20902.
Closes #20921.

InferLayoutStack inserted a synthetic S into the input's layout and looked up the stack axis in the input rank. A valid negative axis could fail before normalization. A valid positive axis could also fail later because the synthetic label is missing from the canonical output layout.

Normalize the axis against the output rank, relabel the existing dimensions in that rank, then apply the input permutation and insert the stack axis. Use an unblocked input layout when the producer uses a split layout, following the rank-insertion policy in expand_dims.

Validation on 23a6dbe, Linux x86-64, with the native compiler rebuilt for each version.

  • All six added cases fail on the base and pass with the patch. LLVM results match NumPy for scalar and rank-two inputs. The converted IR checks cover both NHWC propagation and the NCHW4c fallback.
  • test_transform_convert_layout.py, test_transform_legalize_ops_manipulate.py, and test_op_manipulate.py give 253 passes and two skips.
  • Clang-format 20.1.8 and Ruff 0.12.3 checks pass.

Codex assisted with the patch and validation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] InferLayoutStack does not work with LayoutConvert [Bug] InferLayoutStack does not handle negative axis

1 participant