Browse Source

cleancode

pull/636/head
songmingyang 3 years ago
parent
commit
e72533122a
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      parser/common/parser_fp16_t.h

+ 5
- 5
parser/common/parser_fp16_t.h View File

@@ -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


Loading…
Cancel
Save