It depends on your code, the TorchScript compiler always makes the same type of graph, and there are various limitations on what can be exported to ONNX. Looking at the link you posted, TorchScript currently doesn’t support custom autograd Functions, but this is something we are working on supporting.