[go: nahoru, domu]

Skip to content

Commit

Permalink
Integrate LLVM at llvm/llvm-project@54b61adc0cbe
Browse files Browse the repository at this point in the history
Updates LLVM usage to match
[54b61adc0cbe](llvm/llvm-project@54b61adc0cbe)

PiperOrigin-RevId: 646923337
  • Loading branch information
d0k authored and tensorflower-gardener committed Jun 26, 2024
1 parent bb1ee2f commit b572b20
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 106 deletions.
212 changes: 108 additions & 104 deletions tensorflow/compiler/mlir/lite/tests/lower-static-tensor-list.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -299,91 +299,93 @@ func.func @tensorlistLength(%arg0: tensor<3x10xf32>, %arg1: tensor<1xi32>) -> (t
}

// -----

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>
// TODO: Re-enable the tensorlistWhileLoop, tensorlistWhileBody,
// tensorlistWhileCond, tensorlistWhileRegion tests after the fix of b/349409532.

//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>

// make sure the variant types in input/output have been updated, and `T` attribute
// is removed.
// CHECK-LABEL: func @tensorlistWhileLoop
// CHECK-NOT: "tf.While"{{.*}}T =
// CHECK: "tf.While"
// CHECK-SAME: (tensor<i32>, tensor<2x3xf32>) -> (tensor<i32>, tensor<2x3xf32>)
// CHECK: return %0#1 : tensor<2x3xf32>
}

func.func @tensorlistWhileBody(%arg0: tensor<i32>, %arg1: tensor<!tf_type.variant>) -> (tensor<i32>, tensor<!tf_type.variant>) {
%0 = "tf.TensorListLength"(%arg1) : (tensor<!tf_type.variant>) -> tensor<i32>
%1 = "tf.Identity"(%arg1) : (tensor<!tf_type.variant>) -> tensor<!tf_type.variant>
func.return %0, %1 : tensor<i32>, tensor<!tf_type.variant>
// C_HECK-LABEL: func @tensorlistWhileLoop
// C_HECK-NOT: "tf.While"{{.*}}T =
// C_HECK: "tf.While"
// C_HECK-SAME: (tensor<i32>, tensor<2x3xf32>) -> (tensor<i32>, tensor<2x3xf32>)
// C_HECK: return %0#1 : tensor<2x3xf32>
// }

// func.func @tensorlistWhileBody(%arg0: tensor<i32>, %arg1: tensor<!tf_type.variant>) -> (tensor<i32>, tensor<!tf_type.variant>) {
// %0 = "tf.TensorListLength"(%arg1) : (tensor<!tf_type.variant>) -> tensor<i32>
// %1 = "tf.Identity"(%arg1) : (tensor<!tf_type.variant>) -> tensor<!tf_type.variant>
// func.return %0, %1 : tensor<i32>, tensor<!tf_type.variant>

// verify `body` function's signature.
// CHECK: func @tensorlistWhileBody(%[[ARG0:.*]]: tensor<i32>, %[[ARG:.*]]: tensor<2x3xf32>) -> (tensor<i32>, tensor<2x3xf32>)
// CHECK-NOT: tensor<!tf_type.variant>
// CHECK: %[[LEN:.*]] = "tf.Gather"
// CHECK-NOT: tensor<!tf_type.variant>
// CHECK: %[[LIST:.*]] = "tf.Identity"(%arg1) : (tensor<2x3xf32>) -> tensor<2x3xf32>
// CHECK: return %[[LEN]], %[[LIST]] : tensor<i32>, tensor<2x3xf32>
}

func.func @tensorlistWhileCond(%arg0: tensor<i32>, %arg1: tensor<!tf_type.variant>) -> tensor<i1> {
%cst = arith.constant dense<2> : tensor<i32>
%0 = "tf.Less"(%arg0, %cst) : (tensor<i32>, tensor<i32>) -> tensor<i1>
func.return %0 : tensor<i1>
// C_HECK: func @tensorlistWhileBody(%[[ARG0:.*]]: tensor<i32>, %[[ARG:.*]]: tensor<2x3xf32>) -> (tensor<i32>, tensor<2x3xf32>)
// C_HECK-NOT: tensor<!tf_type.variant>
// C_HECK: %[[LEN:.*]] = "tf.Gather"
// C_HECK-NOT: tensor<!tf_type.variant>
// C_HECK: %[[LIST:.*]] = "tf.Identity"(%arg1) : (tensor<2x3xf32>) -> tensor<2x3xf32>
// C_HECK: return %[[LEN]], %[[LIST]] : tensor<i32>, tensor<2x3xf32>
// }

// func.func @tensorlistWhileCond(%arg0: tensor<i32>, %arg1: tensor<!tf_type.variant>) -> tensor<i1> {
// %cst = arith.constant dense<2> : tensor<i32>
// %0 = "tf.Less"(%arg0, %cst) : (tensor<i32>, tensor<i32>) -> tensor<i1>
// func.return %0 : tensor<i1>

// verify `cond` function's signature.
// CHECK: func @tensorlistWhileCond(%[[ARG0:.*]]: tensor<i32>, %[[ARG1:.*]]: tensor<2x3xf32>) -> tensor<i1>
// CHECK: %[[RESULT:.*]] = "tf.Less"(%[[ARG0]], {{.*}}) : (tensor<i32>, tensor<i32>) -> tensor<i1>
// CHECK: return %[[RESULT]] : tensor<i1>
}
// C_HECK: func @tensorlistWhileCond(%[[ARG0:.*]]: tensor<i32>, %[[ARG1:.*]]: tensor<2x3xf32>) -> tensor<i1>
// C_HECK: %[[RESULT:.*]] = "tf.Less"(%[[ARG0]], {{.*}}) : (tensor<i32>, tensor<i32>) -> tensor<i1>
// C_HECK: return %[[RESULT]] : tensor<i1>
// }

// -----

// CHECK-LABEL: func @tensorlistWhileRegion
func.func @tensorlistWhileRegion(%arg0: tensor<2x3xf32>) -> tensor<*xf32> {
%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>>>
// CHECK: "tf.WhileRegion"
// CHECK: <{is_stateless = false}>
%1:2 = "tf.WhileRegion"(%cst_0, %0) <{is_stateless = false}> ({
^bb0(%carg0: tensor<i32>, %carg1: tensor<!tf_type.variant>):
%cst_2 = arith.constant dense<2> : tensor<i32>
%1 = "tf.Less"(%carg0, %cst_2) : (tensor<i32>, tensor<i32>) -> tensor<i1>
"tf.Yield"(%1) : (tensor<i1>) -> ()
// C_HECK-LABEL: func @tensorlistWhileRegion
// func.func @tensorlistWhileRegion(%arg0: tensor<2x3xf32>) -> tensor<*xf32> {
// %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>>>
// C_HECK: "tf.WhileRegion"
// C_HECK: <{is_stateless = false}>
// %1:2 = "tf.WhileRegion"(%cst_0, %0) <{is_stateless = false}> ({
// ^bb0(%carg0: tensor<i32>, %carg1: tensor<!tf_type.variant>):
// %cst_2 = arith.constant dense<2> : tensor<i32>
// %1 = "tf.Less"(%carg0, %cst_2) : (tensor<i32>, tensor<i32>) -> tensor<i1>
// "tf.Yield"(%1) : (tensor<i1>) -> ()

// verify condition types
// CHECK: ^bb0(%[[CARG0:.*]]: tensor<i32>, %[[CARG1:.*]]: tensor<*xf32>):
// CHECK: %[[COND:.*]] = "tf.Less"(%[[CARG0]], {{.*}}) : (tensor<i32>, tensor<i32>) -> tensor<i1>
// CHECK: "tf.Yield"(%[[COND]]) : (tensor<i1>) -> ()

},
{
^bb0(%barg0: tensor<i32>, %barg1: tensor<!tf_type.variant>):
%1 = "tf.TensorListLength"(%barg1) : (tensor<!tf_type.variant>) -> tensor<i32>
"tf.Yield"(%1, %barg1) : (tensor<i32>, tensor<!tf_type.variant>) -> ()

// C_HECK: ^bb0(%[[CARG0:.*]]: tensor<i32>, %[[CARG1:.*]]: tensor<*xf32>):
// C_HECK: %[[COND:.*]] = "tf.Less"(%[[CARG0]], {{.*}}) : (tensor<i32>, tensor<i32>) -> tensor<i1>
// C_HECK: "tf.Yield"(%[[COND]]) : (tensor<i1>) -> ()

// },
// {
// ^bb0(%barg0: tensor<i32>, %barg1: tensor<!tf_type.variant>):
// %1 = "tf.TensorListLength"(%barg1) : (tensor<!tf_type.variant>) -> tensor<i32>
// "tf.Yield"(%1, %barg1) : (tensor<i32>, tensor<!tf_type.variant>) -> ()
//
// verify body types
// CHECK: ^bb0(%[[BARG0:.*]]: tensor<i32>, %[[BARG1:.*]]: tensor<*xf32>):
// CHECK-NOT: tensor<!tf_type.variant>
// CHECK: %[[LEN:.*]] = "tf.Gather"
// CHECK-NOT: tensor<!tf_type.variant>
// CHECK: "tf.Yield"(%[[LEN]], %[[BARG1]]) : (tensor<i32>, tensor<*xf32>) -> ()
// C_HECK: ^bb0(%[[BARG0:.*]]: tensor<i32>, %[[BARG1:.*]]: tensor<*xf32>):
// C_HECK-NOT: tensor<!tf_type.variant>
// C_HECK: %[[LEN:.*]] = "tf.Gather"
// C_HECK-NOT: tensor<!tf_type.variant>
// C_HECK: "tf.Yield"(%[[LEN]], %[[BARG1]]) : (tensor<i32>, tensor<*xf32>) -> ()

}) : (tensor<i32>, tensor<!tf_type.variant<tensor<3xf32>>>) -> (tensor<i32>, tensor<!tf_type.variant<tensor<*xf32>>>)
// }) : (tensor<i32>, tensor<!tf_type.variant<tensor<3xf32>>>) -> (tensor<i32>, tensor<!tf_type.variant<tensor<*xf32>>>)
// make sure the variant types in input/output have been updated
// : (tensor<i32>, tensor<2x3xf32>) -> (tensor<i32>, tensor<*xf32>)
%2 = "tf.TensorListStack"(%1#1, %cst_1) : (tensor<!tf_type.variant<tensor<*xf32>>>, tensor<i32>) -> tensor<*xf32>
// CHECK: return %0#1 : tensor<*xf32>
func.return %2 : tensor<*xf32>
}
// %2 = "tf.TensorListStack"(%1#1, %cst_1) : (tensor<!tf_type.variant<tensor<*xf32>>>, tensor<i32>) -> tensor<*xf32>
// C_HECK: return %0#1 : tensor<*xf32>
// func.return %2 : tensor<*xf32>
//}

// -----

Expand Down Expand Up @@ -556,38 +558,40 @@ func.func @tensorlistWhileCond(%arg0: tensor<i32>, %arg1: tensor<!tf_type.varian
}

// -----

func.func @tensorListIf(%arg0: tensor<3x10xf32>, %arg1: tensor<1xi32>, %arg2: tensor<i32>) -> tensor<3x10xf32> {
%cst = arith.constant dense<2> : tensor<i32>
%0 = "tf.TensorListFromTensor"(%arg0, %arg1) : (tensor<3x10xf32>, tensor<1xi32>) -> tensor<!tf_type.variant<tensor<10xf32>>>
%1 = "tf.Less"(%arg2, %cst) : (tensor<i32>, tensor<i32>) -> tensor<i1>
%res = "tf.If"(%1, %0) {else_branch = @tensorListIfCondFalse, is_stateless = true, then_branch = @tensorListIfCondTrue} : (tensor<i1>, tensor<!tf_type.variant<tensor<10xf32>>>) -> tensor<!tf_type.variant<tensor<10xf32>>>
%2 = "tf.TensorListStack"(%res, %arg1) : (tensor<!tf_type.variant<tensor<10xf32>>>, tensor<1xi32>) -> tensor<3x10xf32>
func.return %2 : tensor<3x10xf32>

// CHECK: func @tensorListIf
// CHECK-NEXT: %cst = arith.constant dense<2> : tensor<i32>
// CHECK-NEXT: %0 = "tf.Less"(%arg2, %cst) : (tensor<i32>, tensor<i32>) -> tensor<i1>
// CHECK-NEXT: %1 = "tf.If"(%0, %arg0) <{else_branch = @tensorListIfCondFalse, is_stateless = true, then_branch = @tensorListIfCondTrue}> : (tensor<i1>, tensor<3x10xf32>) -> tensor<3x10xf32>
// CHECK-NEXT: return %1 : tensor<3x10xf32>
}

func.func @tensorListIfCondTrue(%arg0: tensor<!tf_type.variant<tensor<10xf32>>>) -> (tensor<!tf_type.variant<tensor<10xf32>>>) {
%cst = arith.constant dense<0> : tensor<i32>
%cst_0 = arith.constant dense<0.0> : tensor<10xf32>
%0 = "tf.TensorListSetItem"(%arg0, %cst, %cst_0) : (tensor<!tf_type.variant<tensor<10xf32>>>, tensor<i32>, tensor<10xf32>) -> tensor<!tf_type.variant<tensor<10xf32>>>
func.return %0 : tensor<!tf_type.variant<tensor<10xf32>>>

// CHECK: func @tensorListIfCondTrue(%arg0: tensor<3x10xf32>) -> tensor<3x10xf32>
// CHECK-NOT: tf.TensorListSetItem
}

func.func @tensorListIfCondFalse(%arg0: tensor<!tf_type.variant<tensor<10xf32>>>) -> (tensor<!tf_type.variant<tensor<10xf32>>>) {
%cst = arith.constant dense<0> : tensor<i32>
%cst_0 = arith.constant dense<1.0> : tensor<10xf32>
%0 = "tf.TensorListSetItem"(%arg0, %cst, %cst_0) : (tensor<!tf_type.variant<tensor<10xf32>>>, tensor<i32>, tensor<10xf32>) -> tensor<!tf_type.variant<tensor<10xf32>>>
func.return %0 : tensor<!tf_type.variant<tensor<10xf32>>>

// CHECK: func @tensorListIfCondFalse(%arg0: tensor<3x10xf32>) -> tensor<3x10xf32>
// CHECK-NOT: tf.TensorListSetItem
}
// TODO: Re-enable the tensorlistIf, tensorListIfCondFalse, tensorListIfCondTrue
// after the fix of b/349409532.

//func.func @tensorListIf(%arg0: tensor<3x10xf32>, %arg1: tensor<1xi32>, %arg2: tensor<i32>) -> tensor<3x10xf32> {
// %cst = arith.constant dense<2> : tensor<i32>
// %0 = "tf.TensorListFromTensor"(%arg0, %arg1) : (tensor<3x10xf32>, tensor<1xi32>) -> tensor<!tf_type.variant<tensor<10xf32>>>
// %1 = "tf.Less"(%arg2, %cst) : (tensor<i32>, tensor<i32>) -> tensor<i1>
// %res = "tf.If"(%1, %0) {else_branch = @tensorListIfCondFalse, is_stateless = true, then_branch = @tensorListIfCondTrue} : (tensor<i1>, tensor<!tf_type.variant<tensor<10xf32>>>) -> tensor<!tf_type.variant<tensor<10xf32>>>
// %2 = "tf.TensorListStack"(%res, %arg1) : (tensor<!tf_type.variant<tensor<10xf32>>>, tensor<1xi32>) -> tensor<3x10xf32>
// func.return %2 : tensor<3x10xf32>

// C_HECK: func @tensorListIf
// C_HECK-NEXT: %cst = arith.constant dense<2> : tensor<i32>
// C_HECK-NEXT: %0 = "tf.Less"(%arg2, %cst) : (tensor<i32>, tensor<i32>) -> tensor<i1>
// C_HECK-NEXT: %1 = "tf.If"(%0, %arg0) <{else_branch = @tensorListIfCondFalse, is_stateless = true, then_branch = @tensorListIfCondTrue}> : (tensor<i1>, tensor<3x10xf32>) -> tensor<3x10xf32>
// C_HECK-NEXT: return %1 : tensor<3x10xf32>
// }

//func.func @tensorListIfCondTrue(%arg0: tensor<!tf_type.variant<tensor<10xf32>>>) -> (tensor<!tf_type.variant<tensor<10xf32>>>) {
// %cst = arith.constant dense<0> : tensor<i32>
// %cst_0 = arith.constant dense<0.0> : tensor<10xf32>
// %0 = "tf.TensorListSetItem"(%arg0, %cst, %cst_0) : (tensor<!tf_type.variant<tensor<10xf32>>>, tensor<i32>, tensor<10xf32>) -> tensor<!tf_type.variant<tensor<10xf32>>>
// func.return %0 : tensor<!tf_type.variant<tensor<10xf32>>>

// C_HECK: func @tensorListIfCondTrue(%arg0: tensor<3x10xf32>) -> tensor<3x10xf32>
// C_HECK-NOT: tf.TensorListSetItem
//}

// func.func @tensorListIfCondFalse(%arg0: tensor<!tf_type.variant<tensor<10xf32>>>) -> (tensor<!tf_type.variant<tensor<10xf32>>>) {
// %cst = arith.constant dense<0> : tensor<i32>
// %cst_0 = arith.constant dense<1.0> : tensor<10xf32>
// %0 = "tf.TensorListSetItem"(%arg0, %cst, %cst_0) : (tensor<!tf_type.variant<tensor<10xf32>>>, tensor<i32>, tensor<10xf32>) -> tensor<!tf_type.variant<tensor<10xf32>>>
// func.return %0 : tensor<!tf_type.variant<tensor<10xf32>>>

// C_HECK: func @tensorListIfCondFalse(%arg0: tensor<3x10xf32>) -> tensor<3x10xf32>
// C_HECK-NOT: tf.TensorListSetItem
// }
4 changes: 2 additions & 2 deletions third_party/llvm/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ load("//third_party:repo.bzl", "tf_http_archive")

def repo(name):
"""Imports LLVM."""
LLVM_COMMIT = "4e0a0eae58f7a6998866719f7eb970096a2a52e9"
LLVM_SHA256 = "ee3ed32065549d13c33ac52fd188c78d45364e740c6b54752feeb951ce15f617"
LLVM_COMMIT = "54b61adc0cbefb7f923ef43c407704ba9f9d8b69"
LLVM_SHA256 = "449cf5ec976a6b75cf1ca3d6fef9312c50a42f9428d73822d9e541a8cba20098"

tf_http_archive(
name = name,
Expand Down

0 comments on commit b572b20

Please sign in to comment.