Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FRONTEND][TENSORFLOW] Some bug fixes for tensorflow NCHW data_format #3514

Merged
merged 1 commit into from
Jul 16, 2019

Conversation

vv1133
Copy link
Contributor

@vv1133 vv1133 commented Jul 9, 2019

update #3008

  • fix tensorflow depthwise_conv2d nchw
  • fix tensorflow biasadd nchw
  • add tensorflow tests: depthwise_conv2d, biasadd

@vv1133
Copy link
Contributor Author

vv1133 commented Jul 9, 2019

Please review @srkreddy1238 @Laurawly @Huyuwei

@u99127
Copy link
Contributor

u99127 commented Jul 13, 2019

Can you please explain further what the bug is and how you are proposing to fix it ?

@vv1133
Copy link
Contributor Author

vv1133 commented Jul 14, 2019

Can you please explain further what the bug is and how you are proposing to fix it ?

  • TensorFlow bias_add with data_format NCHW should reshape inputs[1] to [c, 1, 1] first like below.
  if attr['data_format'] == 'NCHW':
      bias_shape = attr['_input_shapes'][inputs[1]]
      bias = _op.reshape(inputs[1], newshape=tuple([bias_shape, 1, 1]))
  else:
      bias = inputs[1]
  return _op.add(inputs[0], bias)
  • The previous code of transposing weight with data_format NCHW in frotend/tensorflow.py function _conv:
    tmp_shape = [tmp_shape[ii] for ii in (3, 2, 0, 1)]
    inputs[1] = _sym.transpose(inputs[1], axes=(3, 2, 0, 1))

TensorFlow DepthwiseConv2d weights shape: [H, W, C, DEPTH_MULT]
But refer to "./nnvm/src/top/nn/convolution.cc: Conv2DInferShape" weights_shape should transpose to [C, DEPTH_MULT, H, W]. So the transpose shape should be [2, 3, 0, 1] when the opname is "depthwise".

Copy link
Contributor

@srkreddy1238 srkreddy1238 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vv1133 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants