diff --git a/pages/updates.md b/pages/updates.md index 08315754..ea0b73ea 100644 --- a/pages/updates.md +++ b/pages/updates.md @@ -16,19 +16,22 @@ will be avoided. We hope that this is the last time we have such a shift. The changes allow us to implement two new features: -#. Multiple output tensors +1. Multiple output tensors Previously you could pass an array of several input tensors to a Torch model, but only recieve a single output tensor back. Now you can use models that return several output tensors by passing an array of output tensors instead. -#. Preparation for autograd functionality +2. Preparation for autograd functionality We hope to make it easier to access the autograd features of PyTorch from within Fortran. To do this we needed to change how data was assigned from a Fortran array to a Torch tensor. This is now done via a subroutine call rather than a function. +
## Changes and how to update your code -### `torch_tensor`s are created using a subroutine call, not a function +
+ +#### `torch_tensor`s are created using a subroutine call, not a function Previously you would have created a Torch tensor and assigned some fortran data to it as follows: ```fortran @@ -38,7 +41,7 @@ integer :: tensor_layout(1) = [1] my_tensor = torch_tensor_from_array(fortran_data, tensor_layout, torch_kCPU) ``` - +
Now a call is made to a subroutine with the tensor as the first argument: ```fortran real, dimension(5), target :: fortran_data @@ -48,8 +51,9 @@ integer :: tensor_layout(1) = [1] call torch_tensor_from_array(my_tensor, fortran_data, tensor_layout, torch_kCPU) ``` +
-### module becomes model and loading becomes a subroutine call, not a function +#### `module` becomes `model` and loading becomes a subroutine call, not a function Previously a neural net was referred to as a '`module`' and loaded using appropriately named functions and types. @@ -58,7 +62,7 @@ type(torch_module) :: model model = torch_module_load(args(1)) call torch_module_forward(model, in_tensors, out_tensors) ``` - +
Following user feedback we now refer to a neural net and its associated types and calls as a '`model`'. The process of loading a net is also now a subroutine call for consistency with the @@ -70,23 +74,25 @@ call torch_model_forward(model, in_tensors, out_tensors) ``` +
-### n_inputs is no longer required +#### `n_inputs` is no longer required Previously when you called the forward method on a net you had to specify the number of tensors in the array of inputs: ```fortran call torch_model_forward(model, in_tensors, n_inputs, out_tensors) ``` - +
Now all that is supplied to the forward call is the model, and the arrays of input and output tensors. No need for `n_inputs` (or `n_outputs`)! ```fortran call torch_model_forward(model, in_tensors, out_tensors) ``` +
-### Outputs now need to be an array of `torch_tensor`s +#### Outputs now need to be an array of `torch_tensor`s Previously you passed an array of `torch_tensor` types as inputs, and a single `torch_tensor` to the forward method: @@ -96,7 +102,7 @@ type(torch_tensor) :: output_tensor ... call torch_model_forward(model, input_tensor_array, n_inputs, output_tensor) ``` - +
Now both the inputs and the outputs need to be an array of `torch_tensor` types: ```fortran type(torch_tensor), dimension(n_inputs) :: input_tensor_array