18#ifndef ONERT_MICRO_EXECUTE_PAL_MAX_POOL_2D_H
19#define ONERT_MICRO_EXECUTE_PAL_MAX_POOL_2D_H
21#include "PALMaxPool2DCommon.h"
30OMStatus MaxPool(
const core::Pool2DParams ¶ms,
const core::OMRuntimeShape &input_shape,
31 const int8_t *input_data,
const core::OMRuntimeShape &
output_shape,
34 assert(input_shape.dimensionsCount() == 4);
38 const int input_height = input_shape.dims(1);
39 const int input_width = input_shape.dims(2);
42 const int stride_height = params.stride_h;
43 const int stride_width = params.stride_w;
44 const int pad_w = params.pad_w;
45 const int pad_h = params.pad_h;
46 const int filter_h = params.filter_h;
47 const int filter_w = params.filter_w;
48 for (
int batch = 0; batch < batches; ++batch)
50 for (
int out_y = 0; out_y < output_height; ++out_y)
52 for (
int out_x = 0; out_x < output_width; ++out_x)
54 for (
int channel = 0; channel < depth; ++channel)
56 const int in_x_origin = (out_x * stride_width) - pad_w;
57 const int in_y_origin = (out_y * stride_height) - pad_h;
60 const int filter_x_start = std::max(0, -in_x_origin);
61 const int filter_x_end = std::min(filter_w, input_width - in_x_origin);
62 const int filter_y_start = std::max(0, -in_y_origin);
63 const int filter_y_end = std::min(filter_h, input_height - in_y_origin);
64 int8_t max = std::numeric_limits<int8_t>::lowest();
65 for (
int filter_y = filter_y_start; filter_y < filter_y_end; ++filter_y)
67 for (
int filter_x = filter_x_start; filter_x < filter_x_end; ++filter_x)
69 const int in_x = in_x_origin + filter_x;
70 const int in_y = in_y_origin + filter_y;
72 max, input_data[
offset(input_shape.dimsData(), batch, in_y, in_x, channel)]);
75 max = std::max<int8_t>(max, params.quantized_activation_min);
76 max = std::min<int8_t>(max, params.quantized_activation_max);
78 static_cast<int8_t
>(max);
int32_t dimensionsCount() const
int32_t dims(int i) const
const luci_interpreter::RuntimeShape output_shape
int MatchingDim(const core::OMRuntimeShape &shape1, int index1, const core::OMRuntimeShape &shape2, int index2)
OMStatus MaxPool(const core::Pool2DParams ¶ms, const core::OMRuntimeShape &input_shape, const int8_t *input_data, const core::OMRuntimeShape &output_shape, int8_t *output_data)
int offset(const int32_t *dims_data, int i0, int i1, int i2, int i3)