19 if (multiplier == 0.0f)
26 const double q = std::frexp(multiplier, &m_RightShift);
27 m_RightShift = -m_RightShift;
28 int64_t qFixed =
static_cast<int64_t
>(std::round(q * (1ll << 16)));
30 if (qFixed == (1ll << 16))
36 ARMNN_ASSERT(qFixed <= std::numeric_limits<int32_t>::max());
37 m_Multiplier =
static_cast<int32_t
>(qFixed);
41 #define SATURATE_VAL_S_32S(WIDTH, VAL) \ 42 (static_cast<int32_t>(VAL > ((static_cast<int64_t>(1) << (WIDTH - 1)) - 1) \ 43 ? ((static_cast<int64_t>(1) << (WIDTH - 1)) - 1) \ 44 : VAL < (-1 * (static_cast<int64_t>(1) << (WIDTH - 1))) \ 45 ? (-1 * (static_cast<int64_t>(1) << (WIDTH - 1))) \ 53 int64_t b_64(m_Multiplier);
54 int64_t ab_64 = a_64 * b_64;
57 int32_t roundBit = (ab_64 >> m_RightShift) & 0x1;
58 int64_t resultShifted = (ab_64 >> (m_RightShift + 1)) + roundBit;
68 int64_t b_64(m_Multiplier);
69 int64_t ab_64 = a_64 * b_64;
72 int32_t roundBit = (ab_64 >> m_RightShift) & 0x1;
73 int64_t resultShifted = (ab_64 >> (m_RightShift + 1)) + roundBit;
int32_t operator*(int32_t rhs) const
The implementation of this function is adapted from Android NN's MultiplyByEthosnRefQuantizedMultipli...
#define SATURATE_VAL_S_32S(WIDTH, VAL)
Copyright (c) 2021 ARM Limited and Contributors.
#define ARMNN_ASSERT(COND)
EthosnRefQuantizedMultiplierSmallerThanOne(float multiplier)
Constructs a EthosnRefQuantizedMultiplierSmallerThanOne which will multiply by the given multiplier...