32 const int batches = input_shape.
dims(0);
34 const int input_height = input_shape.
dims(1);
35 const int input_width = input_shape.
dims(2);
40 for (
int batch = 0; batch < batches; ++batch)
42 for (
int out_y = 0; out_y < output_height; ++out_y)
44 for (
int out_x = 0; out_x < output_width; ++out_x)
46 for (
int channel = 0; channel < depth; ++channel)
52 const int filter_x_start = std::max(0, -in_x_origin);
53 const int filter_x_end = std::min(params.
filter_width, input_width - in_x_origin);
54 const int filter_y_start = std::max(0, -in_y_origin);
55 const int filter_y_end = std::min(params.
filter_height, input_height - in_y_origin);
58 float filter_count = 0;
60 for (
int filter_y = filter_y_start; filter_y < filter_y_end; ++filter_y)
62 for (
int filter_x = filter_x_start; filter_x < filter_x_end; ++filter_x)
64 const int in_x = in_x_origin + filter_x;
65 const int in_y = in_y_origin + filter_y;
67 const int input_data_offset =
68 ((batch * input_shape.
dims(1) + in_y) * input_shape.
dims(2) + in_x) *
72 total += input_data[input_data_offset];
76 const int output_data_offset =
81 assert(filter_count != 0);
82 const float average = total / filter_count;
84 output_data[output_data_offset] =