(self, x: torch.Tensor)
| 1178 | return result |
| 1179 | |
| 1180 | def forward(self, x: torch.Tensor): |
| 1181 | self.state.is_training = self.training |
| 1182 | if self.weight.CB is not None: |
| 1183 | self.init_8bit_state() |
| 1184 | |
| 1185 | # weights are cast automatically as Int8Params, but the bias has to be cast manually |
| 1186 | if self.bias is not None and self.bias.dtype != x.dtype: |
| 1187 | self.bias.data = self.bias.data.to(x.dtype) |
| 1188 | |
| 1189 | out = bnb.matmul(x, self.weight, bias=self.bias, state=self.state) |
| 1190 | |
| 1191 | if not self.state.has_fp16_weights and self.state.CB is not None: |
| 1192 | self.weight.data = self.state.CB |
| 1193 | |
| 1194 | return out |
| 1195 | |
| 1196 | |
| 1197 | class OutlierAwareLinear(nn.Linear): |
nothing calls this directly
no test coverage detected