-
Notifications
You must be signed in to change notification settings - Fork 6.8k
MKL-DNN QuantizedFullyConnectedOp Error #14467
Comments
Hey, this is the MXNet Label Bot. |
@Soonhwan-Kwon Could you provide a simple reproducer? Also, have you ever tried |
@TaoLv We tried your suggestion before,
and it produces error like below /home/ubuntu/anaconda2/envs/mxnet_1_4/lib/python2.7/site-packages/mxnet/symbol/symbol.pyc in get_backend_symbol(self, backend) /home/ubuntu/anaconda2/envs/mxnet_1_4/lib/python2.7/site-packages/mxnet/base.pyc in check_call(ret) MXNetError: [16:35:10] src/c_api/../operator/subgraph/subgraph_property.h:165: Check failed: it != prop_fn_map_.end() SubgraphProperty MKLDNN_FC is not found in SubgraphPropertyRegistry Stack trace returned 10 entries: And we are working on a simple reproducer now, and will reply the code as soon as possible. |
@TaoLv And also quantized_dtype='uint8' produces the same original error message MXNetError: Error in operator quantized_fusedrnn_t134_i2h: [11:40:16] src/operator/quantization/quantized_fully_connected.cc:41: Check failed: !shape_is_none(in_shape->at(0)) QuantizedFullyConnectedOp input data shape must be given |
May I know which version of MXNet you are using? MKL-DNN QFC is merged into master recently. PR here: #14128 |
@TaoLv we tried version of 1.4.0.post0 which was the version before the commit, we'll try the latest version as you mentioned right now, thank you. |
@Soonhwan-Kwon Thanks to reporting the issue. |
Hi. First, I converted and saved a trained fused-rnn model.
And, I loaded the converted symbols and the params file.
When tried simple_bind, it leads to the simple_bind error like below, RuntimeError: simple_bind error. Arguments: Stack trace returned 10 entries: |
@mxnet-label-bot add [MKLDNN, Quantization] |
@Soonhwan-Kwon is there any 0 dimension in the shape of input data? quantized Fullyconnected requires all the dimension of input data are given. |
@Soonhwan-Kwon @Amagong could you provide a mini reproducible case so that we can help to resolve the issue? Maybe you also need to patch #14466 after excluding the 0-dim layers.
|
The PR #14466 is merged. Please sync up the latest MXNet and build again. |
@pengzhao-intel Thank you for the update. I'm rebuilding the MXNet now and @Amagong and I are working on the same project. @ciyongch we excluded embedding layer(which seems has 0 dimension) but has no effect. |
@Soonhwan-Kwon Are you still facing the error of "Check failed: !shape_is_none(in_shape->at(0)) QuantizedFullyConnectedOp input data shape must be given" or "InferShape pass cannot decide shapes for the following arguments (0s means unknown dimensions). Please consider providing them as inputs:" ? |
@ciyongch Thank you for your quick response. I'll check with the newly built version. |
There is currently an "InferShape pass cannot decide shapes for the following arguments (0s means unknown dimensions). Please consider providing them as inputs:" error. |
@Amagong Still the same problem as original one. There's some layer has 0 dimension shape input, which is currently not supported by quantized FullyConnected operator. Please check your current model, and exclude all of this layer, I guess these layers are all comes from first time step. We're going to enhance the error message to help understand which operator is reporting this error. |
can you try
First list should be correspsonding to q_symbol.list_arguments(), Second list should be corresponding to q_symbol.list_outputs(), third should be q_symbol.list_auxiliary_states(). |
@ciyongch @anirudh2290 Thank you for your reply. The error above was due to the use of fused-rnn.
When the comment is removed for the lstm or fused-rnn block, the following UserWarning is occurs.
And, in bind time, the following error occurs.
|
The same error occurs when using RNNCell. |
@anirudh2290 and I tried to debug the issue. When I see the shape of gru_l0l0_begin_state_0 in the graph is (0,1024) and following by quantized_fully_connected, the zero dimension of gru_1010 is not been inferred and we need to dive deeper |
@Amagong Excluding the layers with 0 dimension input will resolve this error. In your samples, the input to
For lstm block:
For gru block, I noticed that there's another '_' in gru naming:
Beside that, please change simple_bind() to bind() since quantized symbol requires quantized_params (int8). while simple_bind() will allocated default params which is in fp32.
Hope this will help your to enable the case :) |
Thanks @ciyongch . Can you please let me know why quantized_fully_connected doesn't handle inferring the data dimension 0 based on the output shape. For example, the following runs fine on fp32:
Expectation is after quantization also it should run fine. But it fails at this check. |
@anirudh2290 The behavior was not changed since the initial version, looks like it will throw many errors in rnn domain. Will figure out the reason and see how to improve this :) |
Thanks @ciyongch I follow your guide, no more errors occur. |
@Amagong Glad to here you're able to run quantization on the sample code. Please let us know if you met other errors/failures in your real case. We're working on enhancement for this limitation.. |
@ciyongch In my case, there is a problem that inference time is slow when using quantization. I generate a network like the sample code above and use the 'quantize_model' function.
And set parameters as below.
I use this structure because input data length is variable. When I run the inference code like above, it runs without any problem, but it is too slow.... |
I'm using 'FusedRNNCell' |
@Amagong The main reason is, you're using quantized model without calibration information. |
@ZhennanQin Thank you for your advice! I'll try the way you told me. |
@Amagong @Soonhwan-Kwon did you get the expected results? |
PR #15031 will fix this issue |
Closing the issue since the PR is merged. Feel free to reopen if you see the issue again. |
Description
When using FusedRNNCell + MKLDNN backend: Graph optimization and Quantization (experimental), it leads to the QuantizedFullyConnectedOp Error like below,
MXNetError: Error in operator quantized_fusedrnn_t134_i2h: [11:40:16] src/operator/quantization/quantized_fully_connected.cc:41: Check failed: !shape_is_none(in_shape->at(0)) QuantizedFullyConnectedOp input data shape must be given
and below is pseudo code for Network Architecture
Quantization Code
net = net.get_backend_symbol('MKLDNN')
Stack trace returned 10 entries:
[bt] (0) /home/ubuntu/anaconda2/envs/mxnet_1_4/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x3e95ea) [0x7faf97f2b5ea]
[bt] (1) /home/ubuntu/anaconda2/envs/mxnet_1_4/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x3e9c11) [0x7faf97f2bc11]
[bt] (2) /home/ubuntu/anaconda2/envs/mxnet_1_4/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x9e351c) [0x7faf9852551c]
[bt] (3) /home/ubuntu/anaconda2/envs/mxnet_1_4/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x2deed5a) [0x7faf9a930d5a]
[bt] (4) /home/ubuntu/anaconda2/envs/mxnet_1_4/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x2df1704) [0x7faf9a933704]
[bt] (5) /home/ubuntu/anaconda2/envs/mxnet_1_4/lib/python2.7/site-packages/mxnet/libmxnet.so(MXSymbolInferShape+0x15ba) [0x7faf9a89e40a]
[bt] (6) /home/ubuntu/anaconda2/envs/mxnet_1_4/lib/python2.7/lib-dynload/../../libffi.so.6(ffi_call_unix64+0x4c) [0x7fafff188ec0]
[bt] (7) /home/ubuntu/anaconda2/envs/mxnet_1_4/lib/python2.7/lib-dynload/../../libffi.so.6(ffi_call+0x22d) [0x7fafff18887d]
[bt] (8) /home/ubuntu/anaconda2/envs/mxnet_1_4/lib/python2.7/lib-dynload/_ctypes.so(_ctypes_callproc+0x4de) [0x7fafff39f8de]
[bt] (9) /home/ubuntu/anaconda2/envs/mxnet_1_4/lib/python2.7/lib-dynload/_ctypes.so(+0x9b31) [0x7fafff395b31]
commit head
mxnet-cu90mkl 1.4.0.post0
The text was updated successfully, but these errors were encountered: