summaryrefslogtreecommitdiff
path: root/docs/cpp
diff options
context:
space:
mode:
authorWill Feng <willfeng@fb.com>2019-01-21 21:53:43 -0800
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2019-01-21 21:56:22 -0800
commitdfcafb1f719aa54a206aaf966165225f1501a80c (patch)
treef74fa7bdac5e897e95fa1db149456bf79c7580e0 /docs/cpp
parentaddebf110f2dfa86dd42e2a19ae8ae170d31605c (diff)
downloadpytorch-dfcafb1f719aa54a206aaf966165225f1501a80c.tar.gz
pytorch-dfcafb1f719aa54a206aaf966165225f1501a80c.tar.bz2
pytorch-dfcafb1f719aa54a206aaf966165225f1501a80c.zip
cpp doc fix (#16221)
Summary: Fixed a few C++ API callsites to work with v1.0.1. Pull Request resolved: https://github.com/pytorch/pytorch/pull/16221 Differential Revision: D13759207 Pulled By: yf225 fbshipit-source-id: bd92c2b95a0c6ff3ba5d73cb249d0bc88cfdc340
Diffstat (limited to 'docs/cpp')
-rw-r--r--docs/cpp/source/installing.rst2
-rw-r--r--docs/cpp/source/notes/tensor_creation.rst14
2 files changed, 7 insertions, 9 deletions
diff --git a/docs/cpp/source/installing.rst b/docs/cpp/source/installing.rst
index 9aabfe4aaa..82d4ab7bf9 100644
--- a/docs/cpp/source/installing.rst
+++ b/docs/cpp/source/installing.rst
@@ -118,7 +118,7 @@ should now merrily print the tensor (exact output subject to randomness):
.. code-block:: sh
- root@4b5a67132e81:/example-app/build# ./example-app model.pt
+ root@4b5a67132e81:/example-app/build# ./example-app
0.2063 0.6593 0.0866
0.0796 0.5841 0.1569
[ Variable[CPUFloatType]{2,3} ]
diff --git a/docs/cpp/source/notes/tensor_creation.rst b/docs/cpp/source/notes/tensor_creation.rst
index 4905c75e57..df01acfd9a 100644
--- a/docs/cpp/source/notes/tensor_creation.rst
+++ b/docs/cpp/source/notes/tensor_creation.rst
@@ -72,7 +72,7 @@ tensor filled with values from a unit normal distribution by writing:
.. code-block:: cpp
torch::Tensor tensor = torch::randn({3, 4, 5});
- assert(tensor.sizes() == torch::IntList{3, 4, 5})
+ assert(tensor.sizes() == torch::IntList{3, 4, 5});
Notice how we use ``tensor.sizes()`` to get back an ``IntList`` containing the
sizes we passed to the tensor. You can also write ``tensor.size(i)`` to access
@@ -162,7 +162,7 @@ device 1:
torch::TensorOptions()
.dtype(torch::kFloat32)
.layout(torch::kStrided)
- .device({torch::kCUDA, 1})
+ .device(torch::kCUDA, 1)
.requires_grad(true);
@@ -173,15 +173,13 @@ properties:
.. code-block:: cpp
- torch::Tensor tensor = torch::full(/*value=*/123, {3, 4}, options);
+ torch::Tensor tensor = torch::full({3, 4}, /*value=*/123, options);
assert(tensor.dtype() == torch::kFloat32);
assert(tensor.layout() == torch::kStrided);
assert(tensor.device().type() == torch::kCUDA); // or device().is_cuda()
assert(tensor.device().index() == 1);
- assert(tensor.requires_grad())
-
- assert(tensor.options() == options)
+ assert(tensor.requires_grad());
Now, you may be thinking: do I really need to specify each axis for every new
tensor I create? Fortunately, the answer is "no", as **every axis has a default
@@ -199,7 +197,7 @@ defaulted:
.. code-block:: cpp
- auto options = torch::TensorOptions().device({torch::kCUDA, 1}).requires_grad(true);
+ auto options = torch::TensorOptions().device(torch::kCUDA, 1).requires_grad(true);
In fact, we can even omit all axes to get an entirely defaulted
``TensorOptions`` object:
@@ -291,7 +289,7 @@ with the equivalent call in C++:
.. code-block:: cpp
- torch::randn({3, 4}, torch::dtype(torch::kFloat32).device({torch::kCUDA, 1}).requires_grad(true))
+ torch::randn({3, 4}, torch::dtype(torch::kFloat32).device(torch::kCUDA, 1).requires_grad(true))
Pretty close!