From e72533122a48f27a72c80a525f0ef4a501e4f41d Mon Sep 17 00:00:00 2001 From: songmingyang Date: Tue, 30 Aug 2022 17:48:30 +0800 Subject: [PATCH] cleancode --- parser/common/parser_fp16_t.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/parser/common/parser_fp16_t.h b/parser/common/parser_fp16_t.h index e8722f9..2f970b9 100644 --- a/parser/common/parser_fp16_t.h +++ b/parser/common/parser_fp16_t.h @@ -93,8 +93,8 @@ using BitShift = enum { /// @brief fp16 exponent bias constexpr uint16_t kFp16ExpBias = 15U; /// @ingroup fp16 basic parameter -/// @brief the exponent bit length of fp16 is 5 -constexpr uint16_t kFp16ExpLen = 5U; +/// @brief the exponent bit length of fp16 is 10 +constexpr uint16_t kFp16ExpLen = 10U; /// @ingroup fp16 basic parameter /// @brief the mantissa bit length of fp16 is 10 constexpr uint16_t kFp16ManLen = 10U; @@ -134,17 +134,17 @@ constexpr uint16_t kFp16MaxMan = 0x03FF; /// @ingroup fp16 basic operator /// @brief get sign of fp16 inline uint16_t Fp16ExtracSign(const uint16_t x) { - return (((x) >> 15) & 1); + return (((x) >> kFp16SignIndex) & 1); } /// @ingroup fp16 basic operator /// @brief get exponent of fp16 inline uint16_t Fp16ExtracExp(const uint16_t x) { - return (((x) >> 10) & kFp16MaxExp); + return (((x) >> kFp16ExpLen) & kFp16MaxExp); } /// @ingroup fp16 basic operator /// @brief get mantissa of fp16 inline uint16_t Fp16ExtracMan(const uint16_t x) { - return ((((x) >> 0) & 0x3FF) | (((((x) >> 10) & 0x1F) > 0 ? 1 : 0) * 0x400)); + return ((((x) >> 0) & 0x3FF) | (((((x) >> kFp16ManLen) & 0x1F) > 0 ? 1 : 0) * 0x400)); } /// @ingroup fp16 basic operator /// @brief constructor of fp16 from sign exponent and mantissa