You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "jikechao (via GitHub)" <gi...@apache.org> on 2023/09/09 02:10:58 UTC

[GitHub] [tvm] jikechao opened a new pull request, #15715: [Relay][Bugfix] Fix the wrong implementation about operator Threshold in oneflow

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

   The implementation logic of Threshold in oneflow is as follows:
   ![image](https://github.com/apache/tvm/assets/29506758/cd188dcf-fc06-4340-8546-2d21da51f07c)
   
   The detail information can be found [here](https://start.oneflow.org/oneflow-api-cn/nn.html#:~:text=class%20oneflow.nn.Threshold,%EF%BC%8C%E5%90%A6%E5%88%99%E8%BF%94%E5%9B%9E%20value%E3%80%82)
   
   This PR corrects the implementation and adds a corresponding test case.
   
   
   cc @Hzfengsy @echuraev @vvchernov 


-- 
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 #15715: [Relay][Bugfix] Fix the wrong implementation about operator Threshold in oneflow

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


-- 
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] cbalint13 commented on a diff in pull request #15715: [Relay][Bugfix] Fix the wrong implementation about operator Threshold in oneflow

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


##########
python/tvm/relay/frontend/oneflow.py:
##########
@@ -1025,15 +1025,17 @@ def _impl_v1(cls, inputs, attrs, params):
         return out
 
 
-class ThresholdedRelu(OneFlowOpConverter):
-    """Operator converter for ThresholdedRelu."""
+class Threshold(OneFlowOpConverter):
+    """Operator converter for Threshold."""
 
     @classmethod
     def _impl_v1(cls, inputs, attrs, params):
-        alpha = float(attrs.get("alpha", 1.0))
-        alpha_tensor = _op.full_like(inputs[0], fill_value=_expr.const(alpha))
-        mask = _op.greater(inputs[0], alpha_tensor).astype("float32")
-        return inputs[0] * mask
+        threshold = float(attrs.get("threshold_val", 1.0))
+        threshold_tensor = _op.full_like(inputs[0], fill_value=_expr.const(threshold))
+        value = float(attrs.get("value"))
+        value_tensor = _op.full_like(inputs[0], fill_value=_expr.const(value))
+        mask = _op.greater(inputs[0], threshold_tensor).astype("float32")

Review Comment:
   ```.astype("float32")``` should't it be of any universal ```dtype``` ?
   thinking of other types i.e. ```int``` kinds in case of quantized things.



-- 
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] cbalint13 commented on a diff in pull request #15715: [Relay][Bugfix] Fix the wrong implementation about operator Threshold in oneflow

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


##########
python/tvm/relay/frontend/oneflow.py:
##########
@@ -1025,15 +1025,17 @@ def _impl_v1(cls, inputs, attrs, params):
         return out
 
 
-class ThresholdedRelu(OneFlowOpConverter):
-    """Operator converter for ThresholdedRelu."""
+class Threshold(OneFlowOpConverter):
+    """Operator converter for Threshold."""
 
     @classmethod
     def _impl_v1(cls, inputs, attrs, params):
-        alpha = float(attrs.get("alpha", 1.0))
-        alpha_tensor = _op.full_like(inputs[0], fill_value=_expr.const(alpha))
-        mask = _op.greater(inputs[0], alpha_tensor).astype("float32")
-        return inputs[0] * mask
+        threshold = float(attrs.get("threshold_val", 1.0))
+        threshold_tensor = _op.full_like(inputs[0], fill_value=_expr.const(threshold))
+        value = float(attrs.get("value"))
+        value_tensor = _op.full_like(inputs[0], fill_value=_expr.const(value))
+        mask = _op.greater(inputs[0], threshold_tensor).astype("float32")

Review Comment:
   should't it be of any universal ```dtype``` ?
   thinking of other types i.e. int in case of quantized things.



-- 
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] cbalint13 commented on a diff in pull request #15715: [Relay][Bugfix] Fix the wrong implementation about operator Threshold in oneflow

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


##########
python/tvm/relay/frontend/oneflow.py:
##########
@@ -1025,15 +1025,17 @@ def _impl_v1(cls, inputs, attrs, params):
         return out
 
 
-class ThresholdedRelu(OneFlowOpConverter):
-    """Operator converter for ThresholdedRelu."""
+class Threshold(OneFlowOpConverter):
+    """Operator converter for Threshold."""
 
     @classmethod
     def _impl_v1(cls, inputs, attrs, params):
-        alpha = float(attrs.get("alpha", 1.0))
-        alpha_tensor = _op.full_like(inputs[0], fill_value=_expr.const(alpha))
-        mask = _op.greater(inputs[0], alpha_tensor).astype("float32")
-        return inputs[0] * mask
+        threshold = float(attrs.get("threshold_val", 1.0))
+        threshold_tensor = _op.full_like(inputs[0], fill_value=_expr.const(threshold))
+        value = float(attrs.get("value"))
+        value_tensor = _op.full_like(inputs[0], fill_value=_expr.const(value))
+        mask = _op.greater(inputs[0], threshold_tensor).astype("float32")

Review Comment:
   should't it be of any universal ```dtype``` ?
   thinking of other types i.e. ```int``` kinds in case of quantized things.



-- 
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] jikechao commented on a diff in pull request #15715: [Relay][Bugfix] Fix the wrong implementation about operator Threshold in oneflow

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


##########
python/tvm/relay/frontend/oneflow.py:
##########
@@ -1025,15 +1025,17 @@ def _impl_v1(cls, inputs, attrs, params):
         return out
 
 
-class ThresholdedRelu(OneFlowOpConverter):
-    """Operator converter for ThresholdedRelu."""
+class Threshold(OneFlowOpConverter):
+    """Operator converter for Threshold."""
 
     @classmethod
     def _impl_v1(cls, inputs, attrs, params):
-        alpha = float(attrs.get("alpha", 1.0))
-        alpha_tensor = _op.full_like(inputs[0], fill_value=_expr.const(alpha))
-        mask = _op.greater(inputs[0], alpha_tensor).astype("float32")
-        return inputs[0] * mask
+        threshold = float(attrs.get("threshold_val", 1.0))
+        threshold_tensor = _op.full_like(inputs[0], fill_value=_expr.const(threshold))
+        value = float(attrs.get("value"))
+        value_tensor = _op.full_like(inputs[0], fill_value=_expr.const(value))
+        mask = _op.greater(inputs[0], threshold_tensor).astype("float32")

Review Comment:
   @cbalint13  It has been corrected! Thanks for your review.



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