detect_onnx_expanded_nop_activation Function

public function detect_onnx_expanded_nop_activation(prefix, nodes, num_nodes) result(name)

Reconstruct the activation name from the tail of an expanded-ONNX NOP cluster.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: prefix

Layer node prefix without leading slash

type(onnx_node_type), intent(in) :: nodes(:)

Parsed ONNX nodes

integer, intent(in) :: num_nodes

Number of valid node entries

Return Value character(len=64)

Reconstructed ATHENA activation name


Source Code

  function detect_onnx_expanded_nop_activation(prefix, nodes, num_nodes) &
       result(name)
    !! Reconstruct the activation name from the tail of an expanded-ONNX NOP
    !! cluster.
    use athena__onnx_utils, only: onnx_to_athena_activation
    implicit none

    ! Arguments
    character(*), intent(in) :: prefix
    !! Layer node prefix without leading slash
    type(onnx_node_type), intent(in) :: nodes(:)
    !! Parsed ONNX nodes
    integer, intent(in) :: num_nodes
    !! Number of valid node entries
    character(64) :: name
    !! Reconstructed ATHENA activation name
    integer :: i
    character(128) :: cluster_prefix

    write(cluster_prefix, '("/",A,"/")') trim(prefix)
    name = 'none'

    do i = 1, num_nodes
       if(index(trim(nodes(i)%name), trim(cluster_prefix)) .ne. 1) cycle
       select case(trim(nodes(i)%op_type))
       case('Relu', 'LeakyRelu', 'Sigmoid', 'Softmax', 'Tanh', 'Selu', &
            'Swish')
          name = onnx_to_athena_activation(trim(nodes(i)%op_type))
          return
       end select
    end do

  end function detect_onnx_expanded_nop_activation