UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer stevekuznicki
Observer
280 Views
Registered: ‎10-15-2009

decent_q v3.1 error with tf model

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?

 

0 Kudos
3 Replies
Xilinx Employee
Xilinx Employee
271 Views
Registered: ‎05-24-2019

Re: decent_q v3.1 error with tf model

@stevekuznicki

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!

--Quenton

 

0 Kudos
Observer stevekuznicki
Observer
205 Views
Registered: ‎10-15-2009

Re: decent_q v3.1 error with tf model

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

https://github.com/onnx/onnx/blob/master/docs/Operators.md#Conv

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 ...].

 

0 Kudos
Xilinx Employee
Xilinx Employee
172 Views
Registered: ‎05-24-2019

Re: decent_q v3.1 error with tf model

@stevekuznicki 

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:

 

Capture.PNG

 

--Quenton

0 Kudos