[Mlir-commits] [mlir] [mlir][tosa] Add more verifiers for the following operators (PR #127923)
Luke Hutton
llvmlistbot at llvm.org
Fri Feb 28 11:37:13 PST 2025
================
@@ -850,6 +850,71 @@ LogicalResult tosa::ConcatOp::inferReturnTypeComponents(
return success();
}
+LogicalResult tosa::ConcatOp::verify() {
+ // check that each input has same element type as output
+ auto outType = getOutput().getType();
+ const Operation::operand_range inputList = getInput1();
+
+ if (!llvm::all_of(inputList, [&](auto input) {
+ return succeeded(verifySameElementTypes(
+ *this, /* inType = */ input.getType(), outType));
+ })) {
+ return failure();
+ }
+
+ // Check there is at least one input
+ if (inputList.empty())
+ return emitOpError("expect at least one input");
+
+ const Type firstInputType = inputList.front().getType();
+ const ShapeAdaptor firstInputShape(firstInputType);
+ const int32_t axis = getAxis();
+
+ if (firstInputShape.hasRank()) {
----------------
lhutton1 wrote:
I think the case that @GeorgeARM is referring to here is something like:
```
tosa.const(tensor<*xf32>, tensor<1x2x3xf32>)
```
Which is a valid op, until it is determined that the first operand is not rank 3. At this point we should still be able to check that axis makes sense, to try to prove it’s invalid before proceeding further
https://github.com/llvm/llvm-project/pull/127923
More information about the Mlir-commits
mailing list