282 {
283
285 for (
int idx = 0; idx <
output_shape.DimensionsCount(); ++idx)
286 {
287 size_t current =
static_cast<size_t>(
output_shape.Dims(idx));
288
289 if (num_outputs > std::numeric_limits<size_t>::max() / current)
290 {
291 return false;
292 }
294 }
296 {
298 temp_sum[idx] = U();
299 }
300
301
302 int num_resolved_axis = 0;
304 {
305 return false;
306 }
307
310 {
311 return false;
312 }
313
314
315 size_t num_elements_in_axis = 1;
316 for (int idx = 0; idx < num_resolved_axis; ++idx)
317 {
319
320 if (current > static_cast<size_t>(std::numeric_limits<size_t>::max() / num_elements_in_axis))
321 {
322 return false;
323 }
324 num_elements_in_axis *= current;
325 }
326
327 if (num_elements_in_axis > 0)
328 {
329 const float scale = input_scale / output_scale;
330 if (compute_sum)
331 {
332
333 const float bias = -input_zero_point *
scale * num_elements_in_axis;
335 {
336 const U value =
337 static_cast<U>(std::round(temp_sum[idx] * scale + bias)) + output_zero_point;
339 }
340 }
341 else
342 {
343 const float bias = -input_zero_point *
scale;
345 {
346 float float_mean =
347 static_cast<float>(temp_sum[idx]) / static_cast<float>(num_elements_in_axis);
348 float result = std::min(std::round(float_mean * scale + bias) + output_zero_point,
349 static_cast<float>(std::numeric_limits<T>::max()));
350 result = std::max(result,
static_cast<float>(std::numeric_limits<T>::min()));
352 }
353 }
354 }
355 return true;
356 }
int32_t * resolved_axis_data(void)
int32_t * temp_index_data(void)
const luci_interpreter::RuntimeShape output_shape
bool ResolveAxis(const int num_dims, const std::vector< int > &axes, int *out_axis, int *out_num_axis)