FTorch icon indicating copy to clipboard operation
FTorch copied to clipboard

Add FAQ item about constructing tensors used in overloaded assignments

Open joewallwork opened this issue 5 months ago • 0 comments

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

joewallwork avatar Jul 01 '25 17:07 joewallwork