tensorflow/compiler/mlir/tensorflow/transforms/tpu_space_to_depth_pass.cc
// Performs transformation for replicated inputs. Returns true if this is a
// supported case (thus transform happened).
Performs transformation for replicated inputs. Returns true if this is a
supported case (thus transform happened).
Performs transformation for replicated inputs . Returns true if this is a supported case ( thus transform happened ) .
bool HandleHostReplicatedInputs(int64_t index,
                                tf_device::ClusterFuncOp cluster_func,
                                BlockArgument block_arg,
                                tf_device::ReplicateOp replicate,
                                int32_t block_size) {
  if (!replicate.devices()) return false;
  MutableArrayRef<OpOperand> inputs =
      replicate.GetOperandsForBlockArgument(block_arg);
  for (auto& input : inputs) {
    auto input_op = input.get().getDefiningOp();
    if (!input_op || !IsSupportedHostInputOp(input_op)) return false;
  }
  for (auto entry : llvm::enumerate(inputs)) {
    Value input = entry.value().get();
    auto ranked_type = input.getType().dyn_cast<RankedTensorType>();
    if (!ranked_type) return false;
    auto input_shape = ranked_type.getShape();
    auto space_to_depth =
        BuildSpaceToDepth(cluster_func, input, block_size, input_shape);
    entry.value().set(space_to_depth);
    block_arg.setType(space_to_depth.getType());
  }
  return true;
}
bool HandleHostReplicatedInputs ( int64_t index , tf_device :: ClusterFuncOp cluster_func , BlockArgument block_arg , tf_device :: ReplicateOp replicate , int32_t block_size ) { if ( ! replicate . devices ( ) ) return false ; MutableArrayRef < OpOperand > inputs = replicate . GetOperandsForBlockArgument ( block_arg ) ; for ( auto & input : inputs ) { auto input_op = input . get ( ) . getDefiningOp ( ) ; if ( ! input_op || ! IsSupportedHostInputOp ( input_op ) ) return false ; } for ( auto entry : llvm :: enumerate ( inputs ) ) { Value input = entry . value ( ) . get ( ) ; auto ranked_type = input . getType ( ) . dyn_cast < RankedTensorType > ( ) ; if ( ! ranked_type ) return false ; auto input_shape = ranked_type . getShape ( ) ; auto space_to_depth = BuildSpaceToDepth ( cluster_func , input , block_size , input_shape ) ; entry . value ( ) . set ( space_to_depth ) ; block_arg . setType ( space_to_depth . getType ( ) ) ; } return true ; }
Performs transformation for replicated inputs.
Performs transformation for replicated inputs .
// We need to know the devices to copy to.