tensorflow/compiler/mlir/tensorflow/transforms/tpu_space_to_depth_pass.cc
// Creates slice op for filter in back prop pass.
Creates slice op for filter in back prop pass.
Creates slice op for filter in back prop pass .
TF::SliceOp GetSliceOpForConv2DBackPropFilter(
    ArrayRef<int32_t> old_filter_shape, Value input, OpBuilder* builder) {
  SmallVector<int64_t, 4> slice_size(old_filter_shape.begin(),
                                     old_filter_shape.end());
  auto slice_result_type =
      RankedTensorType::get(slice_size, getElementTypeOrSelf(input));
  auto slice_size_op = builder->create<TF::ConstOp>(
      input.getLoc(),
      DenseIntElementsAttr::get(
          RankedTensorType::get({4}, builder->getIntegerType(32)),
          old_filter_shape));
  SmallVector<int64_t, 4> slice_start_position = {0, 0, 0, 0};
  auto start_position_type =
      RankedTensorType::get({4}, builder->getIntegerType(64));
  auto start_position = builder->create<TF::ConstOp>(
      input.getLoc(),
      DenseIntElementsAttr::get(start_position_type, slice_start_position));
  return builder->create<TF::SliceOp>(input.getLoc(), slice_result_type, input,
                                      start_position, slice_size_op);
}
TF :: SliceOp GetSliceOpForConv2DBackPropFilter ( ArrayRef < int32_t > old_filter_shape , Value input , OpBuilder * builder ) { SmallVector < int64_t , 4 > slice_size ( old_filter_shape . begin ( ) , old_filter_shape . end ( ) ) ; auto slice_result_type = RankedTensorType :: get ( slice_size , getElementTypeOrSelf ( input ) ) ; auto slice_size_op = builder -> create < TF :: ConstOp > ( input . getLoc ( ) , DenseIntElementsAttr :: get ( RankedTensorType :: get ( { 4 } , builder -> getIntegerType ( 32 ) ) , old_filter_shape ) ) ; SmallVector < int64_t , 4 > slice_start_position = { 0 , 0 , 0 , 0 } ; auto start_position_type = RankedTensorType :: get ( { 4 } , builder -> getIntegerType ( 64 ) ) ; auto start_position = builder -> create < TF :: ConstOp > ( input . getLoc ( ) , DenseIntElementsAttr :: get ( start_position_type , slice_start_position ) ) ; return builder -> create < TF :: SliceOp > ( input . getLoc ( ) , slice_result_type , input , start_position , slice_size_op ) ; }
Creates slice op for filter in back prop pass.
Creates slice op for filter in back prop pass .