[PATCH] D135734: [NFC][mlir][MemRef] Make use of InferTypeOpInterface

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 14 09:30:10 PDT 2022


qcolombet added inline comments.


================
Comment at: mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp:1257
+    SmallVectorImpl<Type> &inferredReturnTypes) {
+  auto sourceType = operands[0].getType().cast<MemRefType>();
+  unsigned sourceRank = sourceType.getRank();
----------------
jpienaar wrote:
> You can use the OpAdaptor generated for this op if you want to use the generated accessor methods.
Thanks for the pointer, let me double check that.


================
Comment at: mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp:1262
+      MemRefType::get({}, sourceType.getElementType(),
+                      MemRefLayoutAttrInterface{}, sourceType.getMemorySpace());
+  // Base.
----------------
jpienaar wrote:
> It's been some time since I've worked with memrefs. To double check: they always have a memory space and rank? And it's fine to ignore layout here and just insert empty?
Thanks for double checking.

For `MemRefType`s, yes they always have a rank and memory space.

`UnrankedMemRefType` don't have a rank, but they inherit from `BaseMemRefType`, not `MemRefType` (i.e., `MemRefType` == ranked, `UnrankedMemRefType` == unranked). I believe this is how we tell them apart. 

Regarding the layout, yes, this is what we want. Essentially this operation generate 0-D memref from an arbitrary memref.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135734



More information about the llvm-commits mailing list