101{
102 const auto &input_type =
input.getType();
104 (void)input_type;
105
106 assert(input_type.isQuantized());
108 assert(input_type.getElementType() == DataType::UINT8);
109
116 (void)padding_after;
117
118 constexpr int num_spatial_dims = 2;
119 assert(
input.getShape().rank() == 4);
120 assert(window_size.size() == num_spatial_dims);
121 assert(strides.size() == num_spatial_dims);
122 assert(padding_before.size() == num_spatial_dims);
123 assert(padding_after.size() == num_spatial_dims);
124
127
128 ShapeRange in_range(input_shape);
129 Index in_index(input_shape.rank());
130
131 int32_t output_min = std::numeric_limits<uint8_t>::min();
132 int32_t output_max = std::numeric_limits<uint8_t>::max();
133
135 {
138
139
140 in_index.at(0) = out_index.at(0);
141 in_index.at(3) = out_index.at(3);
142
143 for (
const auto &window_index : ShapeRange(
Shape(window_size)))
144 {
145
146 for (int i = 0; i < num_spatial_dims; ++i)
147 in_index.at(1 + i) =
148 out_index.at(1 + i) * strides[i] + window_index.at(i) - padding_before[i];
149
150 if (in_range.contains(in_index))
151 {
153 result += input_accessor.at(in_index);
154 }
156 {
158 }
159 }
161 result = std::max(result, output_min);
162 result = std::min(result, output_max);
163 res_accessor.at(out_index) =
static_cast<uint8_t
>(
result);
164 }
165}
const TensorType & getType() const
Gets the type of this output.
Output * getOutput(std::size_t index)
const Shape & getInputShape(std::size_t index) const
const Shape & getOutputShape(std::size_t index) const
const std::vector< std::int32_t > & getWindowSize() const
const std::vector< std::int32_t > & getPaddingBefore() const
const std::vector< std::int32_t > & getPaddingAfter() const
bool getIncludePad() const
const std::vector< std::int32_t > & getStrides() const
const luci_interpreter::RuntimeShape output_shape
uint32_t num_elements(const Shape &shape)
The number of elements of a feature map of a given shape.