08-16-2019 02:01 PM
Still having issue (but different issues) with v3.1 vs. v3.0 with a Resnet50 TF model converted using ONNX.
The error we get is complaining about the shape used in the batchnorm node:
2019-08-16 16:11:00.909049: F tensorflow/contrib/decent_q/utils/fold_batch_norms.cc:181] Unsupported data format `NCHW` for node `convolution`. Please convert it to `NHWC` data format and try again. `NCHW` data format will be supported in future version.
./decent_q.sh: line 13: 2887 Aborted (core dumped) decent_q quantize --input_frozen_graph rntf3.pb --input_nodes input_1 --input_shapes 1,3,224,224 --output_nodes fc1000_softmax --input_fn resnet_v1_50_input_fn.calib_input --method 1 --gpu 0 --skip_check 1 --calib_iter 20 --output_dir ml_q_results --ignore_nodes Pad_4,Pad_14,Pad_27,Pad_46
Is there something we can do here? Some option to accept NCHW?
08-16-2019 02:20 PM - edited 08-16-2019 02:21 PM
Not really, given that the message is coming from DECENT_Q. I am guessing that you are using this format for each of your BN layers. Can you change the shape in the source framework, retrain and reattempt the ONNX TF export? Another suggestion might be to export the .pb file as .pbtxt file and edit each NCHW instance to NHWC. The weights will be incorrectly ordered, and but perhaps you can at least do a full pass through DNNDK and ensure that there are no other errors before proceeding to the next stage.
Attached is a code snippet I have used in the past to convert back and forth. I don't recall what state I left this in, but it did work for me at one point. I can't take credit for the code either!
08-19-2019 09:45 AM
So standard models are not supported - but does Xilinx have plans on supporting a standard (ONNX) format since they are not supporting transposed shapes? Do you know if any of the ONNX models from ONNX model zoo work with Xilinx’s DNNDK?
The data format in ONNX is NCHW.
Here is the spec for ONNX Conv operator
Inputs (2 - 3)
X : T
Input data tensor from previous layer; has size (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. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 ... x Dn). Optionally, if dimension denotation is in effect, the operation expects input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].
08-28-2019 01:20 PM
For what it is worth, I thought that you might be interested to hear that I have a TF model that was converted from Pytorch to ONNX to TF and the CONV operators in the resulting PB file are actually NHWC: