MCPcopy Create free account
hub / github.com/pytorch/pytorch / _insert_dequant_stub

Function _insert_dequant_stub

torch/ao/quantization/fx/utils.py:502–519  ·  view source on GitHub ↗

Attach a `DeQuantStub` to the model and create a node that calls this `DeQuantStub` on the output of `node`, similar to how observers are inserted.

(
    node: Node,
    model: torch.nn.Module,
    named_modules: Dict[str, torch.nn.Module],
    graph: Graph,
)

Source from the content-addressed store, hash-verified

500 return None
501
502def _insert_dequant_stub(
503 node: Node,
504 model: torch.nn.Module,
505 named_modules: Dict[str, torch.nn.Module],
506 graph: Graph,
507) -> Node:
508 """
509 Attach a `DeQuantStub` to the model and create a node that calls this
510 `DeQuantStub` on the output of `node`, similar to how observers are inserted.
511 """
512 prefix = "dequant_stub_"
513 get_new_dequant_stub_name = get_new_attr_name_with_prefix(prefix)
514 dequant_stub_name = get_new_dequant_stub_name(model)
515 dequant_stub = DeQuantStub()
516 setattr(model, dequant_stub_name, dequant_stub)
517 named_modules[dequant_stub_name] = dequant_stub
518 with graph.inserting_after(node):
519 return graph.call_module(dequant_stub_name, (node,))
520
521def _insert_dequant_stubs_for_custom_module_lstm_output(
522 node: Node,

Calls 4

DeQuantStubClass · 0.90
inserting_afterMethod · 0.45
call_moduleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…