Skip to content

Commit aa1fe45

Browse files
committed
Add notes on pointers [skip ci]
1 parent 43b755a commit aa1fe45

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pages/tensor.md

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ of the `torch::Tensor` C++ class. The interface is designed to be familiar to
99
Fortran programmers, whilst retaining strong similarity with `torch::Tensor` and
1010
the `torch.Tensor` Python class.
1111

12+
Under the hood, the `torch_tensor` type holds a pointer to a `torch::Tensor`
13+
object in C++ (implemented using `c_ptr` from the `iso_c_binding` intrinsic
14+
module). This allows us to avoid unnecessary data copies between C++ and
15+
Fortran.
16+
1217
## Procedures
1318

1419
### Constructors
@@ -26,6 +31,11 @@ include:
2631
the data is *not* copied - the tensor data points to the Fortran array,
2732
meaning the array must have been declared with the `target` property.
2833

34+
It is *compulsory* to call one of the constructors before interacting with it in
35+
any of the ways described in the following. Each of the constructors sets the
36+
pointer attribute of the `torch_tensor`; without this being set, most of the
37+
other operations are meaningless.
38+
2939
### Tensor interrogation
3040

3141
We provide several subroutines for interrogating `torch_tensor` objects. These

0 commit comments

Comments
 (0)