title: Parse an ONNX model using C++. Extract layers, input and output shape from an onnx model using c++
body: <p>I'm trying to extract data like input layers, output layers and their shapes from an onnx model. I know there is python interface to do this. I want to do something similar to this <a href="https://stackoverflow.com/questions/56734576/find-input-shape-from-onnx-file">code</a> but in c++. I have also pasted the code from the link. I have tried it in python and it has worked for me. I want to know if there are c++ API's to do the same.</p>
  <pre><code>import onnx
  
  model = onnx.load(r&quot;model.onnx&quot;)
  
  # The model is represented as a protobuf structure and it can be accessed
  # using the standard python-for-protobuf methods
  
  # iterate through inputs of the graph
  for input in model.graph.input:
      print (input.name, end=&quot;: &quot;)
      # get type of input tensor
      tensor_type = input.type.tensor_type
      # check if it has a shape:
      if (tensor_type.HasField(&quot;shape&quot;)):
          # iterate through dimensions of the shape:
          for d in tensor_type.shape.dim:
              # the dimension may have a definite (integer) value or a symbolic identifier or neither:
              if (d.HasField(&quot;dim_value&quot;)):
                  print (d.dim_value, end=&quot;, &quot;)  # known dimension
              elif (d.HasField(&quot;dim_param&quot;)):
                  print (d.dim_param, end=&quot;, &quot;)  # unknown dimension with symbolic name
              else:
                  print (&quot;?&quot;, end=&quot;, &quot;)  # unknown dimension with no name
      else:
          print (&quot;unknown rank&quot;, end=&quot;&quot;)
      print()
  </code></pre>
  <p>Also I'm new to c++, please help me with the same.</p>