MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / quantize_binary

Method quantize_binary

deepspeed/runtime/quantize.py:115–121  ·  view source on GitHub ↗
(self, inputs)

Source from the content-addressed store, hash-verified

113 return output
114
115 def quantize_binary(self, inputs):
116 input_flat = inputs.reshape(self.q_groups, -1)
117 n = input_flat.shape[1]
118 m = input_flat.norm(p=1, dim=1, keepdim=True).div(n)
119 output = input_flat.sign().mul(m)
120 output = output.reshape(inputs.shape).contiguous()
121 return output
122
123 def mixed_fp16_quantize(self, input, input_q, index):
124 if self.q_mixed_fp16 and self.q_start_bits[index] >= (self.q_target_bits - 1):

Callers 1

compute_quantizationMethod · 0.95

Calls 2

contiguousMethod · 0.80
reshapeMethod · 0.45

Tested by

no test coverage detected