MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _get_norm

Function _get_norm

tools/low_precision_optimize/calibrate.py:14–29  ·  view source on GitHub ↗

Compute the norm of the values uniformaly distributed between delta_begin and delta_end. norm = density * (integral_{begin, end} x^2) = density * (end^3 - begin^3) / 3

(delta_begin, delta_end, density, norm_type)

Source from the content-addressed store, hash-verified

12 histogram = np.bincount(hist_data)
13
14 def _get_norm(delta_begin, delta_end, density, norm_type):
15 """
16 Compute the norm of the values uniformaly distributed between
17 delta_begin and delta_end.
18
19 norm = density * (integral_{begin, end} x^2)
20 = density * (end^3 - begin^3) / 3
21 """
22 assert norm_type == "L2", "Only L2 norms are currently supported"
23 norm = 0.0
24 if norm_type == "L2":
25 norm = (
26 delta_end * delta_end * delta_end
27 - delta_begin * delta_begin * delta_begin
28 ) / 3
29 return density * norm
30
31 def _compute_quantization_error(next_start_bin, next_end_bin, norm_type):
32 """

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected