update_pytorch_prev_output Subroutine

subroutine update_pytorch_prev_output(layer, prefix, is_last_layer, output)

Resolve the downstream tensor name after emitting one PyTorch-format NOP.

Arguments

Type IntentOptional Attributes Name
class(base_layer_type), intent(in) :: layer
character(len=*), intent(in) :: prefix
logical, intent(in) :: is_last_layer
character(len=128), intent(inout) :: output

Source Code

  subroutine update_pytorch_prev_output(layer, prefix, is_last_layer, output)
    !! Resolve the downstream tensor name after emitting one PyTorch-format NOP.
    implicit none

    class(base_layer_type), intent(in) :: layer
    character(*), intent(in) :: prefix
    logical, intent(in) :: is_last_layer
    character(128), intent(inout) :: output

    if(is_last_layer)then
       output = 'output'
       return
    end if

    select type(layer)
    class is(learnable_layer_type)
       if(trim(layer%activation%name) .ne. 'none')then
          write(output, '("/",A,"/Relu_output_0")') trim(prefix)
       else
          write(output, '("/",A,"/Transpose_1_output_0")') trim(prefix)
       end if
    class default
       write(output, '("/",A,"/Transpose_1_output_0")') trim(prefix)
    end select

  end subroutine update_pytorch_prev_output