find_activation_node_for_layer_id Function

function find_activation_node_for_layer_id(nodes, num_nodes, layer_id) result(actv_index)

Return node index for activation attached to node_, or 0.

Arguments

Type IntentOptional Attributes Name
type(onnx_node_type), intent(in) :: nodes(:)

Parsed ONNX nodes

integer, intent(in) :: num_nodes

Number of valid nodes and target layer id

integer, intent(in) :: layer_id

Number of valid nodes and target layer id

Return Value integer

Index of the found activation node


Source Code

  function find_activation_node_for_layer_id(nodes, num_nodes, layer_id) &
       result(actv_index)
    !! Return node index for activation attached to node_<id>, or 0.
    implicit none

    ! Arguments
    type(onnx_node_type), intent(in) :: nodes(:)
    !! Parsed ONNX nodes
    integer, intent(in) :: num_nodes, layer_id
    !! Number of valid nodes and target layer id

    integer :: actv_index
    !! Index of the found activation node

    ! Local variables
    integer :: i
    !! Loop index
    character(128) :: prefix
    !! Prefix for activation nodes linked to layer_id

    write(prefix, '("node_",I0,"_")') layer_id
    actv_index = 0

    do i = 1, num_nodes
       if(index(trim(nodes(i)%name), trim(prefix)) .ne. 1) cycle
       if(is_activation_op_type(trim(nodes(i)%op_type)))then
          actv_index = i
          return
       end if
    end do

  end function find_activation_node_for_layer_id