Skip to content

fix(hiptensor): return HIPTENSOR_STATUS_NOT_SUPPORTED for different modes in elementwise - #11127

Open
Ryker0627 wants to merge 1 commit into
developfrom
users/ryker0627/hiptensor/fix_diff_ele_modes
Open

fix(hiptensor): return HIPTENSOR_STATUS_NOT_SUPPORTED for different modes in elementwise#11127
Ryker0627 wants to merge 1 commit into
developfrom
users/ryker0627/hiptensor/fix_diff_ele_modes

Conversation

@Ryker0627

@Ryker0627 Ryker0627 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

JIRA ID: AIHIPTENS-559

Motivation

Resolves ROCm/legacy-rocm-build#6560, and completes the trinary half of ROCm/legacy-rocm-build#6559, started in #10826.

  1. An elementwise trinary operation whose input A carries a subset of the output modes (A{n} against B/C/D of {m,n}) creates every descriptor and a plan successfully, then returns HIPTENSOR_STATUS_INTERNAL_ERROR at execution. Broadcasting an input along a mode it doesn't carry isn't implemented, so this should be rejected at descriptor creation. The header documented the weaker rule that modes in A or B must also appear in D, which made the subset form look supported.
  2. hiptensorCreateContractionTrinary looks for a batch mode by comparing A, B and E, but a trinary contraction never performs an A x B -> E contraction. It performs T = A * B then E = T * C, and two batch modes slip through that comparison and still produce silently incorrect results.

Technical Details

hiptensorCreatePermutation, hiptensorCreateElementwiseBinary, and hiptensorCreateElementwiseTrinary now compare each input's mode set against the output's and return HIPTENSOR_STATUS_NOT_SUPPORTED on a mismatch. The comparison is set-based, so reordered modes still pass, and it runs before the descriptor is allocated. hiptensorCreateReduction is untouched, since dropping modes is the point of a reduction.
The trinary batch check now runs once per contraction step, using the intermediate mode list from the existing computeTrinaryContractionIntermediateModes: hasSharedBatchMode(A, B, T) and hasSharedBatchMode(T, C, E). This catches a mode shared by A, B and C but absent from E (it survives into T and batches step 1), and a mode shared by A, C and E but absent from B (invisible to a check that requires membership in B, yet it batches step 2). The old triple is subsumed, and the error message now names the offending step.
The corrected elementwise restriction is documented on all three creation functions, hiptensorCreateElementwiseTrinary lists NOT_SUPPORTED among its return values, and CHANGELOG.md records both changes. The API reference renders from these Doxygen comments, so no .rst change is needed.

Test Plan

Three cases added to test/00_unit/batched_contraction_test.cpp, one per branch:

  • TrinaryFirstStepBatchedReturnsNotSupportedA{b,m,k}, B{b,k,n}, C{b,n,p},
    E{m,p}.
  • TrinarySecondStepBatchedReturnsNotSupportedA{b,m,k}, B{k,n}, C{b,n,p},
    E{b,m,p}.
  • TrinaryNonBatchedIsSupported — guards against over-rejection.

Both rejection cases return SUCCESS before this change.
New test/00_unit/elementwise_mode_test.cpp covers each elementwise entry point with a subset-mode rejection and a reordered-mode control, using the shapes and 32F compute type from the issue reproducer. Both files are registered in test/00_unit/CMakeLists.txt and _HIPTENSOR_HOST_TESTS.
Existing elementwise tests, samples, and YAML Permuted Dims entries all use full permutations of the tensor rank, so nothing currently passing is newly rejected.

Test Result

All tests passed.

@therock-pr-bot

therock-pr-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
📝 PR Description ✅ Pass
Forbidden Files ✅ Pass
🧪 Unit Test ✅ Pass
🔎 pre-commit ✅ Pass
🚫 Draft PR 🔜 To Be Enabled
🚩 Feature Flag 🔜 To Be Enabled
📊 Code Coverage 🔜 To Be Enabled
🤖 therock-pr-bot ✅ Pass

🎉 All checks passed! This PR is ready for review.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

Copy link
Copy Markdown

🎉 All checks passed! This PR is ready for review.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[hipTensor 2.3.0] Documented input-mode subsets in elementwise trinary fail with HIPTENSOR_STATUS_INTERNAL_ERROR

1 participant