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

Function mul

tests/validation/reference/PixelWiseMultiplication.cpp:60–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58 */
59template <typename T1, typename T2, typename T3>
60T3 mul(const T1 src1, const T2 src2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy)
61{
62 using intermediate_type = typename common_promoted_signed_type<T1, T2, T3>::intermediate_type;
63
64 const double val =
65 static_cast<intermediate_type>(src1) * static_cast<intermediate_type>(src2) * static_cast<double>(scale);
66
67 if (is_floating_point<T3>::value)
68 {
69 const auto result = static_cast<T3>(val);
70
71 return result;
72 }
73 else
74 {
75 double rounded_val = 0;
76 switch (rounding_policy)
77 {
78 case (RoundingPolicy::TO_ZERO):
79 rounded_val = support::cpp11::trunc(val);
80 break;
81 case (RoundingPolicy::TO_NEAREST_UP):
82 rounded_val = round_half_up(val);
83 break;
84 case (RoundingPolicy::TO_NEAREST_EVEN):
85 rounded_val = round_half_even(val);
86 break;
87 default:
88 ARM_COMPUTE_ERROR("Unsupported rounding policy");
89 }
90
91 const auto result =
92 static_cast<T3>((convert_policy == ConvertPolicy::SATURATE) ? saturate_cast<T3>(rounded_val) : rounded_val);
93
94 return result;
95 }
96}
97
98template <>
99int32_t

Callers

nothing calls this directly

Calls 7

absFunction · 0.85
lowestFunction · 0.85
frexpFunction · 0.85
floorFunction · 0.85
truncFunction · 0.50
round_half_upFunction · 0.50
round_half_evenFunction · 0.50

Tested by

no test coverage detected