“It [ScriptModule] is an analogue of torch’s nn.Module and represents an entire model as a tree of submodules.”
How does a ScriptModule object get serialized using the ScriptModule.save() method? Is it still an NN graph but with special conditional nodes? Or is it more of a code AST and the graph-level abstraction is lost?
Based on the following question on the PyTorch discussion forum, tracing seems to just export to ONNX format:
I dont think they’re that different. Sure, the code AST means you have some constants, some scalars, some booleans, but for the large part you have Tensor computations. For example:
if dilation > 0:
aten::dilated_convolution(...)
else:
aten::convolution(...)
Currently torchscript has fundamental types of Tensors, tuples, lists, scalars, constants, None, and constant strings.
So you can theoretically make a python program out of it that doesn’t do neural network workloads, but for the large part you prob. will have a graph of Tensor operations.