Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

conflicting collapsed shape requirement for memref reshape and linalg reshape ops #51536

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR52569
Status NEW
Importance P enhancement
Reported by Yi Zhang (cathyzhyi@google.com)
Reported on 2021-11-20 11:33:38 -0800
Last modified on 2021-11-23 10:59:43 -0800
Version unspecified
Hardware PC All
CC joker.eph@gmail.com, ravishankarm@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
with the following IR:
func @bufferize_tensor_expand_shape(%arg0: tensor<20x?xf32>) ->
tensor<4x5x?xf32> {
  %out = linalg.tensor_expand_shape %arg0 [[0, 1], [2]] :
     tensor<20x?xf32> into tensor<4x5x?xf32>
  return %out : tensor<4x5x?xf32>
}

memref verification would complain:
bufferize.mlir:2:10: error: 'memref.expand_shape' op expected collapsed type to
be 'memref<?x?xf32>', but got 'memref<20x?xf32>'
  %out = linalg.tensor_expand_shape %arg0 [[0, 1], [2]] :
         ^
bufferize.mlir:2:10: note: see current operation: %1 =
"memref.expand_shape"(%0) {reassociation = [[0, 1], [2]]} : (memref<20x?xf32>) -
> memref<4x5x?xf32>

However, changing the dims according to the memref verification error would
make linalg verification complain:
func @bufferize_tensor_expand_shape(%arg0: tensor<?x?xf32>) ->
tensor<4x5x?xf32> {
  %out = linalg.tensor_expand_shape %arg0 [[0, 1], [2]] :
     tensor<?x?xf32> into tensor<4x5x?xf32>
  return %out : tensor<4x5x?xf32>
}

bufferize.mlir:8:10: error: 'linalg.tensor_expand_shape' op expected dimension
0 of collapsed type to be static value of 20
  %out = linalg.tensor_expand_shape %arg0 [[0, 1], [2]] :
         ^
bufferize.mlir:8:10: note: see current operation: %0 =
"linalg.tensor_expand_shape"(%arg0) {reassociation = [[0, 1], [2]]} :
(tensor<?x?xf32>) -> tensor<4x5x?xf32>
Quuxplusone commented 2 years ago

Not sure why there is a memref.expand_shape coming in. In any case, the verifier of memref.expand_shape seems to be wrong here.

Quuxplusone commented 2 years ago

Sry I forgot the paste the command. The command to get the error is with mlir-opt -linalg-bufferize