Skip to content

Commit 7780f90

Browse files
Address reviewer comments
1 parent 7d49e14 commit 7780f90

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
lines changed

mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def Bufferization_ToTensorOp : Bufferization_Op<"to_tensor", [
402402

403403
```mlir
404404
// Produces a value of tensor<4x?xf32> type.
405-
%t = bufferization.to_tensor %m : memref<4x?xf32, #layout, 0>
405+
%t = bufferization.to_tensor %m : memref<4x?xf32, #layout, 0> -> tensor<4x?xf32>
406406
```
407407

408408
If the `writable` unit attribute is set, the produced tensor is considered
@@ -425,7 +425,7 @@ def Bufferization_ToTensorOp : Bufferization_Op<"to_tensor", [
425425
Example:
426426

427427
```
428-
%t = bufferization.to_tensor %m restrict writable : memref<4xf32>
428+
%t = bufferization.to_tensor %m restrict writable : memref<4xf32> -> tensor<4xf32>
429429

430430
// %t is writable, so the tensor.insert may bufferize in-place in the
431431
// absence of other conflicts.
@@ -498,18 +498,16 @@ def Bufferization_ToMemrefOp : Bufferization_Op<"to_memref", [
498498
SameOperandsAndResultShape,
499499
SameOperandsAndResultElementType,
500500
Pure,
501-
TypesMatchWith<"type of 'tensor' is the tensor equivalent of 'memref'",
502-
"memref", "tensor",
503-
"memref::getTensorTypeFromMemRefType($_self)",
504-
"bufferization::detail::tensorTypesMatchUpToEncoding">
501+
AllShapesMatch<["memref", "tensor"]>,
502+
AllElementTypesMatch<["memref", "tensor"]>
505503
]> {
506504
let summary = "cast a tensor to memref";
507505
let description = [{
508506
An operation that returns the future buffer of a `tensor`.
509507

510508
```mlir
511509
// Result type is memref<4x?xf32, #layout, 0>
512-
%m = bufferization.to_memref %t : memref<4x?xf32, #layout, 0>
510+
%m = bufferization.to_memref %t : tensor<4x?xf32> -> memref<4x?xf32, #layout, 0>
513511
```
514512

515513
This operation is a specialized variant of the built-in

mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ BufferizeTypeConverter::BufferizeTypeConverter() {
6767
ValueRange inputs, Location loc) -> Value {
6868
assert(inputs.size() == 1 && "expected exactly one input");
6969

70-
// Unranked to ranked casts must be explicit.
71-
if (auto inputType = dyn_cast<UnrankedMemRefType>(inputs[0].getType()))
72-
return nullptr;
73-
7470
if (auto inputType = dyn_cast<MemRefType>(inputs[0].getType())) {
7571
// MemRef to MemRef cast.
7672
assert(inputType != type && "expected different types");

mlir/test/Dialect/Bufferization/Transforms/finalizing-bufferize.mlir

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,3 @@ func.func @no_layout_to_dyn_layout_cast(%m: memref<?xf32>) -> memref<?xf32, stri
8383
// expected-note @below{{see existing live user here}}
8484
return %1 : memref<?xf32, strided<[1], offset: ?>>
8585
}
86-
87-
// -----
88-
89-
func.func @illegal_unranked_to_rank(%m: memref<*xf32>) -> memref<?xf32> {
90-
91-
%0 = bufferization.to_tensor %m : memref<*xf32> -> tensor<*xf32>
92-
// expected-error @+1 {{failed to legalize unresolved materialization from ('memref<*xf32>') to 'memref<?xf32>' that remained live after conversion}}
93-
%1 = bufferization.to_memref %0 : tensor<*xf32> -> memref<?xf32>
94-
return %1 : memref<?xf32>
95-
}

0 commit comments

Comments
 (0)