Parse common NOP hyperparameters from metadata value string.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | meta_value | |||
| integer, | intent(inout) | :: | num_inputs | |||
| integer, | intent(inout) | :: | num_outputs | |||
| integer, | intent(inout) | :: | num_modes | |||
| logical, | intent(inout) | :: | use_bias | |||
| character(len=64), | intent(inout) | :: | activation_name |
subroutine parse_nop_metadata(meta_value, & num_inputs, num_outputs, num_modes, use_bias, activation_name) !! Parse common NOP hyperparameters from metadata value string. implicit none character(*), intent(in) :: meta_value integer, intent(inout) :: num_inputs, num_outputs, num_modes logical, intent(inout) :: use_bias character(64), intent(inout) :: activation_name integer :: k, pos, pos2, stat character(256) :: token, key, val logical :: logical_val pos = 1 do while(pos .le. len_trim(meta_value)) pos2 = index(meta_value(pos:), ';') if(pos2 .eq. 0)then token = meta_value(pos:len_trim(meta_value)) pos = len_trim(meta_value) + 1 else token = meta_value(pos:pos+pos2-2) pos = pos + pos2 end if k = index(token, '=') if(k .eq. 0) cycle key = trim(adjustl(token(1:k-1))) val = trim(adjustl(token(k+1:))) select case(trim(key)) case('num_inputs') read(val, *) num_inputs case('num_outputs') read(val, *) num_outputs case('num_modes', 'num_basis') read(val, *) num_modes case('use_bias') read(val, *, iostat=stat) logical_val if(stat .eq. 0)then use_bias = logical_val else select case(trim(adjustl(val))) case('1', 'T', 't', 'true', 'TRUE', 'True') use_bias = .true. case('0', 'F', 'f', 'false', 'FALSE', 'False') use_bias = .false. case default call stop_program('parse_nop_metadata: invalid use_bias value') end select end if case('activation') activation_name = trim(val) end select end do end subroutine parse_nop_metadata