1

This seems so basic, but for some reason, I can't find any clear documentation on it.

So lets say I know my ONNX model wants an input of shape [245, 245, 3]. The second argument in the constructor Ort::Value::CreateTensor wants a linear array of the data to fill the tensor. What is the order of the linear array?

For example, are the first three values in the linear array the BGR values for the 0-th pixel in the image, or are the first three values in the linear array the B-channel value of the first three pixels in the image? And as for ordering of pixels in the image: row-major?

valiano
  • 16,433
  • 7
  • 64
  • 79
Tullhead
  • 565
  • 2
  • 7
  • 17

2 Answers2

1

The short answer is : ONNX only supports NCHW

As a reference, please check the section My converted TensorFlow model is slow - why? in onnxruntime.ai. This is the only "official" material that talking about the data format I found so far.

lbai
  • 31
  • 3
0

It's row-major. The format of inputs in ONNX is NCHW. C = number of channels. In this case C=3. The ordering of C (BGR or RGB) depends on the model. For e.g. the YOLO model takes an image 3(RGB) x 416px x 416px.

pranavsharma
  • 1,085
  • 2
  • 10
  • 18
  • Is this answer anywhere in the "official documentation"? Is there any such documentation? I would really like to use onnxruntime, but finding answers like these is not easy... :-( – omatai Jan 18 '21 at 02:48