Skip to content

Commit 6d8d5ba

Browse files
zdevitoapaszke
authored andcommitted
Codemod Toffee -> ONNX, toffee -> onnx. Change file names to match
1 parent c42ca96 commit 6d8d5ba

33 files changed

Lines changed: 421 additions & 420 deletions
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
torch.toffee
1+
torch.onnx
22
============
3-
.. automodule:: torch.toffee
3+
.. automodule:: torch.onnx
44

55
Example: 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
1010
saves 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

2020
The resulting ``alexnet.proto`` is a binary protobuf file which contains both
2121
the 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

5353
You 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
6868
the 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.
8080
Limitations
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

‎setup.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ def run(self):
333333
main_libraries = ['shm']
334334
main_link_args = [TH_LIB, THS_LIB, THPP_LIB, THNN_LIB, ATEN_LIB, NANOPB_STATIC_LIB]
335335
main_sources = [
336-
"torch/csrc/toffee.pb.cpp",
337-
"torch/csrc/toffee.cpp",
336+
"torch/csrc/onnx.pb.cpp",
337+
"torch/csrc/onnx.cpp",
338338
"torch/csrc/PtrWrapper.cpp",
339339
"torch/csrc/Module.cpp",
340340
"torch/csrc/Generator.cpp",
@@ -379,9 +379,9 @@ def run(self):
379379
"torch/csrc/autograd/functions/special.cpp",
380380
"torch/csrc/autograd/functions/utils.cpp",
381381
"torch/csrc/autograd/functions/init.cpp",
382-
"torch/csrc/autograd/functions/toffee/convolution.cpp",
383-
"torch/csrc/autograd/functions/toffee/batch_normalization.cpp",
384-
"torch/csrc/toffee/export.cpp",
382+
"torch/csrc/autograd/functions/onnx/convolution.cpp",
383+
"torch/csrc/autograd/functions/onnx/batch_normalization.cpp",
384+
"torch/csrc/onnx/export.cpp",
385385
]
386386
main_sources += split_types("torch/csrc/Tensor.cpp")
387387

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)