[PATCH] D75309: [mlir] Add reifyReturnShape to shaped type OpInterface

Alexander Belyaev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 27 16:11:28 PST 2020


pifon2a added inline comments.


================
Comment at: mlir/include/mlir/Analysis/InferTypeOpInterface.td:108
+      /*args=*/(ins "OpBuilder&":$builder,
+                    "SmallVectorImpl<Value>&":$reifiedReturnShapes), [{}],
+    [{ return failure(); }]
----------------
nit:
```
/*methodBody=*/[{}],
/*defaultImplementation=*/[{ return failure(); }]
```


================
Comment at: mlir/test/lib/TestDialect/TestDialect.cpp:327
+    return emitOptionalError(location, "only shaped type operands allowed");
   }
+  inferedReturnShapes.reserve(1);
----------------
nit: maybe smth like:
```
auto sval = operandType.dyn_cast<ShapedType>();
if (!sval) {
    return emitOptionalError(location, "only shaped type operands allowed");
}
int64_t dim = sval.hasRank() ? sval.getShape().front() : ShapedType::kDynamicSize;  
```


================
Comment at: mlir/test/lib/TestDialect/TestDialect.cpp:328
   }
-  inferedComponents.reserve(1);
+  inferedReturnShapes.reserve(1);
   auto type = IntegerType::get(17, context);
----------------
just out of curiosity: is `reserve()` really needed for 1 element? 


================
Comment at: mlir/test/lib/TestDialect/TestDialect.cpp:329
+  inferedReturnShapes.reserve(1);
   auto type = IntegerType::get(17, context);
+  inferedReturnShapes.push_back(ShapedTypeComponents({dim}, type));
----------------
why 17?


================
Comment at: mlir/test/lib/TestDialect/TestDialect.cpp:337
+  shapes.resize(1);
+  shapes[0] = builder.createOrFold<mlir::DimOp>(getLoc(), getOperand(0), 0);
   return success();
----------------
will smth like that work?
```
shapes = {builder.createOrFold<mlir::DimOp>(getLoc(), getOperand(0), 0)};
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75309/new/

https://reviews.llvm.org/D75309





More information about the llvm-commits mailing list