32 const T *input_data, [[maybe_unused]]
const Shape &unextended_block_shape_shape,
33 const int32_t *block_shape_data,
34 [[maybe_unused]]
const Shape &unextended_padding_shape,
const int32_t *paddings_data,
35 const Shape &unextended_output_shape, T *output_data)
39 const Shape input_shape = Shape::ExtendedShape(4, unextended_input_shape);
42 const int depth = input_shape.
Dims(3);
43 const int input_width = input_shape.
Dims(2);
44 const int input_height = input_shape.
Dims(1);
45 const int input_batch_size = input_shape.
Dims(0);
51 const int block_shape_height = block_shape_data[0];
52 const int block_shape_width = block_shape_data[1];
53 const int padding_top = paddings_data[0];
54 const int padding_left = paddings_data[2];
59 for (
int out_b = 0; out_b < output_batch_size; ++out_b)
61 int input_batch = out_b % input_batch_size;
62 int shift_w = (out_b / input_batch_size) % block_shape_width;
63 int shift_h = (out_b / input_batch_size) / block_shape_width;
64 for (
int out_h = 0; out_h < output_height; ++out_h)
66 for (
int out_w = 0; out_w < output_width; ++out_w)
69 if (out_h * block_shape_height + shift_h < padding_top ||
70 out_h * block_shape_height + shift_h >= padding_top + input_height ||
71 out_w * block_shape_width + shift_w < padding_left ||
72 out_w * block_shape_width + shift_w >= padding_left + input_width)
75 memset(out, pad_value, depth *
sizeof(T));
80 input_data +
Offset(input_shape, input_batch,
81 (out_h * block_shape_height + shift_h) - padding_top,
82 (out_w * block_shape_width + shift_w) - padding_left, 0);
83 memcpy(out, in, depth *
sizeof(T));
void SpaceToBatchND(const SpaceToBatchParams ¶ms, const Shape &unextended_input_shape, const T *input_data, const Shape &unextended_block_shape_shape, const int32_t *block_shape_data, const Shape &unextended_padding_shape, const int32_t *paddings_data, const Shape &unextended_output_shape, T *output_data)