-
The ONNX tensor dimension ordering is: (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width. I have an application where I require the output C code produced by onnx2c to have the tensors ordered as: N x H x W x C, (and corresponding weights to be ordered as (M x kH x kW x C ) instead of (M x C x kH x kW)). Do you have a recommendation as to how to implement this and what the difficulty would be? Many thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I don't see an easy solution to this. There is the ONNX operand Most, if not all operands defined in ONNX that assign semantics to the dimensions use the depth-row-column ordering. If the input ONNX could define row-column-depth order, onnx2c would of course be (relatively) easily upgraded to match. The bigger part of the work would be to introduce this idea to ONNX. And possibly Tensorflow/Pytorch/... - I did not check, does some frameworks allow for row-column-depth already? One last idea I have is to use the A slightly related question: why do you need this order? If it is for speedup of computation using SIMD vectors, would scatter loading of the weights into a SIMD register help? And is there some way of improving the onnx2c generated code to allow for this to be done automatically? |
Beta Was this translation helpful? Give feedback.
I don't see an easy solution to this.
There is the ONNX operand
DepthToSpace
that does this required permutation, but at the last stage only. (And unfortunately this operand is not (yet) implemented in onnx2c...) The computation in your net would still be done in depth-row-column order, so the weights would have to match.Most, if not all operands defined in ONNX that assign semantics to the dimensions use the depth-row-column ordering. If the input ONNX could define row-column-depth order, onnx2c would of course be (relatively) easily upgraded to match. The bigger part of the work would be to introduce this idea to ONNX. And possibly Tensorflow/Pytorch/... - I did not check, does some fr…