You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "vvchernov (via GitHub)" <gi...@apache.org> on 2023/01/30 05:55:38 UTC

[GitHub] [tvm] vvchernov opened a new pull request, #13865: [ONNX] Support SequenceErase op

vvchernov opened a new pull request, #13865:
URL: https://github.com/apache/tvm/pull/13865

   Support SequenceErase op in ONNX front-end and its test in CI


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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] tvm-bot commented on pull request #13865: [ONNX] Support SequenceErase op

Posted by "tvm-bot (via GitHub)" <gi...@apache.org>.
tvm-bot commented on PR #13865:
URL: https://github.com/apache/tvm/pull/13865#issuecomment-1408037039

   <!---bot-comment-->
   
   Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
   
   <!--bot-comment-ccs-start-->
    * cc @KJlaccHoeUM9l, @ehsanmok <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
   
   <sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>


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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] KJlaccHoeUM9l commented on a diff in pull request #13865: [ONNX] Support SequenceErase op

Posted by "KJlaccHoeUM9l (via GitHub)" <gi...@apache.org>.
KJlaccHoeUM9l commented on code in PR #13865:
URL: https://github.com/apache/tvm/pull/13865#discussion_r1090424116


##########
python/tvm/relay/frontend/onnx.py:
##########
@@ -6148,13 +6148,35 @@ def _impl_v11(cls, inputs, attr, params):
         return _expr.Tuple(inputs)
 
 
-class SequenceLength(OnnxOpConverter):
-    """Operator converter for sequence length op."""
+class SequenceErase(OnnxOpConverter):
+    """Operator converter for sequence erase op."""
 
     @classmethod
     def _impl_v11(cls, inputs, attr, params):
-        # Get length of input sequence
-        return _expr.const(len(inputs[0]), dtype="int64")
+        # Erase tensor from sequence on specified position
+        input_sequence = inputs[0]
+
+        if len(inputs) == 2:
+            position = inputs[1]
+            # Non constant position is not supported.
+            if isinstance(position, _expr.Constant):
+                position = position.data.numpy()
+            elif position.name_hint in params:
+                position = params[position.name_hint].numpy()
+            else:
+                raise NotImplementedError("Position must be a constant.")
+        else:
+            position = -1
+
+        if position < 0:
+            position = len(input_sequence) + position + 1
+        # Convert sequence to a list, insert tensors before erased, and repackage as Tuple.
+        tensor_list = [input_sequence[i] for i in range(position)]

Review Comment:
   Looks like it could be simplified like this:
   ```Python
   tensor_list = [input_sequence[i] for i in range(len(input_sequence)) if i != position]
   ```
   This `if` will not affect performance in any way, because everything will be done at compile time. However, this code looks more readable.



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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] vvchernov commented on a diff in pull request #13865: [ONNX] Support SequenceErase op

Posted by "vvchernov (via GitHub)" <gi...@apache.org>.
vvchernov commented on code in PR #13865:
URL: https://github.com/apache/tvm/pull/13865#discussion_r1090440845


##########
python/tvm/relay/frontend/onnx.py:
##########
@@ -6148,13 +6148,35 @@ def _impl_v11(cls, inputs, attr, params):
         return _expr.Tuple(inputs)
 
 
-class SequenceLength(OnnxOpConverter):
-    """Operator converter for sequence length op."""
+class SequenceErase(OnnxOpConverter):
+    """Operator converter for sequence erase op."""
 
     @classmethod
     def _impl_v11(cls, inputs, attr, params):
-        # Get length of input sequence
-        return _expr.const(len(inputs[0]), dtype="int64")
+        # Erase tensor from sequence on specified position
+        input_sequence = inputs[0]
+
+        if len(inputs) == 2:
+            position = inputs[1]
+            # Non constant position is not supported.
+            if isinstance(position, _expr.Constant):
+                position = position.data.numpy()
+            elif position.name_hint in params:
+                position = params[position.name_hint].numpy()
+            else:
+                raise NotImplementedError("Position must be a constant.")
+        else:
+            position = -1
+
+        if position < 0:
+            position = len(input_sequence) + position + 1
+        # Convert sequence to a list, insert tensors before erased, and repackage as Tuple.
+        tensor_list = [input_sequence[i] for i in range(position)]

Review Comment:
   done



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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] echuraev merged pull request #13865: [ONNX] Support SequenceErase op

Posted by "echuraev (via GitHub)" <gi...@apache.org>.
echuraev merged PR #13865:
URL: https://github.com/apache/tvm/pull/13865


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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org