abergeron 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_r346909893
 
 

 ##########
 File path: python/tvm/relay/op/_transform.py
 ##########
 @@ -304,6 +305,31 @@ def compute_argwhere(attrs, inputs, output_type, _):
     new_output_type = tvm.relay.ty.TensorType(output_shape, "int32")
     return [topi.argwhere(new_output_type, inputs[0])]
 
+@_reg.register_compute("strided_set")
+def compute_strided_set(attrs, inputs, output_type, _):
+    """Compute definition of strided_set"""
+    begin = attrs.begin
+    end = attrs.end
+    strides = attrs.strides
+    n = len(inputs[0].shape)
+    ls = len(strides)
+    if ls < n:
+        strides = list(strides)
+        strides[ls:] = [1] * (n - ls)
+    lb = len(begin)
+    if lb < n:
+        begin = list(begin)
+        for i in range(lb, n):
+            begin.append(0 if strides[i] >= 0 else inputs.shape[i])
 
 Review comment:
   This is a bit different because the value to append might be different at 
each index.  It depends on the stride for that index.  I'm not sure how to 
shorten that.

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