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

add subgraph detection for convoluation with dilations > 1 #18

Closed
qigtang opened this issue May 17, 2018 · 7 comments
Closed

add subgraph detection for convoluation with dilations > 1 #18

qigtang opened this issue May 17, 2018 · 7 comments

Comments

@qigtang
Copy link

qigtang commented May 17, 2018

Tensorflow conv2d with dilations > 1 is in a graph with

SpaceToBatchND -> conv -> BatchtoSpaceND etc.

SpaceToBatchND and BatchtoSpaceND are not supported in onnx, should combine this subgraph to normal conv2d with dilation > 1 operator.

@guschmue
Copy link
Contributor

not sure if I interpret this correctly:
you say that for example conv2d(dilations=[1,3,3,1]) will compose the graph as SpaceToBatchND -> conv -> BatchtoSpaceND since tf.conv2d has no native support conv2d with dilations ?

I think this has changed, just tested with 1.8 and it has only conv2d:
https://github.com/onnx/tensorflow-onnx/blob/master/tests/test_backend.py#L269

Can't find it in the tensorflow release notes, but I think I recall something after tf-1.5.

@qigtang
Copy link
Author

qigtang commented Jun 13, 2018

Haven't tried recent latest tensorflow version. We decided to switch to pytorch for our training instead.

@sulc
Copy link

sulc commented Apr 30, 2019

Hi,
I would also appreciate the support for SpaceToBatchND, and I believe this is still an issue with newer versions of TF:
I'm working with TF 1.12, and this opp is still used by tf.contrib.layers.conv2d with dilation (i.e. with parameter rate>1) - tf2onnx crashes with:
ValueError: tensorflow op SpaceToBatchND is not supported

Looking deeper into the layer definition, I can see _WithSpaceToBatch being used in Convolution in nn_ops.py..

@nbcsm
Copy link
Collaborator

nbcsm commented Apr 30, 2019

SpaceToBatchND is supported via #472
please give a try with latest mater branch.

@sulc
Copy link

sulc commented Apr 30, 2019

Thank you! My bad - indeed it's supported by the latest master - sorry, I missed this update..

Unfortunately, I'm getting another error related to SpaceToBatchND:
node model/Conv_1/SpaceToBatchND: exception get tensor value: model/Conv_1/concat must be Const
I suppose it cannot handle input with variable size..? (It's a detection network, where images may have different resolutions).
I'm using the latest onnx, but onnx.defs.has("DynamicSlice") is False (not sure if it's relevant)..

@vadimkantorov
Copy link

@guschmue This is still an issue for old TensorFlow checkpoints, like NVidia OpenSeq2Seq wav2letter model. Currently it exports a SpaceToBatchND + Conv + BatchToSpaceND subgraph (indeed with a dynamic crop issue #571, fix in #635 ?).

The corresponding TfLite transform is in https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/toco/graph_transformations/identify_dilated_conv.cc

@anmolduainter
Copy link

I want to convert tensorflow model (tf version: 1.12) where dilation rate > 1 in many convs into ONNX. I am unable to do so as there is Space To Batch error. Can anyone help me to resolve this issue. Desired ONNX version (1.3.0).

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

No branches or pull requests

6 participants