Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: fx.Node docs incorrectly state that the self argument is includ…
…ed in args for module calls (pytorch#86685) It seems like the [torch.fx.Node docs](https://pytorch.org/docs/stable/fx.html#torch.fx.Node) are incorrect regarding the inclusion of the self argument for module call nodes. While the docs state that self (the module) is included in `args`, it is in fact not, as demonstrated by this code: ```python import torch from torch import fx, nn class Net(nn.Module): def __init__(self): super().__init__() self.submod = nn.Linear(10, 10) def forward(self, x): x = x.flatten() return self.submod(x) graph_module = fx.symbolic_trace(Net()) print(graph_module.graph) # doesn't show self for the submodule call submod_node = list(graph_module.graph.nodes)[2] print(submod_node.op) # call_module print(submod_node.args) # (flatten,) => would need to have len 2 if self was included flatten_node = list(graph_module.graph.nodes)[1] print(flatten_node.op) # call_method print(flatten_node.args) # (x,) => here self is included (and docs are correct) ``` Since [torch.fx.Interpreter also uses `args` as if self was is not included](https://github.com/pytorch/pytorch/blob/2fe580859012d2d24a54e452195ccbc7f3191036/torch/fx/interpreter.py#L288), I assume the docs are incorrect. Pull Request resolved: pytorch#86685 Approved by: https://github.com/soulitzer
- Loading branch information