Add Binary Intrinsic ops to TIR Ops in C++ (#5900)
authorMatthew Brookhart <mbrookhart@octoml.ai>
Tue, 23 Jun 2020 23:18:29 +0000 (16:18 -0700)
committerGitHub <noreply@github.com>
Tue, 23 Jun 2020 23:18:29 +0000 (16:18 -0700)
* Add Binary Intrinsic ops to TIR Ops in C++

* clang-format

include/tvm/tir/op.h

index 286b6d7..09eb33c 100644 (file)
@@ -583,6 +583,18 @@ TVM_DECLARE_INTRIN_UNARY(acosh);
 TVM_DECLARE_INTRIN_UNARY(asinh);
 TVM_DECLARE_INTRIN_UNARY(atanh);
 
+#define TVM_DECLARE_INTRIN_BINARY(OpName)                                  \
+  inline PrimExpr OpName(PrimExpr x, PrimExpr y) {                         \
+    static const Op& op = Op::Get("tir." #OpName);                         \
+    return tir::Call(x.dtype(), op, {x, y}, tir::CallNode::PureIntrinsic); \
+  }
+
+TVM_DECLARE_INTRIN_BINARY(atan2);
+TVM_DECLARE_INTRIN_BINARY(nextafter);
+TVM_DECLARE_INTRIN_BINARY(copysign);
+TVM_DECLARE_INTRIN_BINARY(hypot);
+TVM_DECLARE_INTRIN_BINARY(ldexp);
+
 namespace tir {
 /*!
  * \brief Make a const value with certain data type.