mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-26 20:23:26 +00:00
[fx] refactored the file structure of patched function and module (#1238)
* [fx] refactored the file structure of patched function and module * polish code
This commit is contained in:
9
colossalai/fx/tracer/meta_patch/patched_module/linear.py
Normal file
9
colossalai/fx/tracer/meta_patch/patched_module/linear.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import torch
|
||||
from ..registry import meta_patched_module
|
||||
|
||||
|
||||
@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'
|
||||
return torch.empty(input.shape[:-1] + (self.out_features,), device="meta")
|
Reference in New Issue
Block a user