MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / accumulate_squared

Function accumulate_squared

tests/validation/reference/Accumulate.cpp:83–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81
82template <typename T1, typename T2>
83SimpleTensor<T2> accumulate_squared(const SimpleTensor<T1> &src, uint32_t shift, DataType output_data_type)
84{
85 ARM_COMPUTE_ERROR_ON_MSG(shift > 15, "Shift in accumulate_squared must be within the range [0, 15]");
86
87 SimpleTensor<T2> dst{src.shape(), output_data_type};
88
89 library->fill_tensor_uniform(dst, 1, static_cast<T2>(0), static_cast<T2>(std::numeric_limits<T1>::max()));
90
91 using intermediate_type = typename common_promoted_signed_type<T1, T2>::intermediate_type;
92 intermediate_type denom = 1 << shift;
93#if defined(_OPENMP)
94#pragma omp parallel for
95#endif /* _OPENMP */
96 for (int i = 0; i < src.num_elements(); ++i)
97 {
98 intermediate_type val =
99 static_cast<intermediate_type>(dst[i]) +
100 (static_cast<intermediate_type>(src[i]) * static_cast<intermediate_type>(src[i]) / denom);
101 dst[i] = saturate_cast<T2>(val);
102 }
103
104 return dst;
105}
106
107template SimpleTensor<int16_t> accumulate(const SimpleTensor<uint8_t> &src, DataType output_data_type);
108template SimpleTensor<uint8_t>

Callers

nothing calls this directly

Calls 3

fill_tensor_uniformMethod · 0.80
shapeMethod · 0.45
num_elementsMethod · 0.45

Tested by

no test coverage detected