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

BatchToSpaceND: crops parameter need not be const? #571

Closed
vadimkantorov opened this issue Jun 5, 2019 · 6 comments
Closed

BatchToSpaceND: crops parameter need not be const? #571

vadimkantorov opened this issue Jun 5, 2019 · 6 comments
Labels
need investigation Need investigation

Comments

@vadimkantorov
Copy link

vadimkantorov commented Jun 5, 2019

I'm trying to convert the OpenSeq2Seq's wav2letter model checkpoints from TensorFlow to ONNX.

It contains BatchToSpaceND ops. In this model the crops argument is Identity, not Const.

However, tfonnx requires crops to be Const.

Failed to convert node import/ForwardPass/w2l_encoder/conv71/SpaceToBatchND
OP=SpaceToDepth
Name=import/ForwardPass/w2l_encoder/conv71/SpaceToBatchND
Inputs:
        Dropout__40:0=Dropout, [64, -1, 768], 10
        import/ForwardPass/w2l_encoder/conv71/SpaceToBatchND/block_shape:0=Const, [1], 6
        import/ForwardPass/w2l_encoder/conv71/concat:0=Identity, [1, 2], 6
Outpus:
        import/ForwardPass/w2l_encoder/conv71/SpaceToBatchND:0=[128, -1, 768], 10
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/tf2onnx/tfonnx.py", line 574, in tensorflow_onnx_mapping
    func(g, node, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tf2onnx/onnx_opset/tensor.py", line 915, in version_4
    paddings = node.inputs[2].get_tensor_value()
  File "/usr/local/lib/python3.6/dist-packages/tf2onnx/graph.py", line 239, in get_tensor_value
    raise ValueError("get tensor value: {} must be Const".format(self.name))
ValueError: get tensor value: import/ForwardPass/w2l_encoder/conv71/concat must be Const
Failed to convert node import/ForwardPass/w2l_encoder/conv71/BatchToSpaceND
OP=DepthToSpace
Name=import/ForwardPass/w2l_encoder/conv71/BatchToSpaceND
Inputs:
        import/ForwardPass/w2l_encoder/conv71/conv1d/Squeeze:0=Squeeze, [128, -1, 896], 10
        import/ForwardPass/w2l_encoder/conv71/BatchToSpaceND/block_shape:0=Const, [1], 6
        import/ForwardPass/w2l_encoder/conv71/concat_1:0=Identity, [1, 2], 6
Outpus:
        import/ForwardPass/w2l_encoder/conv71/BatchToSpaceND:0=[64, -1, 896], 10
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/tf2onnx/tfonnx.py", line 574, in tensorflow_onnx_mapping
    func(g, node, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tf2onnx/onnx_opset/tensor.py", line 859, in version_4
    cls._convert_since_4(ctx, node, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tf2onnx/onnx_opset/tensor.py", line 871, in _convert_since_4
    crops = node.inputs[2].get_tensor_value()
  File "/usr/local/lib/python3.6/dist-packages/tf2onnx/graph.py", line 239, in get_tensor_value
    raise ValueError("get tensor value: {} must be Const".format(self.name))
ValueError: get tensor value: import/ForwardPass/w2l_encoder/conv71/concat_1 must be Const

` `
@zhijxu-MS
Copy link
Collaborator

onnx padhttps://github.com/onnx/onnx/blob/master/docs/Operators.md#Pad need padding to an attribute, namely a const.

@vadimkantorov the input of identity is a const or not? if yes, you could hack the code to specify its value, also you could wait for our tensorflow_const_folding feature.

@zhijxu-MS zhijxu-MS added the pending on user response Waiting for more information or validation from user label Jun 10, 2019
@vadimkantorov
Copy link
Author

I think it is not const. TensorFlow exports it as applying a shape op and then doing a much of slices and manipulation to it.

@zhijxu-MS
Copy link
Collaborator

sorry, I located the wrong code line, there is nothing about pad.

just looked at the conversion logic of BatchToSpaceND, it looks like we need enhace it, will go back to you later.

@zhijxu-MS zhijxu-MS added need investigation Need investigation and removed pending on user response Waiting for more information or validation from user labels Jun 10, 2019
@vadimkantorov
Copy link
Author

Then there is another question of folding the BatchToSpace + Conv + SpaceToBatch TensorFlow's pattern to a dilated conv.

@vadimkantorov
Copy link
Author

Fix incoming in #635 ?

@fatcat-z
Copy link
Collaborator

The related PR was closed because of the lack of CLA, close it for now.

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

No branches or pull requests

3 participants