Cambridge-ICCS / FTorch

A library for directly calling PyTorch ML models from Fortran.
https://cambridge-iccs.github.io/FTorch/
MIT License
48 stars 11 forks source link

About Autograd Support in Ftorch #131

Open nckxneoro52449 opened 1 month ago

nckxneoro52449 commented 1 month ago

I have a question regarding the functionality of Ftorch. Does Ftorch currently support PyTorch's autograd feature for calculating first-order derivatives (Jacobians)? If not, are there any plans to add this feature in the future?

jatkinson1000 commented 1 month ago

At present we do not include this functionality, but there are active plans to do so in future: See e.g. https://github.com/Cambridge-ICCS/FTorch/discussions/22

It is something we hope to look at soon after we finalise GPU functionalities make a first release, but community contributions are also welcome. Even if it is just a list of the functionalities you would like to see made available through FTorch.

jatkinson1000 commented 2 weeks ago

To follow up on this, can you clarify how exactly you plan to use this? We have an option requires_grad_opt in the tensor and model loaders that turn on gradient calculation, and is_training_opt for models.

See: https://cambridge-iccs.github.io/FTorch/interface/torch_tensor_from_array.html https://cambridge-iccs.github.io/FTorch/proc/torch_module_load.html

If either of those help.