diff --git a/mlir/lib/IR/BuiltinAttributes.cpp b/mlir/lib/IR/BuiltinAttributes.cpp index 8861a94033613..f288dd42baaa1 100644 --- a/mlir/lib/IR/BuiltinAttributes.cpp +++ b/mlir/lib/IR/BuiltinAttributes.cpp @@ -245,9 +245,6 @@ AffineMap StridedLayoutAttr::getAffineMap() const { LogicalResult StridedLayoutAttr::verify(function_ref emitError, int64_t offset, ArrayRef strides) { - if (llvm::is_contained(strides, 0)) - return emitError() << "strides must not be zero"; - return success(); } @@ -1815,7 +1812,6 @@ AffineMap mlir::makeStridedLinearLayoutMap(ArrayRef strides, for (const auto &en : llvm::enumerate(strides)) { auto dim = en.index(); auto stride = en.value(); - assert(stride != 0 && "Invalid stride specification"); auto d = getAffineDimExpr(dim, context); AffineExpr mult; // Static case. diff --git a/mlir/lib/IR/BuiltinTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp index 25e9f80c9963c..c28c580690166 100644 --- a/mlir/lib/IR/BuiltinTypes.cpp +++ b/mlir/lib/IR/BuiltinTypes.cpp @@ -803,20 +803,6 @@ static LogicalResult getStridesAndOffset(MemRefType t, for (auto &stride : strides) stride = simplifyAffineExpr(stride, numDims, numSymbols); - // In practice, a strided memref must be internally non-aliasing. Test - // against 0 as a proxy. - // TODO: static cases can have more advanced checks. - // TODO: dynamic cases would require a way to compare symbolic - // expressions and would probably need an affine set context propagated - // everywhere. - if (llvm::any_of(strides, [](AffineExpr e) { - return e == getAffineConstantExpr(0, e.getContext()); - })) { - offset = AffineExpr(); - strides.clear(); - return failure(); - } - return success(); } diff --git a/mlir/test/Dialect/Affine/memref-stride-calculation.mlir b/mlir/test/Dialect/Affine/memref-stride-calculation.mlir index cce1946b391e7..29a5f5e0d5f44 100644 --- a/mlir/test/Dialect/Affine/memref-stride-calculation.mlir +++ b/mlir/test/Dialect/Affine/memref-stride-calculation.mlir @@ -51,9 +51,9 @@ func.func @f(%0: index) { %26 = memref.alloc(%0)[] : memref(i)>> // CHECK: MemRefType offset: 0 strides: 1 %27 = memref.alloc()[%0] : memref<5xf32, affine_map<(i)[M]->(M)>> -// CHECK: MemRefType memref<5xf32, affine_map<(d0)[s0] -> (s0)>> cannot be converted to strided form +// CHECK: MemRefType offset: ? strides: 0 %28 = memref.alloc()[%0] : memref<5xf32, affine_map<(i)[M]->(123)>> -// CHECK: MemRefType memref<5xf32, affine_map<(d0)[s0] -> (123)>> cannot be converted to strided form +// CHECK: MemRefType offset: 123 strides: 0 %29 = memref.alloc()[%0] : memref(M)>> // CHECK: MemRefType offset: ? strides: %30 = memref.alloc()[%0] : memref(123)>> diff --git a/mlir/test/Dialect/MemRef/invalid.mlir b/mlir/test/Dialect/MemRef/invalid.mlir index 51c4781c9022b..f72ad48245f81 100644 --- a/mlir/test/Dialect/MemRef/invalid.mlir +++ b/mlir/test/Dialect/MemRef/invalid.mlir @@ -245,16 +245,6 @@ func.func @memref_reinterpret_cast_no_map_but_strides(%in: memref) { // ----- -func.func @memref_reinterpret_cast_non_strided_layout(%in: memref) { - // expected-error @+1 {{expected result type to have strided layout but found 'memref<9x10xf32, affine_map<(d0, d1) -> (d0)>>}} - %out = memref.reinterpret_cast %in to - offset: [0], sizes: [9, 10], strides: [42, 1] - : memref to memref<9x10xf32, affine_map<(d0, d1) -> (d0)>> - return -} - -// ----- - func.func @memref_reshape_element_type_mismatch( %buf: memref<*xf32>, %shape: memref<1xi32>) { // expected-error @+1 {{element types of source and destination memref types should be the same}} diff --git a/mlir/test/IR/invalid-builtin-types.mlir b/mlir/test/IR/invalid-builtin-types.mlir index 07854a25000fe..51612446d2e6a 100644 --- a/mlir/test/IR/invalid-builtin-types.mlir +++ b/mlir/test/IR/invalid-builtin-types.mlir @@ -99,11 +99,6 @@ func.func private @memref_incorrect_strided_ending() -> memref memref> - -// ----- - // expected-error @below {{expected the number of strides to match the rank}} func.func private @memref_strided_rank_mismatch() -> memref>