[Mlir-commits] [mlir] [mlir][Transforms] Dialect conversion: Add missing "else if" branch (PR #101148)
Adrian Kuegel
llvmlistbot at llvm.org
Wed Jul 31 03:50:57 PDT 2024
akuegel wrote:
Confirmed, your patch also makes sure that the test still passes. Here is the IR in the faling case:
```
module {
func.func @tensorlistWhileLoop(%arg0: tensor<2x3xf32>) -> tensor<2x3xf32> {
%cst = arith.constant dense<3> : tensor<1xi32>
%cst_0 = arith.constant dense<0> : tensor<i32>
%cst_1 = arith.constant dense<-1> : tensor<i32>
%0 = "tf.TensorListFromTensor"(%arg0, %cst) : (tensor<2x3xf32>, tensor<1xi32>) -> tensor<!tf_type.variant<tensor<3xf32>>>
%1:2 = "tf.While"(%cst_0, %0) <{body = @tensorlistWhileBody, cond = @tensorlistWhileCond, is_stateless = false}> {T = ["tfdtype$DT_INT32", "tfdtype$DT_VARIANT"]} : (tensor<i32>, tensor<!tf_type.variant<tensor<3xf32>>>) -> (tensor<i32>, tensor<!tf_type.variant<tensor<*xf32>>>)
%2 = "tf.TensorListStack"(%1#1, %cst_1) : (tensor<!tf_type.variant<tensor<*xf32>>>, tensor<i32>) -> tensor<2x3xf32>
return %2 : tensor<2x3xf32>
}
}
```
Before:
```
func.func @tensorlistWhileLoop(%arg0: tensor<2x3xf32>) -> tensor<2x3xf32> {
%cst = arith.constant dense<3> : tensor<1xi32>
%cst_0 = arith.constant dense<0> : tensor<i32>
%cst_1 = arith.constant dense<-1> : tensor<i32>
%0 = "tf.TensorListFromTensor"(%arg0, %cst) : (tensor<2x3xf32>, tensor<1xi32>) -> tensor<!tf_type.variant<tensor<3xf32>>>
%1:2 = "tf.While"(%cst_0, %0) {T = ["tfdtype$DT_INT32", "tfdtype$DT_VARIANT"], body = @tensorlistWhileBody, cond = @tensorlistWhileCond, is_stateless = false} : (tensor<i32>, tensor<!tf_type.variant<tensor<3xf32>>>) -> (tensor<i32>, tensor<!tf_type.variant<tensor<*xf32>>>)
%2 = "tf.TensorListStack"(%1#1, %cst_1) : (tensor<!tf_type.variant<tensor<*xf32>>>, tensor<i32>) -> tensor<2x3xf32>
func.return %2 : tensor<2x3xf32>
}
```
https://github.com/llvm/llvm-project/pull/101148
More information about the Mlir-commits
mailing list