[PATCH] D74820: [MLIR] Support memrefs with memref element types.

Kern Handa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 19 01:26:27 PST 2020


kernhanda created this revision.
kernhanda added reviewers: nicolasvasilache, ftynse, mehdi_amini.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, burmako, jpienaar, rriddle.
Herald added a reviewer: rriddle.
Herald added a project: LLVM.
kernhanda added a comment.

Perhaps memref should be agnostic to the element type it contains? Tensors and Vector types can remain more constrained, but memref should be able to act on many kinds of types, not just the basic fundamental ones.


With this change, it is now possible to create a memref that's comprised of other memref types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74820

Files:
  mlir/lib/IR/StandardTypes.cpp
  mlir/test/IR/parser.mlir


Index: mlir/test/IR/parser.mlir
===================================================================
--- mlir/test/IR/parser.mlir
+++ mlir/test/IR/parser.mlir
@@ -143,6 +143,15 @@
 // CHECK: func @unranked_memref_with_complex_elems(memref<*xcomplex<f32>>)
 func @unranked_memref_with_complex_elems(memref<*xcomplex<f32>>)
 
+// CHECK: func @memref_with_memref_elems(memref<1x?xmemref<f32>>)
+func @memref_with_memref_elems(memref<1x?xmemref<f32>>)
+
+// CHECK: func @unranked_memref_with_memref_elems(memref<*xmemref<f32>>)
+func @unranked_memref_with_memref_elems(memref<*xmemref<f32>>)
+
+// CHECK: func @functions_with_memref((memref<1x?x4x?x?xmemref<i32>, #map0>, memref<8xi8>) -> (), () -> ())
+func @functions_with_memref((memref<1x?x4x?x?xmemref<i32>, #map0, 0>, memref<8xi8, #map1, 0>) -> (), ()->())
+
 // CHECK: func @functions((memref<1x?x4x?x?xi32, #map0>, memref<8xi8>) -> (), () -> ())
 func @functions((memref<1x?x4x?x?xi32, #map0, 0>, memref<8xi8, #map1, 0>) -> (), ()->())
 
Index: mlir/lib/IR/StandardTypes.cpp
===================================================================
--- mlir/lib/IR/StandardTypes.cpp
+++ mlir/lib/IR/StandardTypes.cpp
@@ -334,7 +334,7 @@
 
   // Check that memref is formed from allowed types.
   if (!elementType.isIntOrFloat() && !elementType.isa<VectorType>() &&
-      !elementType.isa<ComplexType>())
+      !elementType.isa<ComplexType>() && !elementType.isa<BaseMemRefType>())
     return emitOptionalError(location, "invalid memref element type"),
            MemRefType();
 
@@ -413,7 +413,7 @@
     unsigned memorySpace) {
   // Check that memref is formed from allowed types.
   if (!elementType.isIntOrFloat() && !elementType.isa<VectorType>() &&
-      !elementType.isa<ComplexType>())
+      !elementType.isa<ComplexType>() && !elementType.isa<BaseMemRefType>())
     return emitOptionalError(*loc, "invalid memref element type");
   return success();
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74820.245329.patch
Type: text/x-patch
Size: 1915 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200219/9ab8b519/attachment.bin>


More information about the llvm-commits mailing list