Parse one line from the input or output tensor section.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | line |
Current JSON line to parse |
||
| type(json_tensor_state_type), | intent(inout) | :: | state |
Mutable tensor parser state |
||
| type(onnx_tensor_type), | intent(inout) | :: | tensors(:) |
Parsed tensor destination array |
||
| integer, | intent(inout) | :: | num_tensors |
Number of valid tensor entries in tensors |
||
| character(len=32), | intent(inout) | :: | section |
Current top-level JSON section name |
subroutine parse_tensor_section_line(line, state, tensors, num_tensors, & section) !! Parse one line from the input or output tensor section. implicit none ! Arguments character(*), intent(in) :: line !! Current JSON line to parse type(json_tensor_state_type), intent(inout) :: state !! Mutable tensor parser state type(onnx_tensor_type), intent(inout) :: tensors(:) !! Parsed tensor destination array integer, intent(inout) :: num_tensors !! Number of valid tensor entries in tensors character(32), intent(inout) :: section !! Current top-level JSON section name ! Local variables integer :: stat, dim_value !! Read status and parsed dimension value character(256) :: tmpstr !! Temporary string buffer for dimValue parsing if(.not.state%in_object .and. is_json_object_start(line))then call reset_tensor_state(state) state%in_object = .true. state%object_depth = 1 return end if if(state%in_object)then call update_object_depth(line, state%object_depth) if(state%object_depth .le. 0)then call store_tensor_state(state, tensors, num_tensors) state%in_object = .false. return end if if(index(line, '"name"') .gt. 0)then call extract_json_string(line, '"name"', state%name) return end if if(index(line, '"elemType"') .gt. 0)then call extract_json_int(line, '"elemType"', state%elem_type) return end if if(index(line, '"dimValue"') .gt. 0)then call extract_json_string(line, '"dimValue"', tmpstr) read(tmpstr, *, iostat=stat) dim_value if(stat .eq. 0) state%dim_values = [state%dim_values, dim_value] return end if if(index(line, '"dimParam"') .gt. 0)then state%dim_values = [state%dim_values, -1] return end if end if if(index(line, ']') .gt. 0 .and. .not.state%in_object) section = '' end subroutine parse_tensor_section_line