Skip to content

Commit 5dfeb59

Browse files
committed
Update C++ frontend tutorial with template, working MNIST download link, and newer C++ / CMake versions
1 parent bafe9d4 commit 5dfeb59

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

advanced_source/cpp_frontend.rst

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
1+
.. _cpp-frontend-tutorial:
2+
13
Using the PyTorch C++ Frontend
24
==============================
35

6+
**Author:** `Peter Goldsborough <https://github.com/goldsborough>`_
7+
8+
.. grid:: 2
9+
10+
.. grid-item-card:: :octicon:`mortar-board;1em;` What you will learn
11+
:class-card: card-prerequisites
12+
13+
* How to build a C++ application that utilizes the PyTorch C++ frontend
14+
* How to define and train neural networks from C++ using PyTorch abstractions
15+
16+
.. grid-item-card:: :octicon:`list-unordered;1em;` Prerequisites
17+
:class-card: card-prerequisites
18+
19+
* PyTorch 1.5 or later
20+
* Basic understanding of C++ programming
21+
* Basic Ubuntu Linux environment with CMake >= 3.5; similar commands will work in a MacOS / Windows environment
22+
* (Optional) A CUDA-based GPU for the GPU training sections
23+
424
The PyTorch C++ frontend is a pure C++ interface to the PyTorch machine learning
525
framework. While the primary interface to PyTorch naturally is Python, this
626
Python API sits atop a substantial C++ codebase providing foundational data
727
structures and functionality such as tensors and automatic differentiation. The
8-
C++ frontend exposes a pure C++11 API that extends this underlying C++ codebase
28+
C++ frontend exposes a pure C++17 API that extends this underlying C++ codebase
929
with tools required for machine learning training and inference. This includes a
1030
built-in collection of common components for neural network modeling; an API to
1131
extend this collection with custom modules; a library of popular optimization
@@ -137,14 +157,14 @@ on we'll use this ``CMakeLists.txt`` file:
137157

138158
.. code-block:: cmake
139159
140-
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
160+
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
141161
project(dcgan)
142162
143163
find_package(Torch REQUIRED)
144164
145165
add_executable(dcgan dcgan.cpp)
146166
target_link_libraries(dcgan "${TORCH_LIBRARIES}")
147-
set_property(TARGET dcgan PROPERTY CXX_STANDARD 14)
167+
set_property(TARGET dcgan PROPERTY CXX_STANDARD 17)
148168
149169
.. note::
150170

@@ -859,7 +879,7 @@ stacks them into a single tensor along the first dimension:
859879
860880
Note that the MNIST dataset should be located in the ``./mnist`` directory
861881
relative to wherever you execute the training binary from. You can use `this
862-
script <https://gist.github.com/goldsborough/6dd52a5e01ed73a642c1e772084bcd03>`_
882+
script <https://gist.github.com/jbschlosser/94347505df6188f8764793ee29fd1bdd>`_
863883
to download the MNIST dataset.
864884
865885
Next, we create a data loader and pass it this dataset. To make a new data

0 commit comments

Comments
 (0)