[Mlir-commits] [mlir] [mlir][tosa] Add dim operation (PR #169368)

Luke Hutton llvmlistbot at llvm.org
Mon Jan 5 01:02:15 PST 2026


================
@@ -4663,6 +4648,24 @@ LogicalResult tosa::ConstShapeOp::verify() {
   return success();
 }
 
+LogicalResult tosa::DimOp::verify() {
+  const tosa::shapeType outShapeType =
+      cast<tosa::shapeType>(getResult().getType());
+  if (outShapeType.getRank() != 1)
+    return emitOpError("expect output shape type to contain one element, got ")
+           << outShapeType;
+
+  const ShapeAdaptor inputType(getInput1().getType());
+  if (inputType.hasRank()) {
----------------
lhutton1 wrote:

It can because `Tosa_TensorAtLeast1D` doesn't guarantee the tensor is ranked: https://github.com/llvm/llvm-project/blob/8723fe5606de6dfb344afacd667c20f55bb2f5e0/mlir/include/mlir/Dialect/Tosa/IR/TosaTypesBase.td#L208-L209

https://github.com/llvm/llvm-project/pull/169368


More information about the Mlir-commits mailing list