[Mlir-commits] [mlir] [mlir][tosa] Add acc_type to Tosa-v1.0 Conv Ops (PR #121466)
Luke Hutton
llvmlistbot at llvm.org
Mon Jan 6 06:00:42 PST 2025
================
@@ -271,6 +271,55 @@ LogicalResult tosa::ConstOp::verify() {
return success();
}
+template <typename T>
+static LogicalResult verifyConvOpModes(T op) {
+ auto inputEType =
+ llvm::cast<ShapedType>(op.getInput().getType()).getElementType();
+
+ if (auto quantType =
+ llvm::dyn_cast<mlir::quant::UniformQuantizedType>(inputEType))
+ inputEType = quantType.getStorageType();
+
+ auto accType = op.getAccType();
+ if (inputEType.isInteger(8) && !accType.isInteger(32))
+ return op.emitOpError("accumulator type for i8 tensor is not i32");
+
+ if (inputEType.isInteger(16) && !accType.isInteger(48))
+ return op.emitOpError("accumulator type for i16 tensor is not i48");
+
+ if ((inputEType.isFloat8E5M2() || inputEType.isFloat8E4M3FN()) &&
+ !accType.isF16())
+ return op.emitOpError("accumulator type for f8 tensor is not f16");
+
+ if (inputEType.isF16() && !(accType.isF16() || accType.isF32()))
+ return op.emitOpError("accumulator type for f16 tensor is not f16/f32");
+
+ if (inputEType.isBF16() && !accType.isF32())
+ return op.emitOpError("accumulator type for bf16 tensor is not f32");
+
+ if (inputEType.isF32() && !accType.isF32())
+ return op.emitOpError("accumulator type for f32 tensor is not f32");
+
+ auto resultEType =
+ llvm::cast<ShapedType>(op.getResult().getType()).getElementType();
+
+ if (auto quantType =
+ llvm::dyn_cast<mlir::quant::UniformQuantizedType>(resultEType))
+ resultEType = quantType.getStorageType();
+
+ // check allowed input/result element types combinations
+ if ((inputEType.isInteger(8) && resultEType.isInteger(32)) ||
----------------
lhutton1 wrote:
We might want to be more careful about adding these checks, since they impose a new restriction on the allowed data types of the operator. Are they necessary for this PR? If not, perhaps we can remove them for now and re-introduce in the validation pass in a separate change to minimise the possible impact?
https://github.com/llvm/llvm-project/pull/121466
More information about the Mlir-commits
mailing list