Skip to content

Preserve dense add output layouts - #34

Merged
voltjia merged 1 commit into
masterfrom
fix/add-output-layout
Jul 25, 2026
Merged

Preserve dense add output layouts#34
voltjia merged 1 commit into
masterfrom
fix/add-output-layout

Conversation

@voltjia

@voltjia voltjia commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR preserves the left operand layout for Add results when the output shape is unchanged and the operand is non-overlapping and dense.

It uses the public empty_like API with MemoryFormat::Preserve for that case and retains contiguous allocation for broadcasting, expanded inputs, and gapped layouts.

It extends the CPU-oracle test helper to copy raw noncontiguous result storage, converts the transposed-output strict expected failure into a passing conformance case, and adds an expanded-stride regression.

This advances the Add semantics work in #13.

Validation

  • Ruff and clang-format 19.1.4 checks passed.
  • PyTorch 2.12 and 2.13 CPU behavior probes agreed on the output layout policy.
  • The complete installed-wheel CPU fallback suite passed with 143 tests passed, 32 skipped, and 2 expected failures.
  • The NVIDIA wheel built, installed, and imported successfully. The transposed result reached value comparison with matching shape, stride, contiguity, dtype, layout, and storage offset metadata.
  • The separate NVIDIA Add value instability is tracked in Stabilize NVIDIA Add validation #33 and is not treated as a layout regression in this PR.

@voltjia
voltjia merged commit 524d441 into master Jul 25, 2026
8 checks passed
@voltjia
voltjia deleted the fix/add-output-layout branch July 25, 2026 08:58
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.

1 participant