notoraptor commented on a change in pull request #6030:
URL: https://github.com/apache/incubator-tvm/pull/6030#discussion_r452520170
##########
File path: tests/python/relay/test_op_level3.py
##########
@@ -811,6 +811,51 @@ def verify_scatter(dshape, ishape, axis=0):
verify_scatter((16, 16, 4, 5), (16, 16, 4, 5), 3)
+def test_scatter_add():
+
+ def ref_scatter_add(data, indices, updates, axis=0):
+ output = np.copy(data)
+ for index in np.ndindex(*indices.shape):
+ new_index = list(index)
+ new_index[axis] = indices[index]
+ output[tuple(new_index)] += updates[index]
+ return output
+
+ def verify_scatter_add(dshape, ishape, axis=0):
+ d = relay.var("d", relay.TensorType(dshape, "float32"))
+ i = relay.var("i", relay.TensorType(ishape, "int64"))
+ u = relay.var("u", relay.TensorType(ishape, "float32"))
+ z = relay.op.scatter_add(d, i, u, axis)
+
+ func = relay.Function([d, i, u], z)
+
+ data_np = np.random.uniform(size=dshape).astype("float32")
+ updates_np = np.random.uniform(size=ishape).astype("float32")
+ indices_np = np.random.randint(-dshape[axis], dshape[axis] - 1,
ishape).astype("int64")
+
+ ref_res = ref_scatter_add(data_np, indices_np, updates_np, axis)
+ # TODO(mbrookhart): expand testing when adding more backend schedules
Review comment:
Hi! Unfortunately, no! For the moment, I just need it on CPU ^^ !
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]