| 58 | */ |
| 59 | template <typename T1, typename T2, typename T3> |
| 60 | T3 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 | |
| 98 | template <> |
| 99 | int32_t |
nothing calls this directly
no test coverage detected