Sorry I didn’t make it clear.
What I want ask is when backtracing the computational graph by starting at the network output.grad_fn, how can I know the backward function is corresponding to which layer module?
For instance,
layer1 = nn.Conv2d(param1)
layer2 = nn.Conv2d(param2)
net = nn.Sequential([layer1, layer2])

output = net(input)

layer_grad_fn = output.grad_fn.next_functions[0][0]

layer_grad_fn is the type of ThnnConv2DBackward. How can I know that layer_grad_fn is corresponding to which layer, layer1 or layer2? Which attribute binds them together?
In this example layer_grad_fn  maybe corresponding to layer2, because backward functions connected in reverse order and the network is simple. But it’s hard to count by hand in large networks.