Skip to content

Commit 832f3dc

Browse files
Update src/onnx_ir/passes/common/common_subexpression_elimination.py
Co-authored-by: Justin Chu <[email protected]> Signed-off-by: Ti-Tai Wang <[email protected]>
1 parent 342add5 commit 832f3dc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/onnx_ir/passes/common/common_subexpression_elimination.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ def _eliminate_common_subexpression(self, graph: ir.Graph, modified: bool) -> bo
8181
# to ensure they are hashable.
8282
value = tuple(value)
8383
elif v.type is ir.AttributeType.TENSOR:
84-
np_value = value.numpy()
85-
if np_value.nbytes > self.size_limit:
84+
if value.size > self.size_limit:
8685
# If the tensor is larger than the size limit, we skip it.
8786
large_tensor = True
8887
break
88+
np_value = value.numpy()
89+
8990
value = (np_value.shape, str(np_value.dtype), np_value.tobytes())
9091
attributes[k] = value
9192

0 commit comments

Comments
 (0)