diff --git a/README.md b/README.md index d3c027e6..79de8377 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Self-Created Tools to convert ONNX files (NCHW) to TensorFlow format (NHWC). The 8. Calculation error due to scaling up or down by specifying a `scale` when resizing images The above differences often cannot be dealt with by simply converting the model in a straightforward manner. Therefore, you need to replace the model yourself in advance with an operation that is less prone to errors. +- [x] TFLite does not support `TrueDiv`(INT), so `TrueDiv` is avoided if possible. - [x] Implement the `Resize` process for the 5D tensor. - [x] Add process to replace `Asin` with `pseudo-Asin`. - [x] Add process to replace `Acos` with `pseudo-Acos`. @@ -70,7 +71,7 @@ Video speed is adjusted approximately 50 times slower than actual speed. $ docker run --rm -it \ -v `pwd`:/workdir \ -w /workdir \ -ghcr.io/pinto0309/onnx2tf:1.0.25 +ghcr.io/pinto0309/onnx2tf:1.0.26 or diff --git a/onnx2tf/__init__.py b/onnx2tf/__init__.py index e667fac1..c517b432 100644 --- a/onnx2tf/__init__.py +++ b/onnx2tf/__init__.py @@ -1,3 +1,3 @@ from onnx2tf.onnx2tf import convert, main -__version__ = '1.0.25' +__version__ = '1.0.26' diff --git a/onnx2tf/ops/Div.py b/onnx2tf/ops/Div.py index a1b74b14..267ba69b 100644 --- a/onnx2tf/ops/Div.py +++ b/onnx2tf/ops/Div.py @@ -94,13 +94,18 @@ def make_node( const_or_var_2=input_tensor_2, ) + # TFLite does not support TrueDiv(INT), so TrueDiv is avoided if possible + x_is_integer = input_tensor_1.dtype in target_cast_dtype + y_is_integer = input_tensor_2.dtype in target_cast_dtype + xy_is_integer = x_is_integer and y_is_integer + divided_tensor = tf.math.divide( - x=input_tensor_1, - y=input_tensor_2, + x=input_tensor_1 if not xy_is_integer else tf.cast(input_tensor_1, dtype=tf.float32), + y=input_tensor_2 if not xy_is_integer else tf.cast(input_tensor_2, dtype=tf.float32), name=graph_node.name, ) - if dtype in target_cast_dtype: + if xy_is_integer and dtype in target_cast_dtype: divided_tensor = tf.cast(divided_tensor, dtype=dtype) tf_layers_dict[graph_node_output.name]['tf_node'] = divided_tensor