get_partial_duvenaud_propagate_left_val Subroutine

pure subroutine get_partial_duvenaud_propagate_left_val(this, upstream_grad, output)

In-place value gradient for duvenaud_propagate left operand.

Arguments

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

Forward result node containing saved operands

real(kind=real32), intent(in), dimension(:,:) :: upstream_grad

Upstream gradient values

real(kind=real32), intent(out), dimension(:,:) :: output

Output gradient values for left operand


Source Code

  pure subroutine get_partial_duvenaud_propagate_left_val( &
       this, upstream_grad, output &
  )
    !! In-place value gradient for duvenaud_propagate left operand.
    implicit none

    ! Arguments
    class(array_type), intent(in) :: this
    !! Forward result node containing saved operands
    real(real32), dimension(:,:), intent(in) :: upstream_grad
    !! Upstream gradient values
    real(real32), dimension(:,:), intent(out) :: output
    !! Output gradient values for left operand

    ! Local variables
    integer :: v, w, num_features, num_elements
    !! Loop indices and operand shape values

    num_features = size(this%left_operand%val,1)
    num_elements = size(this%left_operand%val,2)
    output = 0._real32
    do concurrent(v=1:num_elements)
       do w = this%indices(v), this%indices(v+1)-1
          output(:,this%adj_ja(1,w)) = output(:,this%adj_ja(1,w)) + &
               [ upstream_grad(1:num_features, v) ]
       end do
    end do
  end subroutine get_partial_duvenaud_propagate_left_val