tensorflow/compiler/mlir/tensorflow/transforms/tpu_sharding_identification_pass.cc
// Returns XLA sharding from TPUPartitionedOutput or TPUPartitionedInput (via
// AssignVariableOp/resource write) op connected to a `tf_device.cluster_func`
// result value.
Returns XLA sharding from TPUPartitionedOutput or TPUPartitionedInput (via
AssignVariableOp/resource write) op connected to a `tf_device.cluster_func`
result value.
Returns XLA sharding from TPUPartitionedOutput or TPUPartitionedInput ( via AssignVariableOp / resource write ) op connected to a ` tf_device . cluster_func ` result value .
llvm::Optional<llvm::StringRef> GetXlaShardingFromResult(Value value) {
  if (!value.hasOneUse()) return llvm::None;
  Operation* user = *value.getUsers().begin();
  if (auto partitioned_output =
          llvm::dyn_cast<TF::TPUPartitionedOutputOp>(user))
    return partitioned_output._XlaSharding();
  if (auto assign_var = llvm::dyn_cast<TF::AssignVariableOp>(user))
    if (auto partitioned_input =
            assign_var.resource().getDefiningOp<TF::TPUPartitionedInputOp>())
      return partitioned_input._XlaSharding();
  return llvm::None;
}
llvm :: Optional < llvm :: StringRef > GetXlaShardingFromResult ( Value value ) { if ( ! value . hasOneUse ( ) ) return llvm :: None ; Operation * user = * value . getUsers ( ) . begin ( ) ; if ( auto partitioned_output = llvm :: dyn_cast < TF :: TPUPartitionedOutputOp > ( user ) ) return partitioned_output . _XlaSharding ( ) ; if ( auto assign_var = llvm :: dyn_cast < TF :: AssignVariableOp > ( user ) ) if ( auto partitioned_input = assign_var . resource ( ) . getDefiningOp < TF :: TPUPartitionedInputOp > ( ) ) return partitioned_input . _XlaSharding ( ) ; return llvm :: None ; }
Returns XLA sharding from TPUPartitionedOutput or TPUPartitionedInput (via
AssignVariableOp/resource write) op connected to a `tf_device.cluster_func`
result value.
Returns XLA sharding from TPUPartitionedOutput or TPUPartitionedInput ( via AssignVariableOp / resource write ) op connected to a ` tf_device . cluster_func ` result value .