Skip to content

Commit

Permalink
Fix TopologicalSort for Joint and Cooperative matrices (#2143)
Browse files Browse the repository at this point in the history
visit method of the sort relies on getNonLiteralOperands method of the
SPIRVType which is being inserted in the module. Without it dependent
types can be inserted in the module in incorrect order.

For example:
TypeCooperativeMatrixKHR %ID%
TypeStruct ... %ID%
is the correct order, but without the patch in some cases the translator
could generate the opposite order.

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
  • Loading branch information
MrSidims authored Sep 1, 2023
1 parent 8701279 commit 436c497
Show file tree
Hide file tree
Showing 3 changed files with 881 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/SPIRV/libSPIRV/SPIRVType.h
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,10 @@ class SPIRVTypeJointMatrixINTEL : public SPIRVType {
return Args.size() > 5 ? Args[5] : nullptr;
return Args.size() > 4 ? Args[4] : nullptr;
}

std::vector<SPIRVEntry *> getNonLiteralOperands() const override {
return std::vector<SPIRVEntry *>(1, CompType);
}
};

class SPIRVTypeCooperativeMatrixKHR : public SPIRVType {
Expand Down Expand Up @@ -1142,6 +1146,10 @@ class SPIRVTypeCooperativeMatrixKHR : public SPIRVType {
SPIRVValue *getRows() const { return Args[1]; }
SPIRVValue *getColumns() const { return Args[2]; }
SPIRVValue *getUse() const { return Args[3]; }

std::vector<SPIRVEntry *> getNonLiteralOperands() const override {
return std::vector<SPIRVEntry *>(1, CompType);
}
};

} // namespace SPIRV
Expand Down
Loading

0 comments on commit 436c497

Please sign in to comment.