Samsung / ONE

On-device Neural Engine
Other
429 stars 157 forks source link

[onnx-tools] Show tensor shape in onnx-dump #13973

Closed seanshpark closed 3 weeks ago

seanshpark commented 3 weeks ago

onnx-dump.py doesn't show tensor info (shape, dtype) let's revise this tool to show them.

seanshpark commented 3 weeks ago

when dump model.graph, there is value_info like

value_info {
  name: "/Add_1_output_0"
  type {
    tensor_type {
      elem_type: 1
      shape {
        dim {
          dim_value: 1
        }
        dim {
          dim_value: 2
        }
        dim {
          dim_value: 3
        }
        dim {
          dim_value: 3
        }
      }
    }
  }
}
shs-park commented 3 weeks ago

when dump model.graph, there is value_info like

Is it correct..?

seanshpark commented 3 weeks ago

Is it correct..?

Yup :)

shape: [1,2,3,5] (rank 4) dtype is elem_type = 1

Type is defined like

message TypeProto {

  message Tensor {
    // This field MUST NOT have the value of UNDEFINED
    // This field MUST have a valid TensorProto.DataType value
    // This field MUST be present for this version of the IR.
    optional int32 elem_type = 1;
    optional TensorShapeProto shape = 2;
  }
icodo98 commented 3 weeks ago

shape: [1,2,3,5] (rank 4) dtype is elem_type = 1

May I ask whether we should consider dynamic tensor shapes in this issue?

IMHO, dim_param in tensor.dim contains this information:

seanshpark commented 3 weeks ago

May I ask whether we should consider dynamic tensor shapes in this issue?

Maybe yes, but not now. This issue is to solve my internal problem with ONNX model.

seanshpark commented 3 weeks ago

done