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

SpaceToBatchND error: only support same blocksize at different dims #790

Closed
carlosgalvezp opened this issue Feb 6, 2020 · 5 comments
Closed
Labels
bug An unexpected problem or unintended behavior

Comments

@carlosgalvezp
Copy link

carlosgalvezp commented Feb 6, 2020

Hi,

We are trying to convert our frozen network (as protobuf) into ONNX. The tf2onnx tool is called like this:

python -m tf2onnx.convert --input model.pb --inputs image:0 --outputs output1:0,output2:0 --opset 11 --verbose

However the tool complains with the following message:

2020-02-06 11:47:47,438 - INFO - tf2onnx.tfonnx: Using tensorflow=1.14.0, onnx=1.6.0, tf2onnx=1.5.4/ee756a
2020-02-06 11:47:47,438 - INFO - tf2onnx.tfonnx: Using opset <onnx, 11>
2020-02-06 11:47:47,994 - VERBOSE - tf2onnx.tfonnx: Mapping TF node to ONNX node(s)
2020-02-06 11:47:48,127 - ERROR - tf2onnx.tfonnx: Failed to convert node Main_conv_dilated/SpaceToBatchND
OP=SpaceToDepth
Name=Main_conv_dilated/SpaceToBatchND
Inputs:
	pad:0=Pad, [1, 32, 80, 124], 1
	Main_conv_dilated/SpaceToBatchND/block_shape:0=Const, [3], 6
	Main_conv_dilated/SpaceToBatchND/paddings:0=Const, [3, 2], 6
Outpus:
	Main_conv_dilated/SpaceToBatchND:0=[4, 32, 40, 62], 1
Traceback (most recent call last):
  File "venv/lib/python3.6/site-packages/tf2onnx/tfonnx.py", line 354, in tensorflow_onnx_mapping
    func(g, node, **kwargs)
  File "venv/lib/python3.6/site-packages/tf2onnx/onnx_opset/tensor.py", line 1285, in version_1
    "only support same blocksize at different dims")
  File "venv/lib/python3.6/site-packages/tf2onnx/utils.py", line 291, in make_sure
    raise ValueError("make_sure failure: " + error_msg % args)
ValueError: make_sure failure: only support same blocksize at different dims

This stems from creating a Conv2D layer as follows:

        self._conv = tf.compat.v2.keras.layers.Conv2D(
            filters=32,
            kernel_size=3,
            dilation_rate=(2, 2),
            use_bias=True,
            padding='valid',
            name='Main_conv_dilated',
            data_format='channels_first')

Is this expected?
Thanks!

@jignparm
Copy link
Contributor

jignparm commented Feb 6, 2020

This operator is being updated, so the error message should disappear very shortly.

ONNX does not support SpacetoBatchND directly, so it has be composed using a combination of other primitive operators. The current implementation only supports [n, n] block_shape, but will be updated to support arbitrary sized block_shapes and >4D tensors.

@jignparm
Copy link
Contributor

This should be fixed by #797.

Can you check if you're still seeing a conversion failure?

@jignparm jignparm added the bug An unexpected problem or unintended behavior label Feb 11, 2020
@carlosgalvezp
Copy link
Author

Hi @jignparm ! Thanks a lot for the fix. It seems to work, since I now get a different error in further layers. I can open up a different bug for those.

@jignparm
Copy link
Contributor

Thanks for the verification. I'll close this out after merging.

For the remaining errors, one option would be to share the model (assuming privacy is not a concern), otherwise another bug works as well.

@carlosgalvezp
Copy link
Author

Great! Unfortunately I'm not able to share the model so I'll put up another ticket for the other issue. Thanks a lot for the quick help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants