Resets a tensor's gradient to zero.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(torch_tensor), | intent(inout) | :: | tensor |
Tensor to zero the gradient of |
subroutine torch_tensor_zero_grad(tensor) use, intrinsic :: iso_c_binding, only : c_associated class(torch_tensor), intent(inout) :: tensor !! Tensor to zero the gradient of interface subroutine torch_tensor_zero_grad_c(tensor) bind(c, name = 'torch_tensor_zero_grad') use, intrinsic :: iso_c_binding, only : c_ptr implicit none type(c_ptr), value, intent(in) :: tensor end subroutine torch_tensor_zero_grad_c end interface ! TODO: Call torch_tensor_get_gradient to check it exists? call torch_tensor_zero_grad_c(tensor%p) end subroutine torch_tensor_zero_grad