Cambridge-ICCS / FTorch

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

Implement `torch_tensor_to_array` #151

Closed jwallwork23 closed 2 months ago

jwallwork23 commented 5 months 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 5 months ago

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

jwallwork23 commented 5 months 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 5 months ago

Inderdaad.

jatkinson1000 commented 5 months 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...