[Mlir-commits] [mlir] bbe79e2 - [mlir][spirv] Fix encoding of cooperative matrix type to match SPIRV spec
Thomas Raoux
llvmlistbot at llvm.org
Tue Jun 2 16:29:17 PDT 2020
Author: Thomas Raoux
Date: 2020-06-02T16:28:56-07:00
New Revision: bbe79e27bdfbf59838e4d409038aef78a8161989
URL: https://github.com/llvm/llvm-project/commit/bbe79e27bdfbf59838e4d409038aef78a8161989
DIFF: https://github.com/llvm/llvm-project/commit/bbe79e27bdfbf59838e4d409038aef78a8161989.diff
LOG: [mlir][spirv] Fix encoding of cooperative matrix type to match SPIRV spec
Scope, rows and columns need to be encoded in a separate constant operation.
Differential Revision: https://reviews.llvm.org/D80852
Added:
Modified:
mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
index 750dddfa6dc4..fafb916460b8 100644
--- a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
+++ b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
@@ -1251,15 +1251,15 @@ Deserializer::processCooperativeMatrixType(ArrayRef<uint32_t> operands) {
<< operands[1];
}
- auto scope = spirv::symbolizeScope(operands[2]);
+ auto scope = spirv::symbolizeScope(getConstantInt(operands[2]).getInt());
if (!scope) {
return emitError(unknownLoc,
"OpTypeCooperativeMatrix references undefined scope <id> ")
<< operands[2];
}
- unsigned rows = operands[3];
- unsigned columns = operands[4];
+ unsigned rows = getConstantInt(operands[3]).getInt();
+ unsigned columns = getConstantInt(operands[4]).getInt();
typeMap[operands[0]] = spirv::CooperativeMatrixNVType::get(
elementTy, scope.getValue(), rows, columns);
diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
index 0b1c970589b1..67d99124eb78 100644
--- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
+++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
@@ -1104,10 +1104,15 @@ Serializer::prepareBasicType(Location loc, Type type, uint32_t resultID,
return failure();
}
typeEnum = spirv::Opcode::OpTypeCooperativeMatrixNV;
+ auto getConstantOp = [&](uint32_t id) {
+ auto attr = IntegerAttr::get(IntegerType::get(32, type.getContext()), id);
+ return prepareConstantInt(loc, attr);
+ };
operands.push_back(elementTypeID);
- operands.push_back(static_cast<uint32_t>(cooperativeMatrixType.getScope()));
- operands.push_back(cooperativeMatrixType.getRows());
- operands.push_back(cooperativeMatrixType.getColumns());
+ operands.push_back(
+ getConstantOp(static_cast<uint32_t>(cooperativeMatrixType.getScope())));
+ operands.push_back(getConstantOp(cooperativeMatrixType.getRows()));
+ operands.push_back(getConstantOp(cooperativeMatrixType.getColumns()));
return success();
}
More information about the Mlir-commits
mailing list