MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / Catcher

Class Catcher

quantization/autoclip.py:132–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130 # with_kwargs is only supported in PyTorch 2.0
131 # use this Catcher hack for now
132 class Catcher(nn.Module):
133 def __init__(self, module):
134 super().__init__()
135 self.module = module
136
137 def forward(self, inp, **kwargs):
138 inps.append(inp)
139 layer_kwargs.update(kwargs)
140 raise ValueError # early exit to break later inference
141
142 # patch layer 0 to catch input and kwargs
143 layers[0] = Catcher(layers[0])

Callers 1

run_clipFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected