MCPcopy Create free account
hub / github.com/FreedomIntelligence/LLMZoo / compress_module

Function compress_module

llmzoo/deploy/webapp/compression.py:39–49  ·  view source on GitHub ↗
(module, target_device)

Source from the content-addressed store, hash-verified

37
38
39def compress_module(module, target_device):
40 for attr_str in dir(module):
41 target_attr = getattr(module, attr_str)
42 if type(target_attr) == torch.nn.Linear:
43 setattr(
44 module,
45 attr_str,
46 CLinear(target_attr.weight, target_attr.bias, target_device),
47 )
48 for name, child in module.named_children():
49 compress_module(child, target_device)
50
51
52def compress(tensor, config):

Callers 1

load_modelFunction · 0.90

Calls 1

CLinearClass · 0.85

Tested by

no test coverage detected