MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / forward

Method forward

bitsandbytes/nn/modules.py:1180–1194  ·  view source on GitHub ↗
(self, x: torch.Tensor)

Source from the content-addressed store, hash-verified

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
1197class OutlierAwareLinear(nn.Linear):

Callers

nothing calls this directly

Calls 2

init_8bit_stateMethod · 0.95
toMethod · 0.45

Tested by

no test coverage detected