@@ -402,7 +402,7 @@ def Bufferization_ToTensorOp : Bufferization_Op<"to_tensor", [
402
402
403
403
```mlir
404
404
// 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>
406
406
```
407
407
408
408
If the `writable` unit attribute is set, the produced tensor is considered
@@ -425,7 +425,7 @@ def Bufferization_ToTensorOp : Bufferization_Op<"to_tensor", [
425
425
Example:
426
426
427
427
```
428
- %t = bufferization.to_tensor %m restrict writable : memref<4xf32>
428
+ %t = bufferization.to_tensor %m restrict writable : memref<4xf32> -> tensor<4xf32>
429
429
430
430
// %t is writable, so the tensor.insert may bufferize in-place in the
431
431
// absence of other conflicts.
@@ -498,18 +498,16 @@ def Bufferization_ToMemrefOp : Bufferization_Op<"to_memref", [
498
498
SameOperandsAndResultShape,
499
499
SameOperandsAndResultElementType,
500
500
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"]>
505
503
]> {
506
504
let summary = "cast a tensor to memref";
507
505
let description = [{
508
506
An operation that returns the future buffer of a `tensor`.
509
507
510
508
```mlir
511
509
// 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>
513
511
```
514
512
515
513
This operation is a specialized variant of the built-in
0 commit comments