Files
clang-p2996/mlir/test/Dialect/Shape/arg_with_shape.mlir
Xiang Li c3728d2882 [mlir] support !shape.value_shape when replace WithOp in OutlineShapeComputationPass.
Fixes #60069  https://github.com/llvm/llvm-project/issues/60069

In case like:
  %1 = shape.with_shape %arg1, %0 : !shape.value_shape, !shape.shape
  %2 = shape.value_of %1 : tensor<?xf32>
cannot replace %2 with %arg1.
Transform it into
  %2 = shape.value_of %arg1 : tensor<?xf32>

Differential Revision: https://reviews.llvm.org/D142275
2023-01-23 22:24:23 -05:00

17 lines
839 B
MLIR

// RUN: mlir-opt -outline-shape-computation -split-input-file %s 2>%t | FileCheck %s
func.func @func1(%arg0: !shape.value_shape, %arg1: !shape.value_shape) -> !shape.shape {
%0 = shape.shape_of %arg0 : !shape.value_shape -> !shape.shape
%1 = shape.shape_of %arg1 : !shape.value_shape -> !shape.shape
%2 = shape.meet %0, %1 : !shape.shape, !shape.shape -> !shape.shape
return %2 : !shape.shape
}
// Make sure with_shape used by call not crash.
// CHECK-LABEL:func.func @func
func.func @func(%arg0: !shape.value_shape, %arg1: !shape.value_shape) -> !shape.shape {
%0 = shape.shape_of %arg0 : !shape.value_shape -> !shape.shape
%1 = shape.with_shape %arg1, %0 : !shape.value_shape, !shape.shape
%2 = call @func1(%arg0, %1) : (!shape.value_shape, !shape.value_shape) -> !shape.shape
return %2 : !shape.shape
}