grad_forward Module Function

module function grad_forward(this, variable) result(output)

Perform forward-mode automatic differentiation

Arguments

Type IntentOptional Attributes Name
class(array_type), intent(inout) :: this
type(array_type), intent(in) :: variable

Return Value type(array_type), pointer


Source Code

  module function grad_forward(this, variable) result(output)
    !! Perform forward-mode automatic differentiation
    implicit none
    class(array_type), intent(inout) :: this
    type(array_type), intent(in) :: variable
    type(array_type), pointer :: output

    integer :: depth

    if(.not.variable%requires_grad)then
       call print_warning("Variable does not require grad in forward mode")
       return
    end if
    depth = 0
    output => forward_over_reverse(this, variable, depth)
    output%is_forward = .true.
    this%requires_grad = .true.

  end function grad_forward