MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / forward

Method forward

quantization/qlinear.py:63–78  ·  view source on GitHub ↗
(self, x: torch.Tensor)

Source from the content-addressed store, hash-verified

61 self.compute_dtype = compute_dtype
62
63 def forward(self, x: torch.Tensor):
64 if self.bias is not None and self.bias.dtype != x.dtype:
65 self.bias.data = self.bias.data.to(x.dtype)
66
67 inp_dtype = x.dtype
68
69 if self.compute_dtype is not None:
70 x = x.to(self.compute_dtype)
71
72 bias = None if self.bias is None else self.bias.to(self.compute_dtype)
73 out = None
74
75 quantize_weight = self.weight_quantizer(self.weight.to(self.compute_dtype))
76 out = F.linear(x, quantize_weight, bias).to(inp_dtype)
77
78 return out

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected