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

Method __init__

deepspeed/inference/quantization/layers.py:49–62  ·  view source on GitHub ↗
(self, config: Dict, pre_quant_layer: nn.Linear)

Source from the content-addressed store, hash-verified

47class QuantizedLinear(nn.Linear):
48
49 def __init__(self, config: Dict, pre_quant_layer: nn.Linear) -> None:
50 super(QuantizedLinear, self).__init__(in_features=pre_quant_layer.in_features,
51 out_features=pre_quant_layer.out_features,
52 bias=pre_quant_layer.bias is not None,
53 device=pre_quant_layer.weight.device,
54 dtype=pre_quant_layer.weight.dtype)
55 self.config = config
56
57 self.quantizer = Quantizer(config=config)
58 self.bias = pre_quant_layer.bias
59 self.weight = get_quantized_weight_wrapper(self, pre_quant_layer.weight,
60 get_quantize_weight_fn(self.quantizer, pre_quant_layer.weight))
61
62 self.weight.dequantizer = DeQuantizer(config, pre_quant_layer.weight.dtype)
63
64 def forward(self, input: Tensor) -> Tensor:
65 quantized_weight, quant_scale, quant_min = self.weight.deconcat(self.weight)

Callers 1

__init__Method · 0.45

Calls 4

get_quantize_weight_fnFunction · 0.85
DeQuantizerClass · 0.85
QuantizerClass · 0.70

Tested by

no test coverage detected