forward_avgpool2d Subroutine

private subroutine forward_avgpool2d(this, input)

Forward propagation

Type Bound

avgpool2d_layer_type

Arguments

Type IntentOptional Attributes Name
class(avgpool2d_layer_type), intent(inout) :: this

Instance of the 2D average pooling layer

class(array_type), intent(in), dimension(:,:) :: input

Input values


Source Code

  subroutine forward_avgpool2d(this, input)
    !! Forward propagation
    implicit none

    ! Arguments
    class(avgpool2d_layer_type), intent(inout) :: this
    !! Instance of the 2D average pooling layer
    class(array_type), dimension(:,:), intent(in) :: input
    !! Input values

    ! Local variables
    type(array_type), pointer :: ptr
    !! Pointer array


    call this%output(1,1)%zero_grad()
    select case(allocated(this%pad_layer))
    case(.true.)
       call this%pad_layer%forward(input)
       ptr => avgpool2d(this%pad_layer%output(1,1), this%pool, this%strd)
    case default
       ptr => avgpool2d(input(1,1), this%pool, this%strd)
    end select
    call this%output(1,1)%assign_and_deallocate_source(ptr)
    this%output(1,1)%is_temporary = .false.

  end subroutine forward_avgpool2d