2022-07-12 07:01:58 +00:00
|
|
|
import torch
|
2022-11-01 14:53:51 +00:00
|
|
|
|
|
|
|
from ...registry import meta_patched_module
|
2022-07-12 07:01:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
@meta_patched_module.register(torch.nn.Linear)
|
|
|
|
def torch_nn_linear(self, input):
|
|
|
|
last_dim = input.shape[-1]
|
|
|
|
assert last_dim == self.in_features, f'Expected hidden size {self.in_features} but got {last_dim} for the torch.nn.Linear patch'
|
2022-07-27 03:03:14 +00:00
|
|
|
return torch.empty(input.shape[:-1] + (self.out_features,), device="meta")
|