Add test to check constant folding for tf.Add op, and no constant folding for side effect ops.
PiperOrigin-RevId: 260555719
This commit is contained in:
parent
7b372c7da2
commit
fc2f969a74
@ -42,3 +42,24 @@ func @tfConst() -> (tensor<4xf32>, tensor<1x1x6x2xf32>) {
|
||||
// CHECK-DAG: constant dense<0.242886767> : tensor<1x1x6x2xf32>
|
||||
return %0, %21 : tensor<4xf32>, tensor<1x1x6x2xf32>
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func @testAdd() -> tensor<2x2xi32>
|
||||
func @testAdd() -> tensor<2x2xi32> {
|
||||
^bb0:
|
||||
%0 = constant dense<[[0, 1], [2, 3]]> : tensor<2x2xi32>
|
||||
%1 = constant dense<1> : tensor<2xi32>
|
||||
%2 = "tf.Add"(%0, %1) {device = "", name = "add"} : (tensor<2x2xi32>, tensor<2xi32>) -> tensor<2x2xi32>
|
||||
// CHECK: [[cst:%.*]] = constant dense<{{\[\[}}1, 2], {{\[}}3, 4]]> : tensor<2x2xi32>
|
||||
// CHECK-NEXT: return [[cst]] : tensor<2x2xi32>
|
||||
return %2: tensor<2x2xi32>
|
||||
}
|
||||
|
||||
// Ops with side effects should not get constant folded.
|
||||
// CHECK-LABEL: func @testSideEffectOp() -> tensor<3xf32>
|
||||
func @testSideEffectOp() -> tensor<3xf32> {
|
||||
%0 = constant dense<[3]> : tensor<1xi32>
|
||||
%1 = "tf.RandomUniform"(%0) {device = "", seed = 3 : i64, seed2 = 5 : i64} : (tensor<1xi32>) -> tensor<3xf32>
|
||||
// CHECK: %[[random:.*]] = "tf.RandomUniform"
|
||||
// CHECK: return %[[random]]
|
||||
return %1: tensor<3xf32>
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user