[Mlir-commits] [mlir] [mlir][spirv] Add OpExtension "SPV_INTEL_tensor_float32_conversion " (PR #151337)
Igor Wodiany
llvmlistbot at llvm.org
Wed Jul 30 09:45:55 PDT 2025
================
@@ -297,13 +300,40 @@ LogicalResult INTELConvertBF16ToFOp::verify() {
LogicalResult INTELConvertFToBF16Op::verify() {
auto operandType = getOperand().getType();
auto resultType = getResult().getType();
- // ODS checks that vector result type and vector operand type have the same
- // shape.
- if (auto vectorType = llvm::dyn_cast<VectorType>(operandType)) {
- unsigned operandNumElements = vectorType.getNumElements();
- unsigned resultNumElements =
- llvm::cast<VectorType>(resultType).getNumElements();
- if (operandNumElements != resultNumElements) {
+ // ODS checks that vector result type and vector operand type are
+ // non-scalable and have the same shape.
+ auto operandVectorType = dyn_cast<VectorType>(operandType);
+ auto resultVectorType = dyn_cast<VectorType>(resultType);
+ if (operandVectorType && resultVectorType) {
+ if (operandVectorType.isScalable() || resultVectorType.isScalable()) {
+ return emitOpError("scalable vectors are not supported");
+ }
+ if (operandVectorType.getNumElements() !=
+ resultVectorType.getNumElements()) {
+ return emitOpError(
+ "operand and result must have same number of elements");
+ }
+ }
+ return success();
+}
+
+//===----------------------------------------------------------------------===//
+// spirv.INTELRoundFToTF32Op
+//===----------------------------------------------------------------------===//
+
+LogicalResult INTELRoundFToTF32Op::verify() {
+ auto operandType = getOperand().getType();
+ auto resultType = getResult().getType();
+ // ODS checks that vector result type and vector operand type are
+ // non-scalable and have the same shape.
+ auto operandVectorType = dyn_cast<VectorType>(operandType);
+ auto resultVectorType = dyn_cast<VectorType>(resultType);
+ if (operandVectorType && resultVectorType) {
----------------
IgWod-IMG wrote:
To add to it. Could it be checked in ODS? For example with ` SameOperandsAndResultShape` or something similar? There may even be a trait to make sure vector is not scalable. That would mean that there is no need for C++ verification.
https://github.com/llvm/llvm-project/pull/151337
More information about the Mlir-commits
mailing list