MCPcopy Create free account
hub / github.com/Derious/cuMPC / compute_direct

Method compute_direct

test/test_CORE/test_exp.cpp:92–102  ·  view source on GitHub ↗

使用直接计算的量化指数

Source from the content-addressed store, hash-verified

90
91 // 使用直接计算的量化指数
92 static uint8_t compute_direct(float x) {
93 // 输入截断
94 x = std::min(std::max(x, kXMin), kXMax);
95
96 // 计算量化值
97 float exp_val = std::exp(x);
98 int quant_val = std::round(exp_val / kScale + kZeroPoint);
99
100 // 确保输出在[0, 255]范围内
101 return static_cast<uint8_t>(std::min(std::max(quant_val, 0), 255));
102 }
103};
104
105int main() {

Callers

nothing calls this directly

Calls 2

expFunction · 0.50
roundFunction · 0.50

Tested by

no test coverage detected