torch_tensor_requires_grad Function

public function torch_tensor_requires_grad(self) result(requires_grad)

Determines whether a tensor requires the autograd module.

Type Bound

torch_tensor

Arguments

Type IntentOptional Attributes Name
class(torch_tensor), intent(in) :: self

Return Value logical


Source Code

  function torch_tensor_requires_grad(self) result(requires_grad)
    class(torch_tensor), intent(in) :: self
    logical :: requires_grad

    interface
      function torch_tensor_requires_grad_c(tensor) result(requires_grad) &
          bind(c, name = 'torch_tensor_requires_grad')
        use, intrinsic :: iso_c_binding, only : c_bool, c_ptr
        implicit none
        type(c_ptr), value, intent(in) :: tensor
        logical(c_bool) :: requires_grad
      end function torch_tensor_requires_grad_c
    end interface

    requires_grad = torch_tensor_requires_grad_c(self%p)
  end function torch_tensor_requires_grad