Skip to content

Commit 0cf0c68

Browse files
committed
fix confusion w.r.t. which model to serialize and use
1 parent 56b6951 commit 0cf0c68

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

advanced_source/cpp_export.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Loading a PyTorch Model in C++
22
==============================
33

4+
**This tutorial was updated to work with PyTorch 1.2**
5+
46
As its name suggests, the primary interface to PyTorch is the Python
57
programming language. While Python is a suitable and preferred language for
68
many scenarios requiring dynamism and ease of iteration, there are equally many
@@ -129,10 +131,11 @@ earlier in the tracing example. To perform this serialization, simply call
129131
`save <https://pytorch.org/docs/master/jit.html#torch.jit.ScriptModule.save>`_
130132
on the module and pass it a filename::
131133

132-
traced_script_module.save("model.pt")
134+
my_module.save("custom_model.pt")
133135

134-
This will produce a ``model.pt`` file in your working directory. We have now
135-
officially left the realm of Python and are ready to cross over to the sphere
136+
This will produce a ``custom_model.pt`` file in your working directory.
137+
If you also would like to save our traced version of ``ResNet18``, call ``traced_script_module.save("traced_resnet_model.pt")``
138+
We have now officially left the realm of Python and are ready to cross over to the sphere
136139
of C++.
137140

138141
Step 3: Loading Your Script Module in C++
@@ -285,13 +288,13 @@ distribution. If all goes well, it will look something like this:
285288
[100%] Linking CXX executable example-app
286289
[100%] Built target example-app
287290
288-
If we supply the path to the serialized ``ResNet18`` model we created earlier
291+
If we supply the path to the serialized custom model ``custom_model.pt`` we created earlier
289292
to the resulting ``example-app`` binary, we should be rewarded with a friendly
290293
"ok":
291294
292295
.. code-block:: sh
293296
294-
root@4b5a67132e81:/example-app/build# ./example-app model.pt
297+
root@4b5a67132e81:/example-app/build# ./example-app <path_to_model>/custom_model.pt
295298
ok
296299
297300
Step 4: Executing the Script Module in C++

0 commit comments

Comments
 (0)