1- torch.toffee
1+ torch.onnx
22============
3- .. automodule :: torch.toffee
3+ .. automodule :: torch.onnx
44
55Example: End-to-end AlexNet from PyTorch to Caffe2
66--------------------------------------------------
@@ -10,12 +10,12 @@ torchvision into Toffee IR. It runs a single round of inference and then
1010saves the resulting traced model to ``alexnet.proto ``::
1111
1212 from torch.autograd import Variable
13- import torch.toffee
13+ import torch.onnx
1414 import torchvision
1515
1616 dummy_input = Variable(torch.randn(10, 3, 224, 224)).cuda()
1717 model = torchvision.models.alexnet(pretrained=True).cuda()
18- torch.toffee .export(model, dummy_input, "alexnet.proto", verbose=True)
18+ torch.onnx .export(model, dummy_input, "alexnet.proto", verbose=True)
1919
2020The resulting ``alexnet.proto `` is a binary protobuf file which contains both
2121the network structure and parameters of the model you exported
@@ -51,14 +51,14 @@ exporter to print out a human-readable representation of the network::
5151 }
5252
5353You can also verify and inspect the actual (substantially more verbose) protobuf
54- using the `ToffeeIR <https://github.com/ProjectToffee/ToffeeIR / >`_ library::
54+ using the `ONNXIR <https://github.com/ProjectONNX/ONNXIR / >`_ library::
5555
56- import toffee
56+ import onnx
5757
58- graph = toffee .load("alexnet.proto")
58+ graph = onnx .load("alexnet.proto")
5959
6060 # Check that the IR is well formed
61- toffee .checker.check_graph(graph)
61+ onnx .checker.check_graph(graph)
6262
6363 # Print the IR
6464 print(str(graph))
@@ -68,7 +68,7 @@ To run the exported script with Caffe2, you will need to install
6868the backend for Caffe2::
6969
7070 # ...continuing from above
71- import toffee .backend.c2 as backend
71+ import onnx .backend.c2 as backend
7272 import numpy as np
7373
7474 (caffe2_proto, caffe2_workspace) = backend.prepare(graph, device="CUDA:0") # or "CPU"
@@ -80,7 +80,7 @@ In the future, there will be backends for other frameworks as well.
8080Limitations
8181-----------
8282
83- * The Toffee exporter is a *trace-based * exporter, which means that it
83+ * The ONNX exporter is a *trace-based * exporter, which means that it
8484 operates by executing your model once, and exporting the operators which
8585 were actually run during this run. This means that if your model is
8686 dynamic, e.g., changes behavior depending on input data, the export
0 commit comments