yongwww commented on a change in pull request #4303: [TOPI][Relay][OP] Add a 
strided_set operation.
URL: https://github.com/apache/incubator-tvm/pull/4303#discussion_r351039468
 
 

 ##########
 File path: topi/tests/python/test_topi_transform.py
 ##########
 @@ -342,6 +342,52 @@ def check_device(device):
     for device in ["llvm", "opencl", "sdaccel", "aocl_sw_emu"]:
         check_device(device)
 
+def verify_strided_set(in_shape, v_shape, begin, end, strides=None):
+    A = tvm.placeholder(shape=in_shape, name="A")
+    V = tvm.placeholder(shape=v_shape, name="V")
+    b = tvm.placeholder(shape=(len(begin),), name="b", dtype='int32')
+    e = tvm.placeholder(shape=(len(end),), name="e", dtype='int32')
+    if strides is not None:
+        st = tvm.placeholder(shape=(len(strides),), name="st", dtype='int32')
+        B = topi.strided_set(A, V, b, e, st) + 1
+    else:
+        B = topi.strided_set(A, V, b, e) + 1
+
+    def check_device(device):
+        ctx = tvm.context(device, 0)
+        if not ctx.exist:
+            print("Skip because %s is not enabled" % device)
+            return
+        print("Running on target: %s" % device)
+        with tvm.target.create(device):
+            s = topi.generic.schedule_injective(B)
+
+        if strides is not None:
+            foo = tvm.build(s, [A, V, b, e, st, B], device, name="stride_set")
+            s_np = np.asarray(strides).astype('int32')
+            s_nd = tvm.nd.array(s_np, ctx)
+        else:
+            foo = tvm.build(s, [A, V, b, e, B], device, name="stride_set")
+        x_np = np.random.uniform(size=in_shape).astype(A.dtype)
+        v_np = np.random.uniform(size=v_shape).astype(V.dtype)
+        b_np = np.asarray(begin).astype('int32')
+        e_np = np.asarray(end).astype('int32')
+        out_npy = topi.testing.strided_set_python(
+            x_np, v_np, begin, end, strides) + 1
 
 Review comment:
   just for curiosity,  why is `+1` needed here?

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to