Overload elementary operations
Closes #138.
This seems sensible, and impressive 😄
What is the argument for making torch_tensor_from_array() no longer return a value but instead operate internally?
We can chat over lunch.
This seems sensible, and impressive 😄 What is the argument for making
torch_tensor_from_array()no longer return a value but instead operate internally? We can chat over lunch.
Thanks!
If you overload the assignment operator then tensor = torch_tensor_from_array(...) will call torch_tensor_from_array with the provided arguments and then call torch_tensor_assign, copying that into tensor. If this and other constructor-type procedures go from being functions to subroutines then we avoid unnecessary data copies.
I created a new branch autograd_toarray off this one and merged in changes from #161. Can confirm the tests pass!
Got round to updating this branch. The simplest thing to do was to merge main into it, so it should be merged with squash.
As discussed in today's meeting, we should check what happens if an operator that hasn't been implemented is used. I switched from Q = 3 * a ** 3 - b ** 2 to Q = 3 * a ** b - b ** 2, i.e., take a tensor to the power of another tensor, rather than to the power of a scalar. I get the following compile error, which seems clear enough:
Scanning dependencies of target autograd
[ 91%] Building Fortran object test/examples/6_Autograd/CMakeFiles/autograd.dir/autograd.f90.o
/home/joe/software/FTorch/src/test/examples/6_Autograd/autograd.f90:54:14:
54 | Q = 3 * a ** b - b ** 2
| 1
Error: Unexpected derived-type entities in binary intrinsic numeric operator ‘**’ at (1)
Merged in the Windows fix from #207.