Загрузка
Dev utility to return node names in order of execution. See note on node
names under create_feature_extractor(). Useful for seeing which node
names are available for feature extraction. There are two reasons that
node names can’t easily be read directly from the code for a model:
Not all submodules are traced through. Modules from
torch.nnall fall within this category.Nodes representing the repeated application of the same operation or leaf module get a
_{counter}postfix.
The model is traced twice: once in train mode, and once in eval mode. Both sets of node names are returned.
For more details on the node naming conventions used here, please see the relevant subheading in the documentation.
model (nn.Module) – model for which we’d like to print node names
tracer_kwargs (dict, optional) – a dictionary of keyword arguments for
NodePathTracer (they are eventually passed onto
torch.fx.Tracer).
By default, it will be set to wrap and make leaf nodes all torchvision ops:
{“autowrap_modules”: (math, torchvision.ops,),”leaf_modules”: _get_leaf_modules_for_ops(),}
WARNING: In case the user provides tracer_kwargs, above default arguments will be appended to the user
provided dictionary.
suppress_diff_warning (bool, optional) – whether to suppress a warning when there are discrepancies between the train and eval version of the graph. Defaults to False.
concrete_args (Optional[Dict[str, any]]) – Concrete arguments that should not be treated as Proxies. According to the Pytorch docs, this parameter’s API may not be guaranteed.
a list of node names from tracing the model in train mode, and another from tracing the model in eval mode.
Examples:
>>> model = torchvision.models.resnet18()
>>> train_nodes, eval_nodes = get_graph_node_names(model)