google / google/gemmlowp

what is "ab_x2_high32" in <func::SaturatingRoundingDoublingHighMul> stand for?

Open
#191 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.8k
Forks
461
PR merge metrics
No merged PRs in 30d

Description

Hi,
In
```
inline std::int32_t SaturatingRoundingDoublingHighMul(std::int32_t a,
std::int32_t b) {
bool overflow = a == b && a == std::numeric_limits::min();
std::int64_t a_64(a);
std::int64_t b_64(b);
std::int64_t ab_64 = a_64 * b_64;
std::int32_t nudge = ab_64 >= 0 ? (1 << 30) : (1 - (1 << 30));
std::int32_t ab_x2_high32 =
static_cast((ab_64 + nudge) / (1ll << 31));
return overflow ? std::numeric_limits::max() : ab_x2_high32;
}
```

it seemed this function is computing a * b
i wondered what is the relationship between _ab_x2_high32_ and _ab_64_. Could you explain how is _ab_x2_high32_ computed?

Thank you!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.