Cambridge-ICCS / FTorch

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

Implement `torch_tensor_to_array` #151

Open jwallwork23 opened 4 days ago

jwallwork23 commented 4 days ago

FTorch implements torch_tensor_from_array to map Fortran arrays to (F)Torch tensors. It would be useful to have the reverse mapping, too.

This would provide a way to get around the issue mentioned in #139.

dorchard commented 4 days ago

Good idea. Would it be worth having an alias for it as well called torch_array_from_tensor?

jwallwork23 commented 4 days ago

Good idea. Would it be worth having an alias for it as well called torch_array_from_tensor?

Sure, I guess torch_array_to_tensor would then complete the set.

dorchard commented 4 days ago

Inderdaad.

jatkinson1000 commented 4 days ago

Interesting, I always read it as being "create a torch_tensor from a fortran_array" and this is how we refer to things in our docs - and we have an object called a torch_tensor.

I feel like torch_array from tensor could be ambiguous on this front.

However, I feel like all our routines all being prepended with torch_ is nice too...