-
Notifications
You must be signed in to change notification settings - Fork 895
[SM6.10] LinAlg Validation: MatrixLength #8787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Ashley Coleman (V-FEXrt)
merged 1 commit into
microsoft:main
from
V-FEXrt:linalg-vali-matrixlength
Aug 17, 2026
+18
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already ensured by the type system and an extremely common pattern. Generally we should be able to assume well-formed IR from the frontend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I agree with "we should be able to assume well-formed IR from the frontend." - the whole point of the validator is to ensure that code from other frontends is valid.
At the same time, I don't think it matters so much about hitting an assert in debug builds, as long as a non-assert enabled build rejects the invalid dxil.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well-formed and valid aren't the same thing :)
A proper frontend will not generate IR that calls a function with the wrong types for example. If we can't assume that the frontend generated a call to
foo(i32, float)with parameters ofi32, floatthen pretty much all bets are off and the backend needs to have essentially another copy of the frontend in it. (or at least the type checker)Separately, if we say it's only valid to call
foowith even integers then that's where we can't necessarily trust the frontend to not generate IR with odd integers so we validate.In this specific case, we only have overloads for
linAlgMatrixLengthwith a matrix in param slot 1, if the frontend ever generates anything different then the type system is very broken and the IR is not well-formedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't well-formedness validated elsewhere already before we get to this point?
Anyway, to be clear, I don't think this impacts this PR, but alarm bells go off if I hear anything suggesting that the validator should lean on the frontend, because the frontend isn't always there and is not something that's in the control of the validator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LLVM IR well-formedness is already validated elsewhere yeah but DXIL is a bit weird in this regard (in fact DXIL makes a lot of this weird since other folks generate it directly and its not really an IR anymore).
As long as the function is
declared correctly then we should expect a type error to already be generated if the wrong type is passed in, but I think copilot is commenting here because nothing stops someone from declaring an illegal overload of matrixlength that doesn't have a matrix as arg 1. That would be well-formed LLVM IR that passes the IR checker but not well-formed DXIL since its an illegal overload.Out of curiosity I'll hand build both of those rq and report back.
I suppose the question we need to answer more generally is: what is our responsibility to users who forgo the safety checks of the frontend and generate DXIL directly? Should we gracefully fail for all generatable DXIL thats well-formed enough to pass llvmir checks yet not well-formed DXIL? There is also certainly a gray area here on whether we should call illegal type overload for DXIL operations as "invalid" or "not well-formed" and I suppose I'm slowly talking myself into the first
aside: I do have to admit I found myself a bit snippy with copilot for calling out a pretty mundane thing as a "HIGH" priority issue after having seen the pattern at least 10 other times without saying anything about it. It reads a bit as trying to invent a comment when it had nothing else to say
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling with correct declaration but wrong parameter type errors as expected
Declaring a wrong overload for the operation (but calling it correctly) errors with an invalid overload error
So we properly catch both cases already and copilots comment was actually just superfluous. That said, my reason for rejecting the comment was also incorrect so I guess its a learning moment:)