Skip to content

Fix: add tile.neg to kRowMajorOps for ACC-to-VEC layout conversion#1308

Open
bumble0918 wants to merge 1 commit into
hw-native-sys:mainfrom
bumble0918:feature/2026-05-07
Open

Fix: add tile.neg to kRowMajorOps for ACC-to-VEC layout conversion#1308
bumble0918 wants to merge 1 commit into
hw-native-sys:mainfrom
bumble0918:feature/2026-05-07

Conversation

@bumble0918
Copy link
Copy Markdown

@bumble0918 bumble0918 commented May 7, 2026

#1309 When infer_tile_memory_space_pass inserts tile.move for a matmul accumulator (col_major, ACC space) feeding into tile.neg, the move previously inherited col_major blayout because tile.neg was not in kRowMajorOps. tile.neg propagates layout via InheritTileViewLayout, so col_major flowed through to downstream ops like tile.exp which require row_major in VEC space, causing PTO verifier failure.

When infer_tile_memory_space_pass inserts tile.move for a matmul
accumulator (col_major, ACC space) feeding into tile.neg, the move
previously inherited col_major blayout because tile.neg was not in
kRowMajorOps. tile.neg propagates layout via InheritTileViewLayout,
so col_major flowed through to downstream ops like tile.exp which
require row_major in VEC space, causing PTO verifier failure.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds "tile.neg" to the kRowMajorOps set in the RequiresRowMajorLayout helper function, ensuring that tile.neg operations receive row-major layout configuration during backend operation registration.

Changes

Operation Registration Configuration

Layer / File(s) Summary
Row-Major Layout Configuration
src/backend/common/pto_ops_common.cpp
The "tile.neg" operation is added to the kRowMajorOps set in RequiresRowMajorLayout, enabling automatic row-major input/output layout settings for tile.neg in the operation registration loop.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • hw-native-sys/pypto#1231: Expands row-major layout detection and repair for tile operations with similar configuration logic.
  • hw-native-sys/pypto#729: Previously modified the same RequiresRowMajorLayout helper to extend row-major layout requirements for unary tile operations.

Suggested labels

bug

Poem

A simple tile.neg joins the row-major crew,
One line of code, yet systems made anew,
In patterns aligned, the operators stand tall,
Layout requirements answered, completing the call. 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding tile.neg to kRowMajorOps for ACC-to-VEC layout conversion, which directly matches the single-line change in the file.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description clearly explains the problem (tile.neg not in kRowMajorOps causing layout propagation issues) and the fix being applied, relating directly to the code change.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds tile.neg to the list of operations requiring a row-major layout in src/backend/common/pto_ops_common.cpp. The reviewer noted that while this change is correct, several other element-wise and tile-scalar operations (such as tile.prelu, tile.subs, and tile.rems) are also missing from the RequiresRowMajorLayout list and should be included to prevent similar layout propagation issues and verifier failures.

"tile.sqrt",
"tile.rsqrt",
"tile.recip",
"tile.neg",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While adding tile.neg correctly addresses the reported issue, several other element-wise operations that likely require row-major layout in the Vector core are still missing from the kRowMajorOps list.

Specifically, the following operations defined in kSimpleOps appear to be missing from kRowMajorOps:

  • Binary: tile.prelu (line 1989)
  • Tile x Scalar: tile.subs (line 2005), tile.rems (line 2008), tile.ands (line 2009), tile.ors (line 2010), tile.xors (line 2011), tile.shls (line 2012), tile.shrs (line 2013), and tile.mins (line 2015).

Failure to include these will likely result in similar layout propagation issues and verifier failures when these operations are used in VEC memory space after a matmul, as they also propagate layout via InheritTileViewLayout.

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant