[SM6.10] LinAlg Validation: Validate Params and K Dim#8588
Conversation
bob80905
left a comment
There was a problem hiding this comment.
I think we should add a test that checks for the new diagnostic.
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
bob80905
left a comment
There was a problem hiding this comment.
My other comment is a nit, it can be taken or left. Otherwise, LGTM
| ConstantInt *Ints[5]; | ||
|
|
||
| for (size_t I = 0; I < 5; ++I) { | ||
| ConstantAsMetadata *ConstMDI = | ||
| dyn_cast<ConstantAsMetadata>(MDT->getOperand(I + 1).get()); | ||
| if (!ConstMDI) | ||
| return std::nullopt; | ||
| ConstantInt *CI = dyn_cast<ConstantInt>(ConstMDI->getValue()); | ||
| if (!CI) | ||
| return std::nullopt; | ||
| Ints[I] = CI; | ||
| } | ||
|
|
||
| LinAlgTargetType LATT; | ||
| LATT.Type = static_cast<DXIL::ComponentType>(Ints[0]->getLimitedValue()); | ||
| LATT.M = Ints[1]->getLimitedValue(); | ||
| LATT.N = Ints[2]->getLimitedValue(); | ||
| LATT.Use = static_cast<DXIL::MatrixUse>(Ints[3]->getLimitedValue()); | ||
| LATT.Scope = static_cast<DXIL::MatrixScope>(Ints[4]->getLimitedValue()); | ||
|
|
||
| return {{Ty, LATT}}; |
There was a problem hiding this comment.
(read the next comment first please ;))
This is want I have in mind:
| ConstantInt *Ints[5]; | |
| for (size_t I = 0; I < 5; ++I) { | |
| ConstantAsMetadata *ConstMDI = | |
| dyn_cast<ConstantAsMetadata>(MDT->getOperand(I + 1).get()); | |
| if (!ConstMDI) | |
| return std::nullopt; | |
| ConstantInt *CI = dyn_cast<ConstantInt>(ConstMDI->getValue()); | |
| if (!CI) | |
| return std::nullopt; | |
| Ints[I] = CI; | |
| } | |
| LinAlgTargetType LATT; | |
| LATT.Type = static_cast<DXIL::ComponentType>(Ints[0]->getLimitedValue()); | |
| LATT.M = Ints[1]->getLimitedValue(); | |
| LATT.N = Ints[2]->getLimitedValue(); | |
| LATT.Use = static_cast<DXIL::MatrixUse>(Ints[3]->getLimitedValue()); | |
| LATT.Scope = static_cast<DXIL::MatrixScope>(Ints[4]->getLimitedValue()); | |
| return {{Ty, LATT}}; | |
| uint64_t Ints[5]; | |
| for (size_t I = 0; I < 5; ++I) { | |
| ConstantAsMetadata *ConstMDI = | |
| dyn_cast<ConstantAsMetadata>(MDT->getOperand(I + 1).get()); | |
| if (!ConstMDI) | |
| return; | |
| ConstantInt *CI = dyn_cast<ConstantInt>(ConstMDI->getValue()); | |
| if (!CI) | |
| return; | |
| Ints[I] = CI->getLimitedValue(); | |
| } | |
| auto Result = Map.try_emplace(Ty, static_cast<DXIL::ComponentType>(Ints[0]), | |
| Ints[1], Ints[2], static_cast<DXIL::MatrixUse>(Ints[3]), | |
| static_cast<DXIL::MatrixScope>(Ints[4])); | |
| if (!Result.second) | |
| ;// TODO: validation error - metadata for this type already exists | |
There was a problem hiding this comment.
how strongly do you want the validation error for type already exists?
The map is built up during initialization/before we have access to a ValidationContext (in fact this function call is in the ValContext ctor). If we want to raise an error there, we'll need to do some rearchitecting somewhere.
There was a problem hiding this comment.
In that case I think it is fine to ignore the duplicate types.
5918212 to
d40bb08
Compare
Add the following validation rules:
undefis disallowed as a LinAlg builtin parameterThe vast majority of the change is updating tests that were previously out of spec as well as adding new tests that intentionally raise the new validation failures.
Some of the tests are fixed by using the fillmatrix builtin to have an actual matrix SSA value. This will be invalid in some cases but those invalid uses will be much easier to fix as they are found/disallowed by future validation PRs