MCPcopy
hub / github.com/OpenPPL/ppq / post_forward_hook

Method post_forward_hook

ppq/quantization/analyse/graphwise.py:24–31  ·  view source on GitHub ↗
(self, outputs: list, **kwargs)

Source from the content-addressed store, hash-verified

22 return super().pre_forward_hook(inputs, **kwargs)
23
24 def post_forward_hook(self, outputs: list, **kwargs) -> list:
25 output_tensor = outputs[0]
26 assert isinstance(output_tensor, torch.Tensor), (
27 'Output of monitoring operation is not a torch.Tensor')
28 self.fetched = batch_random_fetch(
29 output_tensor, seed=10086, fetches_per_batch=self.fetchs
30 ).to('cpu')
31 return super().post_forward_hook(outputs, **kwargs)
32
33 def pop(self) -> torch.Tensor:
34 fetched = self.fetched

Callers 1

post_forward_hookMethod · 0.45

Calls 2

batch_random_fetchFunction · 0.90
toMethod · 0.80

Tested by

no test coverage detected