Skip to content

Commit

Permalink
Fixed the broadcast processing when x_scale is 1D 1Elem
Browse files Browse the repository at this point in the history
  • Loading branch information
PINTO0309 committed Jan 22, 2025
1 parent a3b9ec0 commit 068a9c2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,15 @@ 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.26.6
ghcr.io/pinto0309/onnx2tf:1.26.7

or

# Authentication is not required for pulls from Docker Hub.
docker run --rm -it \
-v `pwd`:/workdir \
-w /workdir \
docker.io/pinto0309/onnx2tf:1.26.6
docker.io/pinto0309/onnx2tf:1.26.7

or

Expand Down
2 changes: 1 addition & 1 deletion onnx2tf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from onnx2tf.onnx2tf import convert, main

__version__ = '1.26.6'
__version__ = '1.26.7'
4 changes: 3 additions & 1 deletion onnx2tf/ops/DequantizeLinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ def make_node(

# Reshape process is needed for per-axis dequantization
# when scale is a 1-D tensor
if x_scale_rank == 1:
if x_scale_rank == 1 and x_scale_shape[0] != 1:
shape_broadcast = list([1 for _ in range(axis)] + [input_tensor_shape[axis]] + [1 for _ in range(axis + 1, input_tensor_rank)])
x_scale = tf.reshape(
tensor=x_scale,
shape=shape_broadcast,
)
elif x_scale_rank == 1 and x_scale_shape[0] == 1:
shape_broadcast = [1 for i in range(input_tensor_rank)]

subed_tensor = input_tensor
if len(graph_node.inputs) >= 3 and input_tensor.dtype != tf.int32:
Expand Down

0 comments on commit 068a9c2

Please sign in to comment.