Skip to content

Commit 5835d3a

Browse files
committed
Add notes to autograd page on working with scalars
1 parent 390c016 commit 5835d3a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pages/autograd.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,20 @@ use ftorch
2424
statement, the best practice is to import specifically the operators that you
2525
wish to use. Note that the assignment operator `=` has a slightly different
2626
notation:
27-
```
27+
```fortran
2828
use ftorch, only: assignment(=), operator(+), operator(-), operator(*), &
2929
operator(/), operator(**)
3030
```
3131

32+
If you would like to make use of scalar multiplication or scalar division, this
33+
can be achieved by setting the scalar as a rank-1 `torch_tensor` with a single
34+
entry. For example:
35+
```fortran
36+
call torch_tensor_from_array(multiplier, [3.0_wp], [1], torch_kCPU)
37+
```
38+
3239
For a concrete example of how to compute mathematical expressions involving
33-
Torch tensors, see the associated
40+
Torch tensors and scalars, see the associated
3441
[worked example](https://github.com/Cambridge-ICCS/FTorch/tree/main/examples/6_Autograd).
3542

3643
### The `requires_grad` property

0 commit comments

Comments
 (0)