FTorch
FTorch copied to clipboard
Add FAQ item about constructing tensors used in overloaded assignments
Note: Found during this that one cannot use tensor_a = tensor_b(requires_grad=.true.) when tensor_a is only defined as a torch_tensor. This is because the required_grad property gets copied across, and then we get errors resulting from trying to modify the values of a tensor with requires_grad=.true.. The solution is to declare tensor_a as empty.
See pFUnit tests for optimizers, specifically the zero_grad test.
cc @jwallwork23
Originally posted by @jatkinson1000 in https://github.com/Cambridge-ICCS/FTorch/issues/320#issuecomment-3024838290