You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/04/24 23:21:16 UTC

[GitHub] [incubator-tvm] mbrookhart commented on a change in pull request #5441: Add TopK to ONNX Frontend

mbrookhart commented on a change in pull request #5441:
URL: https://github.com/apache/incubator-tvm/pull/5441#discussion_r414914928



##########
File path: python/tvm/relay/frontend/onnx.py
##########
@@ -1470,6 +1470,23 @@ def _impl_v9(cls, inputs, attr, params):
         output = AttrCvt(op_name='argwhere')(inputs, attr, params)
         return _op.transpose(output, axes=(1, 0))
 
+class TopK(OnnxOpConverter):
+    """Operator converter for TopK
+    """
+    @classmethod
+    def _impl_v1(cls, inputs, attr, params):
+        if len(inputs) != 2:
+            raise ValueError("Expect 2 input only")
+        inp = inputs[0]
+        axis = attr.get("axis", len(infer_shape(inp)) - 1)
+        largest = attr.get("largest", 1)
+
+        if largest == 0:
+            raise ValueError("TVM only supports finding TopK largest elements")

Review comment:
       It's a boolean value stored as an int. Anything but zero is technically true, and I only want to throw on the false case.




----------------------------------------------------------------
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:
users@infra.apache.org