19#include "kernels/Utils.h"
21#include <tensorflow/lite/kernels/internal/reference/integer_ops/pooling.h>
22#include <tensorflow/lite/kernels/internal/reference/pooling.h>
40 assert(
input()->shape().num_dims() == 4);
42 const int32_t batches = input_shape.
dim(0);
43 const int32_t input_height = input_shape.
dim(1);
44 const int32_t input_width = input_shape.
dim(2);
45 const int32_t depth = input_shape.
dim(3);
47 const int32_t output_height =
49 const int32_t output_width =
57 output()->
resize({batches, output_height, output_width, depth});
58 if (
input()->element_type() == DataType::U8)
63 else if (
input()->element_type() == DataType::S16)
72 switch (
input()->element_type())
74 case DataType::FLOAT32:
84 throw std::runtime_error(
"luci-intp MaxPool2D Unsupported type.");
88void MaxPool2D::evalFloat()
const
90 float activation_min{};
91 float activation_max{};
94 tflite::PoolParams
params{};
95 params.padding_values.height = _padding_height;
96 params.padding_values.width = _padding_width;
101 params.float_activation_min = activation_min;
102 params.float_activation_max = activation_max;
108void MaxPool2D::evalQuantized()
const
110 int32_t activation_min{};
111 int32_t activation_max{};
114 tflite::PoolParams
params{};
115 params.padding_values.height = _padding_height;
116 params.padding_values.width = _padding_width;
121 params.quantized_activation_min = activation_min;
122 params.quantized_activation_max = activation_max;
128void MaxPool2D::evalSInt16()
const
130 int32_t activation_min{};
131 int32_t activation_max{};
134 tflite::PoolParams
params{};
135 params.padding_values.height = _padding_height;
136 params.padding_values.width = _padding_width;
141 params.quantized_activation_min = activation_min;
142 params.quantized_activation_max = activation_max;
144 tflite::reference_integer_ops::MaxPool(
const Pool2DParams _params
const Pool2DParams & params() const
void resize(const Shape &new_shape)
const Shape & shape() const
const Tensor * input() const
void configure() override
MaxPool2D(const Tensor *input, Tensor *output, const Pool2DParams ¶ms)
void execute() const override
#define LUCI_INTERPRETER_CHECK(cond)
int32_t computePadding(int32_t stride, int32_t dilation_rate, int32_t in_size, int32_t filter_size, int32_t out_size)
tflite::RuntimeShape getTensorShape(const Tensor *tensor)
void calculateActivationRange(Activation activation, T *activation_min, T *activation_max)
void calculateActivationRangeQuantized(Activation activation, const Tensor *output, int32_t *activation_min, int32_t *activation_max)
int32_t computeOutputSize(Padding padding, int32_t image_size, int32_t filter_size, int32_t stride, int32_t dilation_rate=1)