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

[RELAY,TOPI] Add scatter_nd op #6854

Merged
merged 13 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
formatting
  • Loading branch information
tkonolige committed Nov 11, 2020
commit 0593227560dd744f8c1e3fdacea0df043dec3705
1 change: 1 addition & 0 deletions python/tvm/relay/op/strategy/x86.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ def bitserial_dense_strategy_cpu(attrs, inputs, out_type, target):
)
return strategy


@scatter_nd_strategy.register("cpu")
def scatter_nd_strategy_cpu(attrs, inputs, out_type, target):
"""scatter_nd x86 strategy"""
Expand Down
7 changes: 4 additions & 3 deletions python/tvm/topi/scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,10 @@ def _verify_scatter_nd_inputs(data, indices, shape):
)
for i in range(mdim, len(shape)):
data_ind = i - mdim + len(indices.shape) - 1
assert (
data.shape[data_ind] == shape[i]
), f"Dimension of data[{data_ind}] ({data.shape[data_ind]}) must equal dimension of out_shape[{i}] ({shape[i]})."
assert data.shape[data_ind] == shape[i], (
f"Dimension of data[{data_ind}] ({data.shape[data_ind]}) must equal dimension "
f"of out_shape[{i}] ({shape[i]})."
)

assert (
"int" in indices.dtype
Expand Down
1 change: 1 addition & 0 deletions python/tvm/topi/x86/scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def scatter_nd(data, indices, shape):
_verify_scatter_nd_inputs(data, indices, shape)

def gen_ir(data_ptr, indices_ptr, out_ptr):
# pylint: disable=invalid-name
ib = tvm.tir.ir_builder.create()

data = ib.buffer_ptr(data_ptr)
Expand Down
2 changes: 1 addition & 1 deletion tests/python/topi/python/test_topi_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def check_scatter_nd(data, indices, shape, out):
out = np.array([[[[0, 0], [1, 2]], [[0, 0], [3, 4]]], [[[0, 0], [0, 0]], [[0, 0], [0, 0]]]])
check_scatter_nd(data, indices, shape, out)

data = np.reshape(np.arange(1560*3), (3, 1560)).astype("float32")
data = np.reshape(np.arange(1560 * 3), (3, 1560)).astype("float32")
indices = np.array([[1, 0, 0]])
shape = (2, 1560)
out = np.zeros(shape).astype("float32")
Expand Down