fix(hiptensor): return HIPTENSOR_STATUS_NOT_SUPPORTED for different modes in elementwise - #11127
Open
Ryker0627 wants to merge 1 commit into
Open
fix(hiptensor): return HIPTENSOR_STATUS_NOT_SUPPORTED for different modes in elementwise#11127Ryker0627 wants to merge 1 commit into
Ryker0627 wants to merge 1 commit into
Conversation
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Acarries a subset of the output modes (A{n}againstB/C/Dof{m,n}) creates every descriptor and a plan successfully, then returnsHIPTENSOR_STATUS_INTERNAL_ERRORat 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 inAorBmust also appear inD, which made the subset form look supported.hiptensorCreateContractionTrinarylooks for a batch mode by comparingA,BandE, but a trinary contraction never performs anA x B -> Econtraction. It performsT = A * BthenE = T * C, and two batch modes slip through that comparison and still produce silently incorrect results.Technical Details
hiptensorCreatePermutation,hiptensorCreateElementwiseBinary, andhiptensorCreateElementwiseTrinarynow compare each input's mode set against the output's and returnHIPTENSOR_STATUS_NOT_SUPPORTEDon a mismatch. The comparison is set-based, so reordered modes still pass, and it runs before the descriptor is allocated.hiptensorCreateReductionis 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)andhasSharedBatchMode(T, C, E). This catches a mode shared byA,BandCbut absent fromE(it survives intoTand batches step 1), and a mode shared byA,CandEbut absent fromB(invisible to a check that requires membership inB, 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,
hiptensorCreateElementwiseTrinarylistsNOT_SUPPORTEDamong its return values, andCHANGELOG.mdrecords both changes. The API reference renders from these Doxygen comments, so no.rstchange is needed.Test Plan
Three cases added to
test/00_unit/batched_contraction_test.cpp, one per branch:TrinaryFirstStepBatchedReturnsNotSupported—A{b,m,k},B{b,k,n},C{b,n,p},E{m,p}.TrinarySecondStepBatchedReturnsNotSupported—A{b,m,k},B{k,n},C{b,n,p},E{b,m,p}.TrinaryNonBatchedIsSupported— guards against over-rejection.Both rejection cases return
SUCCESSbefore this change.New
test/00_unit/elementwise_mode_test.cppcovers 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 intest/00_unit/CMakeLists.txtand_HIPTENSOR_HOST_TESTS.Existing elementwise tests, samples, and YAML
Permuted Dimsentries all use full permutations of the tensor rank, so nothing currently passing is newly rejected.Test Result
All tests passed.