-
Notifications
You must be signed in to change notification settings - Fork 74.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of xla_broadcast pass
PiperOrigin-RevId: 610098561
- Loading branch information
1 parent
7fbe494
commit 371de46
Showing
2 changed files
with
244 additions
and
1 deletion.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
tensorflow/compiler/mlir/tensorflow/tests/xla_broadcast.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// RUN: tf-opt %s -split-input-file -tf-xla-broadcast | FileCheck %s | ||
|
||
// CHECK-LABEL: func @move_broadcast | ||
func.func @move_broadcast(%arg0: tensor<f32>) -> () { | ||
// CHECK: %[[ELEM:.*]] = "tf.Const"() <{value = dense<0.000000e+00> : tensor<f32>}> : () -> tensor<f32> | ||
// CHECK-NEXT: %[[SHAPE:.*]] = "tf.Const"() <{value = dense<> : tensor<0xi64>}> : () -> tensor<0xi64> | ||
// CHECK-NEXT: %[[FULL:.*]] = "tf.Fill"(%[[SHAPE]], %[[ELEM]]) : (tensor<0xi64>, tensor<f32>) -> tensor<f32> | ||
// CHECK-NEXT: tf_device.replicate([%arg0, %[[FULL]]] as %[[REPVAR:.*]]: tensor<f32>) {n = 2 : i32} { | ||
// CHECK-NEXT: %[[ID:.*]] = "tf_device.launch"() <{device = "TPU_REPLICATED_HOST_0"}> ({ | ||
// CHECK-NEXT: %[[IDINSIDE:.*]] = "tf.Identity"(%[[REPVAR]]) : (tensor<f32>) -> tensor<f32> | ||
// CHECK-NEXT: tf_device.return %[[IDINSIDE]] : tensor<f32> | ||
// CHECK-NEXT: }) : () -> tensor<f32> | ||
// CHECK-NEXT: "tf_device.cluster"() ({ | ||
// CHECK-NEXT: %[[GROUP:.*]] = "tf.Const"() | ||
// CHECK-SAME: [0, 1] | ||
// CHECK-NEXT: %[[REDUCED:.*]] = "tf.XlaAllReduce"(%[[ID]], %[[GROUP]]) <{mode = "CrossReplica", reduce_op = "Add"}> : (tensor<f32>, tensor<1x2xi32>) -> tensor<f32> | ||
// CHECK-NEXT: "tf.OpA"(%[[REDUCED]]) : (tensor<f32>) -> () | ||
tf_device.replicate {n = 2 : i32} { | ||
"tf_device.cluster"() ({ | ||
"tf.OpA"(%arg0) : (tensor<f32>) -> () | ||
tf_device.return | ||
}) : () -> () | ||
} | ||
func.return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters