combine_concat Subroutine

private subroutine combine_concat(this, input_list)

Forward propagation for 2D input

Type Bound

concat_layer_type

Arguments

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

Instance of the concatenate layer

type(array_ptr_type), intent(in), dimension(:) :: input_list

Input values


Source Code

  subroutine combine_concat(this, input_list)
    !! Forward propagation for 2D input
    implicit none

    ! Arguments
    class(concat_layer_type), intent(inout) :: this
    !! Instance of the concatenate layer
    type(array_ptr_type), dimension(:), intent(in) :: input_list
    !! Input values

    ! Local variables
    integer :: i, j, s
    !! Loop index
    type(array_type), pointer :: ptr
    !! Pointer array


    if(allocated(this%output))then
       if(any(shape(this%output).ne.shape(input_list(1)%array)))then
          deallocate(this%output)
          allocate(this%output( &
               size(input_list(1)%array,1), &
               size(input_list(1)%array,2) &
          ))
       end if
    else
       allocate(this%output( &
            size(input_list(1)%array,1), &
            size(input_list(1)%array,2) &
       ))
    end if

    do s = 1, size(input_list(1)%array, 2)
       index_loop: do i = 1, size(input_list(1)%array, 1)
          do j = 1, size(input_list,1)
             if(.not.input_list(j)%array(i,s)%allocated) cycle index_loop
          end do
          ptr => concat_layers(input_list, i, s, dim = 1)
          call this%output(i,s)%zero_grad()
          call this%output(i,s)%assign_and_deallocate_source(ptr)
          this%output(i,s)%is_temporary = .false.
       end do index_loop
    end do

  end subroutine combine_concat