diff --git a/tensorflow/compiler/mlir/g3doc/includes/tf_passes.md b/tensorflow/compiler/mlir/g3doc/includes/tf_passes.md index a9485a1a7d9..79a3fc4f859 100644 --- a/tensorflow/compiler/mlir/g3doc/includes/tf_passes.md +++ b/tensorflow/compiler/mlir/g3doc/includes/tf_passes.md @@ -1,4 +1,44 @@ +### `-cluster-ops-by-policy`: Clusters ops according to specified policy. +This pass clusters ops according to the policy specified by the pass options. +Clustered ops are moved to a tf_device::clusterOp region. + +The only currently supported option is 'oplist='. This option +specifies the names of the ops that should be clustered if they form +a single use def-use chain, that is, the next op in the list uses the result +of the previous op and is the only user of that result. The ops should +be located in the same block, be assigned to the same device and have no +side effects. + +For example, running this pass with option oplist="tf.Cast, tf.Add" on: + +```mlir +func @cluster_oplist(%arg0 : tensor, %arg1 : tensor) -> tensor { + %0 = "tf.Cast"(%arg0) : (tensor) -> tensor + %1 = "SomeOp" (%arg1) : (tensor) -> tensor + %2 = "tf.Add"(%0, %1) : (tensor, tensor) -> tensor + return %2 : tensor +} +``` + +will produce tf_device::opCluster enclosing tf.Add and tf.Neg: + +```mlir +func @cluster_oplist(%arg0: tensor, %arg1: tensor) -> tensor { + %0 = "SomeOp"(%arg1) : (tensor) -> tensor + %1 = "tf_device.cluster"() ( { + %2 = "tf.Cast"(%arg0) : (tensor) -> tensor + %3 = "tf.Add"(%2, %0) : (tensor, tensor) -> tensor + tf_device.return %3 : tensor + }) : () -> tensor + return %1 : tensor +} +``` + +#### Options +``` +-oplist : Cluster listed ops when they form a single use def-use chain, such that each op's single user is the next op in the list. +``` ### `-tf-device-cluster-outlining`: Outlines regions of tf_device.cluster operations This pass outlines the body of a `tf_device.cluster` into a function and replaces the `tf_device.cluster` op with an equivalent `tf_device.cluster_func`