Skip to content

Commit

Permalink
Add notes to autograd page on working with scalars
Browse files Browse the repository at this point in the history
  • Loading branch information
jwallwork23 committed Feb 18, 2025
1 parent fa9f661 commit be28788
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pages/autograd.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ use ftorch
statement, the best practice is to import specifically the operators that you
wish to use. Note that the assignment operator `=` has a slightly different
notation:
```
```fortran
use ftorch, only: assignment(=), operator(+), operator(-), operator(*), &
operator(/), operator(**)
```

If you would like to make use of scalar multiplication or scalar division, this
can be achieved by setting the scalar as a rank-1 `torch_tensor` with a single
entry. For example:
```fortran
call torch_tensor_from_array(multiplier, [3.0_wp], [1], torch_kCPU)
```

For a concrete example of how to compute mathematical expressions involving
Torch tensors, see the associated
Torch tensors and scalars, see the associated
[worked example](https://github.com/Cambridge-ICCS/FTorch/tree/main/examples/6_Autograd).

### The `requires_grad` property
Expand Down

0 comments on commit be28788

Please sign in to comment.