Read activation function from input file
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | unit |
Unit number for input file |
||
| integer, | intent(inout), | optional | :: | iline |
Line number |
Activation function object
function read_activation(unit, iline) result(activation) !! Read activation function from input file implicit none ! Arguments integer, intent(in) :: unit !! Unit number for input file integer, intent(inout), optional :: iline !! Line number class(base_actv_type), allocatable :: activation !! Activation function object ! Local variables type(onnx_attribute_type), allocatable, dimension(:) :: attributes !! Array of ONNX attributes integer :: i !! Loop variable character(20) :: actv_name !! Activation function name logical :: found !! Flag for finding activation creator integer :: creator_index !! Index of activation creator integer :: iline_ = 0 !! Line number ! initialise list if needed if(.not.allocated(list_of_onnx_activation_creators)) & call allocate_list_of_onnx_activation_creators() ! Read activation attributes attributes = read_activation_attributes(unit, iline=iline_) if(present(iline)) iline = iline + iline_ ! Extract activation name actv_name = "" do i=1, size(attributes,dim=1) if(trim(to_lower(attributes(i)%name)) .eq. "name")then actv_name = trim(to_lower(attributes(i)%val)) exit end if end do if(actv_name .eq. "")then call stop_program( & "Activation name '"// actv_name //"' not specified in activation block" & ) return end if do i = 1, size(list_of_onnx_activation_creators,dim=1) if(trim(to_lower(list_of_onnx_activation_creators(i)%name)) .eq. actv_name)then found = .true. creator_index = i exit end if end do if(.not.found)then call stop_program( & "Activation name '"// actv_name //"' not recognised" & ) return end if allocate(activation, source = list_of_onnx_activation_creators(creator_index)% & create_ptr(attributes)) end function read_activation