onnx-tensorflow icon indicating copy to clipboard operation
onnx-tensorflow copied to clipboard

RuntimeError: GRU with linear_before_reset is not supported in Tensorflow.

Open tulasiram58827 opened this issue 4 years ago • 10 comments
trafficstars

Please find the error log:

RuntimeError: in user code:

    /usr/local/lib/python3.6/dist-packages/onnx_tf/backend_tf_module.py:98 __call__  *
        output_ops = self.backend._onnx_node_to_tensorflow_op(onnx_node,
    /usr/local/lib/python3.6/dist-packages/onnx_tf/backend.py:289 _onnx_node_to_tensorflow_op  *
        return handler.handle(node, tensor_dict=tensor_dict, strict=strict)
    /usr/local/lib/python3.6/dist-packages/onnx_tf/handlers/handler.py:58 handle  *
        cls.args_check(node, **kwargs)
    /usr/local/lib/python3.6/dist-packages/onnx_tf/handlers/backend/gru.py:68 args_check  *
        exception.OP_UNSUPPORTED_EXCEPT("GRU with linear_before_reset",
    /usr/local/lib/python3.6/dist-packages/onnx_tf/common/exception.py:50 __call__  *
        raise self._func(self.get_message(op, framework))

    RuntimeError: GRU with linear_before_reset is not supported in Tensorflow.

ONNX Version used - 1.8 ONNX-TF Version Used - 1.7

tulasiram58827 avatar Jan 14 '21 11:01 tulasiram58827

This is a known limitation in conversion using Tensorflow APIs. The support status for onnx-tf 1.7 can be found here, https://github.com/onnx/onnx-tensorflow/blob/master/doc/support_status_v1_7_0.md

chinhuang007 avatar Jan 14 '21 17:01 chinhuang007

Ok Are there any alternatives to bypass this error

tulasiram58827 avatar Jan 15 '21 03:01 tulasiram58827

Change the GRU linear_before_reset to 0 or remove the attribute in onnx model. Contribution to support of this attribute is highly welcome!

chinhuang007 avatar Jan 15 '21 19:01 chinhuang007

@chinhuang007, force the attribure linear_before_reset to 0 seems to cause some dimension error, is there any plan to support this feature, I saw tf.keras.layers.GRU has the argument reset_after=false, but I failed after trying.

TingfengTang avatar Dec 13 '21 13:12 TingfengTang

any fix now? i still get the same error

fancoltran avatar Jun 15 '22 08:06 fancoltran

I had the same problem

LXP-Never avatar Sep 24 '22 14:09 LXP-Never

I had the same problem

yinzeq avatar Sep 27 '22 09:09 yinzeq

I didn't experience any change in dimensions when forcing linear_before_reset to 0, but the values are definitely incorrect. It looks like there's a PR from years ago that solved this issue but was left to the wayside while waiting to update to tf2.0: https://github.com/onnx/onnx-tensorflow/pull/452 would love to see it updated as needed and implemented as it appears to be the only thing blocking pytorch -> tf conversion with GRUs at this point

nukelash avatar Sep 29 '22 16:09 nukelash

@all, did anyone find a way to resolve this issue? Any suggestions would help greatly. Thanks

balaji-haridass avatar Dec 12 '22 04:12 balaji-haridass

I think I have implemented it, but I don't know if it works correctly because I don't have enough ONNX files for testing.

It's a topic that's over a year old, so no one will be interested in it.

https://github.com/PINTO0309/onnx2tf/blob/main/onnx2tf/ops/GRU.py

PINTO0309 avatar Sep 02 '23 02:09 PINTO0309