It is possible to iterate torch._C.graph?

Hi folks,

I’m following this Official PyTorch ONNX tutorial and I would like to iterate through the torch._C.graph that generated so I can obtain the “layer indexes” from the trace (i.e. for the AlexNet tutorial, it is %17, %18 and so on).

Is that possible? The reason why I want the indexes because I want to do a one-to-one layer comparison between PyTorch and Core ML layers generated by my model. Thanks!


I think I figured it out. For those who interested in getting the “layer indexes”, or to be specific, the “output indexes”, check out this file

1 Like