[Mlir-commits] [mlir] [mlir][tosa] Add more verifiers for the following operators (PR #127923)
Georgios Pinitas
llvmlistbot at llvm.org
Fri Feb 28 05:48:41 PST 2025
================
@@ -899,6 +964,57 @@ LogicalResult tosa::MatMulOp::inferReturnTypeComponents(
return success();
}
+LogicalResult MatMulOp::verify() {
+ auto aType = llvm::dyn_cast<ShapedType>(getA().getType());
+ auto bType = llvm::dyn_cast<ShapedType>(getB().getType());
+
+ // Must be shaped tensor types
+ if (!aType) {
+ emitOpError("expect a shaped tensor for input a, got ") << getA().getType();
+ return failure();
+ }
+ if (!bType) {
+ emitOpError("expect a shaped tensor for input b, got ") << getB().getType();
+ return failure();
+ }
+
+ auto aElementType = aType.getElementType();
+ auto bElementType = bType.getElementType();
+
+ auto aQuantizedEType =
+ llvm::dyn_cast<quant::UniformQuantizedType>(aElementType);
+ auto bQuantizedEType =
+ llvm::dyn_cast<quant::UniformQuantizedType>(bElementType);
+
+ if (aQuantizedEType || bQuantizedEType) {
----------------
GeorgeARM wrote:
Ok fine with it. Was thinking something across the lines of :
- `(aQuantizedEType && !bQuantizedEType) || (!aQuantizedEType && bQuantizedEType)`
- `(aQuantizedEType && aQuantizedEType.getStorageTypeIntegralWidth() == bQuantizedEType.getStorageTypeIntegralWidth())`
But I see that then the `getStorageTypeIntegralWidth()` in the printer needs to be down probably twice. Eitherway.
https://github.com/llvm/llvm-project/pull/127923
More information about the Mlir-commits
mailing list