MCPcopy Create free account
hub / github.com/Xilinx/CHaiDNN / Trim2FP_Offline

Function Trim2FP_Offline

software/interface/xi_readwrite_util.cpp:55–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53};
54
55void Trim2FP_Offline(float *data, const int bw, float threshold)
56{
57 //# Compute scale factor
58 float scaling_factor = threshold / (pow(2, bw-1) - 1);
59
60 //# Clip the data b/w (-threshold, threshold)
61 data[0] = std::max(std::min(data[0], threshold), -threshold);
62
63 if(threshold != 0)
64 {
65 data[0] /= scaling_factor;
66 data[0] = round(data[0]);
67 }
68}
69
70void Trim2FixedPoint(float &data, const int bw, const int fl, int round_floor_flag)
71{

Callers 1

Calls 2

maxFunction · 0.50
minFunction · 0.50

Tested by

no test coverage detected