zxybazh commented on a change in pull request #7809:
URL: https://github.com/apache/tvm/pull/7809#discussion_r616224603



##########
File path: python/tvm/ir/op.py
##########
@@ -115,3 +127,50 @@ def _register(v):
         return v
 
     return _register(value) if value is not None else _register
+
+
+def register_op_intrin_lowering(
+    op_name,
+    f=None,
+    target="default",
+    level=10,
+    override=False,
+):
+    """Register Op lowering function
+
+    Parameters
+    ----------
+    op_name : str or function
+        The op name
+
+    f : function, optional
+        The function to be registered.
+
+    target : str
+        The target string for given intrinsic lowering function
+
+    level : int
+        The priority level
+
+    override: boolean optional
+        Whether override existing entry.
+
+    Returns
+    -------
+    fregister : function
+        Register op lowering function if f is not specified.
+    """
+    if not isinstance(op_name, str):
+        raise ValueError("expect string op name")
+
+    def _register(myf):
+        """internal intrinsic lowering registration function"""
+        assert isinstance(target, str)
+        if not isinstance(myf, PackedFuncBase):
+            myf = convert_to_tvm_func(myf)
+        _ffi_api.RegisterOpLowerIntrinsic(op_name, myf.handle, target, level, 
override)
+        return myf

Review comment:
       Sure it could be simplified but I'll still keep the `_register` function 
for consistensy in function implementation compared to `register_op_attr`.




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


Reply via email to