tvm
Loading...
Searching...
No Matches
op.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
23#ifndef TVM_IR_PRIM_OP_H_
24#define TVM_IR_PRIM_OP_H_
25#include <tvm/ir/op.h>
26#include <tvm/ir/prim/expr.h>
27
28#include <algorithm>
29#include <limits>
30#include <type_traits>
31#include <utility>
32namespace tvm {
33namespace prim {
34
40
43
46
49
58
61
62} // namespace prim
63
75
87
98
110
122
134
146
158
170
182
194
206
217
228
238
254
268
282
299
316
332
344
357
369
381
393
405
417
429
440
453 Location loc = UnknownLoc());
454
466namespace prim {
476
484
496TVM_TIRX_DLL PrimExpr cast(DLDataType t, PrimExpr value, Location loc = UnknownLoc());
514template <typename ValueType,
515 typename = typename std::enable_if<(std::is_standard_layout<ValueType>::value &&
516 std::is_trivial<ValueType>::value) ||
517 std::is_same<ValueType, ffi::BigInt>::value>::type>
518inline PrimExpr MakeConst(PrimType dtype, ValueType value, Location loc = UnknownLoc());
519
520template <typename ValueType>
521inline PrimExpr MakeConstScalar(PrimType dtype, ValueType value, Location loc = UnknownLoc()) {
522 if constexpr (std::is_enum_v<ValueType>) {
523 return MakeConstScalar(dtype, static_cast<std::underlying_type_t<ValueType>>(value), loc);
524 } else {
525 DLDataTypeCode code = dtype.code();
526 if (code == DLDataTypeCode::kDLInt || code == DLDataTypeCode::kDLBool) {
527 return IntImm(dtype, ffi::BigInt(value), loc);
528 }
529 if (code == DLDataTypeCode::kDLUInt) {
530 TVM_FFI_ICHECK(value >= 0) << "cannot make uint from negative value " << value;
531 return IntImm(dtype, ffi::BigInt(value), loc);
532 }
533 if (dtype.MatchesCode(DLDataTypeCode::kDLFloat, DLDataTypeCode::kDLFloat8_e3m4,
534 DLDataTypeCode::kDLFloat8_e4m3, DLDataTypeCode::kDLFloat8_e4m3b11fnuz,
535 DLDataTypeCode::kDLFloat8_e4m3fn, DLDataTypeCode::kDLFloat8_e4m3fnuz,
536 DLDataTypeCode::kDLFloat8_e5m2, DLDataTypeCode::kDLFloat8_e5m2fnuz,
537 DLDataTypeCode::kDLFloat8_e8m0fnu, DLDataTypeCode::kDLFloat6_e2m3fn,
538 DLDataTypeCode::kDLFloat6_e3m2fn, DLDataTypeCode::kDLFloat4_e2m1fn) ||
539 dtype.MatchesElementType(DLDataTypeCode::kDLBfloat, 16)) {
540 return FloatImm(dtype, static_cast<double>(value), loc);
541 }
542 TVM_FFI_THROW(InternalError) << "cannot make const for type " << dtype;
543 throw;
544 }
545}
546
547template <>
548inline PrimExpr MakeConstScalar(PrimType dtype, bool value, Location loc) {
549 return MakeConstScalar(dtype, static_cast<int>(value), loc);
550}
551
552template <typename ValueType, typename>
553inline PrimExpr MakeConst(PrimType dtype, ValueType value, Location loc) {
554 if (!dtype.IsScalableVector() && !dtype.IsFixedLengthVector()) {
555 return MakeConstScalar(dtype, value, loc);
556 }
557 PrimType elem_ty = dtype.WithLanes(1);
558 if (dtype.IsFixedLengthVector()) {
559 return prim::Broadcast(MakeConstScalar(elem_ty, value, loc), dtype.lanes(), loc);
560 }
561 PrimExpr lanes = prim::Mul(Call(PrimType::Int(32), prim::vscale_op(), {}).as_or_throw<PrimExpr>(),
562 dtype.VScaleFactor());
563 return prim::Broadcast(MakeConstScalar(elem_ty, value, loc), lanes, loc);
564}
565
566} // namespace prim
567
568// additional const expression overloading
569#define TVM_DEFINE_ASSIGN_OP_OVERLOAD(Name, OpFunc) \
570 inline PrimExpr Name(PrimExpr& a, PrimExpr b) { \
571 a = OpFunc(a, b); \
572 return a; \
573 }
574
575#define TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD(Name) \
576 inline PrimExpr Name(const PrimExpr& a, float b) { return Name(a, PrimExpr(b)); } \
577 inline PrimExpr Name(float a, const PrimExpr& b) { return Name(PrimExpr(a), b); } \
578 inline PrimExpr Name(int a, const PrimExpr& b) { return Name(prim::MakeConst(b.ty(), a), b); } \
579 inline PrimExpr Name(const PrimExpr& a, int b) { return Name(a, prim::MakeConst(a.ty(), b)); } \
580 inline PrimExpr Name(const PrimExpr& a, double b) { \
581 return Name(a, FloatImm(PrimType::Float(64), b)); \
582 }
583
584#define TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD_SPANNED(Name) \
585 inline PrimExpr Name(const PrimExpr& a, float b, Location loc = UnknownLoc()) { \
586 return Name(a, PrimExpr(b), loc); \
587 } \
588 inline PrimExpr Name(float a, const PrimExpr& b, Location loc = UnknownLoc()) { \
589 return Name(PrimExpr(a), b, loc); \
590 } \
591 inline PrimExpr Name(int a, const PrimExpr& b, Location loc = UnknownLoc()) { \
592 return Name(prim::MakeConst(b.ty(), a), b, loc); \
593 } \
594 inline PrimExpr Name(const PrimExpr& a, int b, Location loc = UnknownLoc()) { \
595 return Name(a, prim::MakeConst(a.ty(), b), loc); \
596 } \
597 inline PrimExpr Name(const PrimExpr& a, double b, Location loc = UnknownLoc()) { \
598 return Name(a, FloatImm(PrimType::Float(64), b), loc); \
599 }
600
601#define TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD(Name) \
602 inline PrimExpr Name(const PrimExpr& a, bool b) { return Name(a, PrimExpr(b)); } \
603 inline PrimExpr Name(bool a, const PrimExpr& b) { return Name(PrimExpr(a), b); }
604
605#define TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD_SPANNED(Name) \
606 inline PrimExpr Name(const PrimExpr& a, bool b, Location loc = UnknownLoc()) { \
607 return Name(a, PrimExpr(b), loc); \
608 } \
609 inline PrimExpr Name(bool a, const PrimExpr& b, Location loc = UnknownLoc()) { \
610 return Name(PrimExpr(a), b, loc); \
611 }
612
613#define TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD(Name) \
614 inline PrimExpr Name(const PrimExpr& a, int b) { return Name(a, prim::MakeConst(a.ty(), b)); } \
615 inline PrimExpr Name(int a, const PrimExpr& b) { return Name(prim::MakeConst(b.ty(), a), b); }
616
617#define TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD_SPANNED(Name) \
618 inline PrimExpr Name(const PrimExpr& a, int b, Location loc = UnknownLoc()) { \
619 return Name(a, prim::MakeConst(a.ty(), b), loc); \
620 } \
621 inline PrimExpr Name(int a, const PrimExpr& b, Location loc = UnknownLoc()) { \
622 return Name(prim::MakeConst(b.ty(), a), b, loc); \
623 }
624
625TVM_DEFINE_ASSIGN_OP_OVERLOAD(operator+=, operator+);
626TVM_DEFINE_ASSIGN_OP_OVERLOAD(operator-=, operator-);
627TVM_DEFINE_ASSIGN_OP_OVERLOAD(operator*=, operator*);
645// integer related ops
662// logical ops
667
673template <typename TA>
674inline void DivAmbiguityError(const TA& a) {
675 constexpr bool div_ambiguity = !std::is_class<TA>::value;
676 static_assert(div_ambiguity,
677 "TVM supports multiple types of integer divisions, "
678 "please call div, indexdiv/indexmod, "
679 "floordiv/floormod or truncdiv/truncmod directly "
680 "to avoid ambiguity in the code. "
681 "Checkout these functions in ir/prim/op.h.");
682}
683
684// The following code are not intended to be used in the codebase.
685// Instead, they generate clear compiler errors that ask developers
686// to use the specific division function.
687// The second template argument is necessary to make sure the
688// code compiles lazily by the compiler during invocation.
689template <typename TB>
690inline PrimExpr operator/(const PrimExpr& a, const TB& b) {
692 return a;
693}
694
695template <typename TB>
696inline PrimExpr operator/=(const PrimExpr& a, const TB& b) {
698 return a;
699}
700
701template <typename TB>
702inline PrimExpr operator%(const PrimExpr& a, const TB& b) {
704 return a;
705}
706
707// Constant predicates
708namespace prim {
709
716inline bool IsConstInt(const PrimExpr& x, int64_t value);
717
724inline bool IsOne(const PrimExpr& x);
725
732inline bool IsZero(const PrimExpr& x);
733
738inline bool IsConstInt(const PrimExpr& x);
739
745inline bool IsConstNumber(const PrimExpr& x);
746
755TVM_TIRX_DLL bool IsPowerOfTwoInt(const PrimExpr& x, int* shift);
756
758inline bool IsPositiveConst(const PrimExpr& a);
759
761inline bool IsNegativeConst(const PrimExpr& a);
762
763// Inline constant predicate implementations.
764inline bool IsConstInt(const PrimExpr& x) { return x.as<IntImmNode>() != nullptr; }
765
766inline bool IsConstNumber(const PrimExpr& x) {
767 if (x.as<IntImmNode>()) {
768 return true;
769 } else if (x.as<FloatImmNode>()) {
770 return true;
771 } else if (const auto* op = x.as<prim::BroadcastNode>()) {
772 return (op->value->IsInstance<IntImmNode>() || op->value->IsInstance<FloatImmNode>());
773 }
774 return false;
775}
776
777inline bool IsPositiveConst(const PrimExpr& a) {
778 const auto* as_int = a.as<IntImmNode>();
779 return as_int && as_int->value > 0;
780}
781
782inline bool IsNegativeConst(const PrimExpr& a) {
783 const auto* as_int = a.as<IntImmNode>();
784 return as_int && as_int->value < 0;
785}
786
787inline bool IsConstInt(const PrimExpr& x, int64_t value) {
788 const auto* as_int = x.as<IntImmNode>();
789 return as_int && as_int->value == value;
790}
791
792inline bool IsOne(const PrimExpr& x) { return IsConstInt(x, 1); }
793
794inline bool IsZero(const PrimExpr& x) { return IsConstInt(x, 0); }
795
803
811
820
828
836
844
852
864
875
883
964
967 return Call(x.ty(), fma_op(), {x, y, z}, {}, {}, loc).as_or_throw<PrimExpr>();
968}
969
970inline void CheckMathUnaryOpInputDType(const char* op_name, const PrimType& dtype) {
971 TVM_FFI_CHECK(dtype.code() == DLDataTypeCode::kDLFloat ||
972 dtype.MatchesElementType(DLDataTypeCode::kDLBfloat, 16),
973 TypeError)
974 << "prim." << op_name << " only supports floating-point inputs, but got " << dtype;
975}
976
977// Intrinsic operators
978#define TVM_DECLARE_INTRIN_UNARY_WITH_CHECK(OpName, CheckInputDType) \
979 inline PrimExpr OpName(PrimExpr x, Location loc = UnknownLoc()) { \
980 static const Op op = Op::Get("prim." #OpName); \
981 PrimType x_ty = x.ty(); \
982 CheckInputDType(#OpName, x_ty); \
983 if (x_ty.MatchesElementType(DLDataTypeCode::kDLBfloat, 16)) { \
984 PrimType bf16_ty = x_ty; \
985 PrimType f32_ty = \
986 x_ty.IsScalableVector() \
987 ? PrimType::ScalableVector(DLDataTypeCode::kDLFloat, 32, x_ty.VScaleFactor()) \
988 : PrimType::Float(32, x_ty.lanes()); \
989 PrimExpr x_fp32 = prim::Cast(f32_ty, x, loc); \
990 PrimExpr result_fp32 = Call(f32_ty, op, {x_fp32}, {}, {}, loc).as_or_throw<PrimExpr>(); \
991 return prim::Cast(bf16_ty, result_fp32, loc); \
992 } else { \
993 return Call(x_ty, op, {x}, {}, {}, loc).as_or_throw<PrimExpr>(); \
994 } \
995 }
996
997#define TVM_DECLARE_INTRIN_UNARY(OpName) \
998 TVM_DECLARE_INTRIN_UNARY_WITH_CHECK(OpName, [](const char*, const PrimType&) {})
999
1000#define TVM_DECLARE_FLOAT_INTRIN_UNARY(OpName) \
1001 TVM_DECLARE_INTRIN_UNARY_WITH_CHECK(OpName, CheckMathUnaryOpInputDType)
1002
1026
1027#define TVM_DECLARE_INTRIN_BINARY(OpName) \
1028 inline PrimExpr OpName(PrimExpr x, PrimExpr y, Location loc = UnknownLoc()) { \
1029 static const Op op = Op::Get("prim." #OpName); \
1030 return Call(x.ty(), op, {x, y}, {}, {}, loc).as_or_throw<PrimExpr>(); \
1031 }
1032
1038
1039template <typename FReduce>
1040inline PrimExpr foldl(FReduce freduce, PrimExpr init_value, const ffi::Array<PrimExpr>& values,
1041 Location loc = UnknownLoc()) {
1042 for (PrimExpr val : values) {
1043 init_value = freduce(init_value, val, loc);
1044 }
1045 return init_value;
1046}
1047
1048} // namespace prim
1049
1050} // namespace tvm
1051#endif // TVM_IR_PRIM_OP_H_
Managed reference to CallNode.
Definition expr.h:972
Constant floating point literals in the program.
Definition expr.h:215
Managed reference class to FloatImmNode.
Definition expr.h:232
Constant integer literals in the program.
Definition expr.h:135
ffi::BigInt value
the Internal value.
Definition expr.h:138
Managed reference class to IntImmNode.
Definition expr.h:152
Non-nullable source-location metadata.
Definition location.h:91
Reference-counted handle to a canonical named operator.
Definition op.h:147
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:447
Definition base_expr.h:161
TVM_FFI_INLINE DLDataTypeCode code() const
Definition base_expr.h:198
TVM_FFI_INLINE PrimType WithLanes(int lanes) const
Return the same scalar element type with a fixed lane count.
Definition base_expr.h:298
TVM_FFI_INLINE bool IsScalableVector() const
Whether this type is a scalable vector.
Definition base_expr.h:251
TVM_FFI_INLINE bool IsFixedLengthVector() const
Whether this type is a fixed-length vector.
Definition base_expr.h:256
TVM_FFI_INLINE bool MatchesCode(Codes... codes) const
Check whether the dtype code matches any of the provided DLPack codes.
Definition base_expr.h:232
TVM_FFI_INLINE bool MatchesElementType(DLDataTypeCode code, int bits) const
Check the scalar element code and bit width.
Definition base_expr.h:222
static TVM_TIRX_DLL PrimType Int(int bits, int lanes=1)
Construct a signed integer type with fixed lanes.
TVM_FFI_INLINE int32_t VScaleFactor() const
Definition base_expr.h:303
TVM_FFI_INLINE int32_t lanes() const
Definition base_expr.h:209
ExpectedType ty() const
Definition base_expr.h:424
Reference to the shared immutable unknown location.
Definition location.h:105
Create a vector where all the elements are value.
Definition vector_expr.h:79
Managed reference to BroadcastNode.
Definition vector_expr.h:102
Managed reference to MulNode.
Definition expr.h:266
Canonical primitive operators and their registration.
TIR expressions.
#define TVM_DECLARE_INTRIN_UNARY(OpName)
Definition op.h:997
#define TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD(Name)
Definition op.h:613
#define TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD_SPANNED(Name)
Definition op.h:605
#define TVM_DEFINE_ASSIGN_OP_OVERLOAD(Name, OpFunc)
Definition op.h:569
#define TVM_DECLARE_FLOAT_INTRIN_UNARY(OpName)
Definition op.h:1000
#define TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD_SPANNED(Name)
Definition op.h:584
#define TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD(Name)
Definition op.h:575
#define TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD(Name)
Definition op.h:601
#define TVM_DECLARE_INTRIN_BINARY(OpName)
Definition op.h:1027
#define TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD_SPANNED(Name)
Definition op.h:617
TVM_TIRX_DLL PrimExpr nearbyint(PrimExpr x, Location loc=UnknownLoc())
Round x to the nearest integer, ties to even.
TVM_TIRX_DLL const Op & log_op()
Natural logarithm. Argument: x.
TVM_TIRX_DLL const Op & assume_op()
Record a known condition for simplification. Argument: condition.
TVM_TIRX_DLL const Op & log10_op()
Base-ten logarithm. Argument: x.
TVM_TIRX_DLL PrimExpr isfinite(PrimExpr x, Location loc=UnknownLoc())
Check if x is finite.
TVM_TIRX_DLL const Op & atan_op()
Inverse tangent. Argument: x.
TVM_TIRX_DLL const Op & isnan_op()
Check for NaN, preserving the lane count. Argument: x.
TVM_TIRX_DLL bool IsPowerOfTwoInt(const PrimExpr &x, int *shift)
Check whether x is a constant power of two If x is power of two, write the power to the shift.
TVM_TIRX_DLL const Op & tan_op()
Tangent. Argument: x.
void CheckMathUnaryOpInputDType(const char *op_name, const PrimType &dtype)
Definition op.h:970
TVM_TIRX_DLL PrimExpr min_value(PrimType dtype, Location loc=UnknownLoc())
PrimExpr foldl(FReduce freduce, PrimExpr init_value, const ffi::Array< PrimExpr > &values, Location loc=UnknownLoc())
Definition op.h:1040
TVM_TIRX_DLL const Op & ceil_op()
Round up to the nearest integral value.
TVM_TIRX_DLL PrimExpr IntegerAbs(PrimExpr x, Location loc=UnknownLoc())
Construct integer absolute value; floating absolute value belongs to TIRX.
TVM_TIRX_DLL const Op & sqrt_op()
Square root. Argument: x.
TVM_TIRX_DLL const Op & clz_op()
Count leading zero bits.
TVM_TIRX_DLL const Op & acos_op()
Inverse cosine. Argument: x.
TVM_TIRX_DLL const Op & pow_op()
Raise x to the power y. Arguments: x, y.
TVM_TIRX_DLL const Op & ldexp_op()
Multiply x by two raised to exponent. Arguments: x, exponent.
TVM_TIRX_DLL PrimExpr isnan(PrimExpr x, Location loc=UnknownLoc())
Check if x is NaN.
TVM_TIRX_DLL PrimExpr trunc(PrimExpr x, Location loc=UnknownLoc())
Calculate trunc(x)
PrimExpr MakeConstScalar(PrimType dtype, ValueType value, Location loc=UnknownLoc())
Definition op.h:521
TVM_TIRX_DLL PrimExpr isinf(PrimExpr x, Location loc=UnknownLoc())
Check if x is infinite.
TVM_TIRX_DLL PrimExpr floor(PrimExpr x, Location loc=UnknownLoc())
Calculate floor(x)
TVM_TIRX_DLL const Op & cosh_op()
Hyperbolic cosine. Argument: x.
TVM_TIRX_DLL const Op & fma_op()
Fused multiply-add, x * y + z. Arguments: x, y, z.
TVM_TIRX_DLL PrimExpr assume(PrimExpr condition, Location loc=UnknownLoc())
Record a known condition for compile-time simplification.
TVM_TIRX_DLL const Op & round_op()
Round to nearest integer, ties to even. Argument: x.
TVM_TIRX_DLL const Op & nextafter_op()
Next representable value from x toward y. Arguments: x, y.
TVM_TIRX_DLL const Op & atan2_op()
Inverse tangent of y/x with quadrant selection. Arguments: y, x.
TVM_TIRX_DLL const Op & cos_op()
Cosine. Argument: x.
TVM_TIRX_DLL PrimExpr max_value(PrimType dtype, Location loc=UnknownLoc())
TVM_TIRX_DLL const Op & asinh_op()
Inverse hyperbolic sine. Argument: x.
TVM_TIRX_DLL const Op & exp2_op()
Base-two exponential. Argument: x.
TVM_TIRX_DLL const Op & tanh_op()
Hyperbolic tangent. Argument: x.
TVM_TIRX_DLL const Op & sin_op()
Sine. Argument: x.
bool IsOne(const PrimExpr &x)
Check whether x is a constant integer 1.
Definition op.h:792
TVM_TIRX_DLL PrimExpr fmod(PrimExpr x, PrimExpr y, Location loc=UnknownLoc())
Floating-point remainder of x divided by y.
TVM_TIRX_DLL const Op & exp_op()
Natural exponential. Argument: x.
TVM_TIRX_DLL const Op & nearbyint_op()
Round to nearest integer, ties to even. Argument: x.
TVM_TIRX_DLL const Op & exp10_op()
Base-ten exponential. Argument: x.
bool IsConstNumber(const PrimExpr &x)
Check whether x is an integer or floating-point constant.
Definition op.h:766
TVM_TIRX_DLL PrimExpr round(PrimExpr x, Location loc=UnknownLoc())
Round x to the nearest integer, ties to even.
TVM_TIRX_DLL PrimExpr infinity(PrimType dtype, Location loc=UnknownLoc())
TVM_TIRX_DLL const Op & trunc_op()
Round toward zero. Argument: x.
TVM_TIRX_DLL const Op & log1p_op()
Natural logarithm of one plus x. Argument: x.
bool IsZero(const PrimExpr &x)
Check whether x is a constant integer 0.
Definition op.h:794
TVM_TIRX_DLL const Op & sinh_op()
Hyperbolic sine. Argument: x.
TVM_TIRX_DLL const Op & likely_op()
Marks a condition is likely going to happen.
TVM_TIRX_DLL PrimExpr abs(PrimExpr x, Location loc=UnknownLoc())
Calculate absolute value of x.
TVM_TIRX_DLL const Op & fabs_op()
Absolute value. Argument: x.
TVM_TIRX_DLL const Op & vscale_op()
Get the target's vscale value. It will be lowered to llvm.vscale intrinsic (https://llvm....
bool IsConstInt(const PrimExpr &x, int64_t value)
Check whether x is a constant integer expression.
Definition op.h:787
TVM_TIRX_DLL const Op & acosh_op()
Inverse hyperbolic cosine. Argument: x.
PrimExpr MakeConst(PrimType dtype, ValueType value, Location loc=UnknownLoc())
Make a const value with certain data type.
Definition op.h:553
TVM_TIRX_DLL const Op & sigmoid_op()
Logistic sigmoid. Argument: x.
TVM_TIRX_DLL const Op & popcount_op()
Count set bits. Argument: x.
bool IsNegativeConst(const PrimExpr &a)
Check whether a is a negative integer constant.
Definition op.h:782
TVM_TIRX_DLL const Op & asin_op()
Inverse sine. Argument: x.
TVM_TIRX_DLL PrimExpr cast(PrimType t, PrimExpr value, Location loc=UnknownLoc())
cast value to type.
PrimExpr fma(PrimExpr x, PrimExpr y, PrimExpr z, Location loc=UnknownLoc())
Fused multiply-add of x, y and z, in that order.
Definition op.h:966
TVM_TIRX_DLL const Op & hypot_op()
Euclidean length of x and y. Arguments: x, y.
TVM_TIRX_DLL const Op & if_then_else_op()
Same as select, used for unsafe memory access.
TVM_TIRX_DLL const Op & erf_op()
Error function. Argument: x.
TVM_TIRX_DLL PrimExpr clz(PrimExpr x, Location loc=UnknownLoc())
Count leading zero bits, preserving the input primitive type.
TVM_TIRX_DLL const Op & rsqrt_op()
Reciprocal square root. Argument: x.
TVM_TIRX_DLL PrimExpr pow(PrimExpr x, PrimExpr y, Location loc=UnknownLoc())
Calculate power(x, y)
TVM_TIRX_DLL const Op & floor_op()
Round toward negative infinity. Argument: x.
TVM_TIRX_DLL const Op & copysign_op()
Magnitude of x with the sign of y. Arguments: x, y.
TVM_TIRX_DLL const Op & fmod_op()
Floating-point remainder. Arguments: x, y.
bool IsPositiveConst(const PrimExpr &a)
Check whether a is a positive integer constant.
Definition op.h:777
TVM_TIRX_DLL const Op & atanh_op()
Inverse hyperbolic tangent. Argument: x.
TVM_TIRX_DLL const Op & log2_op()
Base-two logarithm.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
TVM_TIRX_DLL PrimExpr log2(PrimExpr x, Location loc=UnknownLoc())
Construct a base-two logarithm with the input's primitive type.
TVM_TIRX_DLL PrimExpr bitwise_and(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
take bitwise and of two values
TVM_TIRX_DLL PrimExpr logical_and(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
and
TVM_TIRX_DLL PrimExpr mul(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
multiplication operator
TVM_TIRX_DLL PrimExpr max(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
take maximum of two values
TVM_TIRX_DLL PrimExpr bitwise_neg(PrimExpr a, Location loc=UnknownLoc())
take bitwise negation of two values
void DivAmbiguityError(const TA &a)
Helper function to raise a compiler error about division ambiguity.
Definition op.h:674
TVM_TIRX_DLL PrimExpr not_equal(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
not_equal
TVM_TIRX_DLL PrimExpr if_then_else(PrimExpr cond, PrimExpr true_value, PrimExpr false_value, Location loc=UnknownLoc())
Conditional expression.
TVM_TIRX_DLL PrimExpr min(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
take minimum of two values
TVM_TIRX_DLL PrimExpr greater_equal(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
greater_equal
TVM_TIRX_DLL PrimExpr truncdiv(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
compute trunc(a / b)
TVM_TIRX_DLL PrimExpr left_shift(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
left shift operator
TVM_TIRX_DLL PrimExpr less_equal(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
less_equal
PrimExpr operator/=(const PrimExpr &a, const TB &b)
Definition op.h:696
TVM_TIRX_DLL PrimExpr neg(PrimExpr a, Location loc=UnknownLoc())
negation.
TVM_TIRX_DLL PrimExpr indexdiv(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
compute floor(a / b) where a and b are non-negative.
TVM_TIRX_DLL PrimExpr greater(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
greater
TVM_TIRX_DLL PrimExpr div(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
compute division in C semantics.
TVM_TIRX_DLL PrimExpr right_shift(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
right shift operator
TVM_TIRX_DLL PrimExpr equal(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
equal
TVM_TIRX_DLL PrimExpr logical_or(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
or
TVM_TIRX_DLL PrimExpr operator/(PrimExpr a, PrimExpr b)
division operator
TVM_TIRX_DLL PrimExpr floormod(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
compute the remainder of floordiv
TVM_TIRX_DLL PrimExpr truncmod(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
compute the remainder of truncdiv
TVM_TIRX_DLL PrimExpr logical_not(PrimExpr a, Location loc=UnknownLoc())
not
TVM_TIRX_DLL PrimExpr likely(PrimExpr cond, Location loc=UnknownLoc())
Mark condition as likely.
TVM_TIRX_DLL PrimExpr floordiv(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
compute floor(a / b)
TVM_TIRX_DLL PrimExpr add(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
add operator
TVM_TIRX_DLL PrimExpr sub(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
subtraction operator
TVM_TIRX_DLL PrimExpr less(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
less
PrimExpr operator%(const PrimExpr &a, const TB &b)
Definition op.h:702
TVM_TIRX_DLL PrimExpr shapediv(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
compute ceil(a / b) where a and b are non-negative.
TVM_TIRX_DLL PrimExpr ceildiv(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
compute ceil(a / b)
TVM_TIRX_DLL PrimExpr bitwise_xor(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
take bitwise xor of two values
TVM_TIRX_DLL PrimExpr bitwise_or(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
take bitwise or of two values
TVM_TIRX_DLL PrimExpr ceil(PrimExpr x, Location loc=UnknownLoc())
Round up to the nearest integral value, preserving the input type.
TVM_TIRX_DLL PrimExpr indexmod(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
compute the remainder floor(a / b) where a and b are non-negative.
#define TVM_TIRX_DLL
Definition base.h:83