Copy the current initialiser state into the parsed result collection.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(json_initialiser_state_type), | intent(in) | :: | state |
Completed initialiser parse state to copy into the result object |
||
| type(json_parse_result_type), | intent(inout) | :: | parsed |
Parsed ONNX content accumulated so far |
subroutine store_initialiser_state(state, parsed) !! Copy the current initialiser state into the parsed result collection. use athena__onnx_utils, only: decode_base64_to_float32, & decode_base64_to_int64 implicit none ! Arguments type(json_initialiser_state_type), intent(in) :: state !! Completed initialiser parse state to copy into the result object type(json_parse_result_type), intent(inout) :: parsed !! Parsed ONNX content accumulated so far ! Local variables integer :: j, n_decoded !! Integer loop index and decoded tensor length real(real32), allocatable :: decoded_floats(:) !! Float payload decoded from base64 rawData integer, allocatable :: decoded_ints(:) !! Int64 payload decoded from base64 rawData parsed%num_inits = parsed%num_inits + 1 parsed%inits(parsed%num_inits)%name = state%name parsed%inits(parsed%num_inits)%data_type = state%data_type if(allocated(state%dims))then allocate(parsed%inits(parsed%num_inits)%dims(size(state%dims))) parsed%inits(parsed%num_inits)%dims = state%dims end if if(len_trim(state%raw_data) .eq. 0) return if(state%data_type .eq. 1)then call decode_base64_to_float32(trim(state%raw_data), decoded_floats, & n_decoded) allocate(parsed%inits(parsed%num_inits)%data(n_decoded)) parsed%inits(parsed%num_inits)%data = decoded_floats deallocate(decoded_floats) else if(state%data_type .eq. 7)then call decode_base64_to_int64(trim(state%raw_data), decoded_ints, & n_decoded) allocate(parsed%inits(parsed%num_inits)%data(n_decoded)) do j = 1, n_decoded parsed%inits(parsed%num_inits)%data(j) = & real(decoded_ints(j), real32) end do deallocate(decoded_ints) end if end subroutine store_initialiser_state