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

[FIX][topi.scatter_nd] fixed shape equality assert by using analyzer to prove equality #17537

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/tvm/arith/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def int_set(self, expr, dom_map):
expr : PrimExpr
The expression.

dom_map : Dict[Var, tvm.arith.IntSet]
dom_map : Dict[tvm.tir.Var, tvm.arith.IntSet]
The domain for variables to be relaxed.

Returns
Expand Down
5 changes: 4 additions & 1 deletion python/tvm/topi/scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
"""ScatterND operator"""
from tvm import te, tir # hide redefinition of min and max
from tvm.tir import expr
from tvm.arith.analyzer import Analyzer


def _verify_scatter_nd_inputs(data, indices, updates):
analyzer = Analyzer()
mdim = int(indices.shape[0])
assert mdim <= len(data.shape), (
f"The first dimension of the indices ({mdim}) must be less than or equal to "
Expand All @@ -29,7 +31,8 @@ def _verify_scatter_nd_inputs(data, indices, updates):
for i in range(len(indices.shape) - 1):
if isinstance(indices.shape[i + 1], expr.Var) or isinstance(updates.shape[i], expr.Var):
continue
assert indices.shape[i + 1] == updates.shape[i], (

assert analyzer.can_prove_equal(indices.shape[i + 1], updates.shape[i]), (
f"Dimension of indices[{i+1}] ({indices.shape[i+1]}) must equal dimension of "
f"updates[{i}] ({updates.shape[i]})."
)
Expand Down
Loading