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 {
33
44
55
65
76
87
98
109
120
131
142
153
164
175
185
195
204
215
226
237
247
250 a = a + b;
251 return a;
252}
253
256 a = a - b;
257 return a;
258}
259
262 a = a * b;
263 return a;
264}
265
266namespace prim {
267
274
281
288
295
301
304
307
310
319
322
323} // namespace prim
324
336
348
359
371
383
395
407
419
431
443
455
467
478
489
499
515
529
543
560
577
593
605
618
630
642
654
666
678
690
701
714 Location loc = UnknownLoc());
715
723namespace prim {
737
745
775template <typename ValueType,
776 typename = typename std::enable_if<(std::is_standard_layout<ValueType>::value &&
777 std::is_trivial<ValueType>::value) ||
778 std::is_same<ValueType, ffi::BigInt>::value>::type>
779inline PrimExpr MakeConst(PrimType dtype, ValueType value, Location loc = UnknownLoc());
780
781template <typename ValueType>
782inline PrimExpr MakeConstScalar(PrimType dtype, ValueType value, Location loc = UnknownLoc()) {
783 if constexpr (std::is_enum_v<ValueType>) {
784 return MakeConstScalar(dtype, static_cast<std::underlying_type_t<ValueType>>(value), loc);
785 } else {
786 DLDataTypeCode code = dtype.code();
787 if (code == DLDataTypeCode::kDLInt || code == DLDataTypeCode::kDLBool) {
788 return IntImm(dtype, ffi::BigInt(value), loc);
789 }
790 if (code == DLDataTypeCode::kDLUInt) {
791 TVM_FFI_ICHECK(value >= 0) << "cannot make uint from negative value " << value;
792 return IntImm(dtype, ffi::BigInt(value), loc);
793 }
794 if (dtype.MatchesCode(DLDataTypeCode::kDLFloat, DLDataTypeCode::kDLFloat8_e3m4,
795 DLDataTypeCode::kDLFloat8_e4m3, DLDataTypeCode::kDLFloat8_e4m3b11fnuz,
796 DLDataTypeCode::kDLFloat8_e4m3fn, DLDataTypeCode::kDLFloat8_e4m3fnuz,
797 DLDataTypeCode::kDLFloat8_e5m2, DLDataTypeCode::kDLFloat8_e5m2fnuz,
798 DLDataTypeCode::kDLFloat8_e8m0fnu, DLDataTypeCode::kDLFloat6_e2m3fn,
799 DLDataTypeCode::kDLFloat6_e3m2fn, DLDataTypeCode::kDLFloat4_e2m1fn) ||
800 dtype.MatchesElementType(DLDataTypeCode::kDLBfloat, 16)) {
801 return FloatImm(dtype, static_cast<double>(value), loc);
802 }
803 TVM_FFI_THROW(InternalError) << "cannot make const for type " << dtype;
804 throw;
805 }
806}
807
808template <>
809inline PrimExpr MakeConstScalar(PrimType dtype, bool value, Location loc) {
810 return MakeConstScalar(dtype, static_cast<int>(value), loc);
811}
812
813template <typename ValueType, typename>
814inline PrimExpr MakeConst(PrimType dtype, ValueType value, Location loc) {
815 if (!dtype.IsScalableVector() && !dtype.IsFixedLengthVector()) {
816 return MakeConstScalar(dtype, value, loc);
817 }
818 PrimType elem_ty = dtype.WithLanes(1);
819 if (dtype.IsFixedLengthVector()) {
820 return prim::Broadcast(MakeConstScalar(elem_ty, value, loc), dtype.lanes(), loc);
821 }
822 PrimExpr lanes = prim::Mul(Call(PrimType::Int(32), prim::vscale_op(), {}).as_or_throw<PrimExpr>(),
823 dtype.VScaleFactor());
824 return prim::Broadcast(MakeConstScalar(elem_ty, value, loc), lanes, loc);
825}
826
827} // namespace prim
828
829// additional const expression overloading
830#define TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD(Name) \
831 inline PrimExpr Name(const PrimExpr& a, float b) { return Name(a, PrimExpr(b)); } \
832 inline PrimExpr Name(float a, const PrimExpr& b) { return Name(PrimExpr(a), b); } \
833 inline PrimExpr Name(int a, const PrimExpr& b) { return Name(prim::MakeConst(b.ty(), a), b); } \
834 inline PrimExpr Name(const PrimExpr& a, int b) { return Name(a, prim::MakeConst(a.ty(), b)); } \
835 inline PrimExpr Name(const PrimExpr& a, double b) { \
836 return Name(a, FloatImm(PrimType::Float(64), b)); \
837 }
838
839#define TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD_SPANNED(Name) \
840 inline PrimExpr Name(const PrimExpr& a, float b, Location loc = UnknownLoc()) { \
841 return Name(a, PrimExpr(b), loc); \
842 } \
843 inline PrimExpr Name(float a, const PrimExpr& b, Location loc = UnknownLoc()) { \
844 return Name(PrimExpr(a), b, loc); \
845 } \
846 inline PrimExpr Name(int a, const PrimExpr& b, Location loc = UnknownLoc()) { \
847 return Name(prim::MakeConst(b.ty(), a), b, loc); \
848 } \
849 inline PrimExpr Name(const PrimExpr& a, int b, Location loc = UnknownLoc()) { \
850 return Name(a, prim::MakeConst(a.ty(), b), loc); \
851 } \
852 inline PrimExpr Name(const PrimExpr& a, double b, Location loc = UnknownLoc()) { \
853 return Name(a, FloatImm(PrimType::Float(64), b), loc); \
854 }
855
856#define TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD(Name) \
857 inline PrimExpr Name(const PrimExpr& a, bool b) { return Name(a, PrimExpr(b)); } \
858 inline PrimExpr Name(bool a, const PrimExpr& b) { return Name(PrimExpr(a), b); }
859
860#define TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD_SPANNED(Name) \
861 inline PrimExpr Name(const PrimExpr& a, bool b, Location loc = UnknownLoc()) { \
862 return Name(a, PrimExpr(b), loc); \
863 } \
864 inline PrimExpr Name(bool a, const PrimExpr& b, Location loc = UnknownLoc()) { \
865 return Name(PrimExpr(a), b, loc); \
866 }
867
868#define TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD(Name) \
869 inline PrimExpr Name(const PrimExpr& a, int b) { return Name(a, prim::MakeConst(a.ty(), b)); } \
870 inline PrimExpr Name(int a, const PrimExpr& b) { return Name(prim::MakeConst(b.ty(), a), b); }
871
872#define TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD_SPANNED(Name) \
873 inline PrimExpr Name(const PrimExpr& a, int b, Location loc = UnknownLoc()) { \
874 return Name(a, prim::MakeConst(a.ty(), b), loc); \
875 } \
876 inline PrimExpr Name(int a, const PrimExpr& b, Location loc = UnknownLoc()) { \
877 return Name(prim::MakeConst(b.ty(), a), b, loc); \
878 }
879
897// integer related ops
914// logical ops
919
925template <typename TA>
926inline void DivAmbiguityError(const TA& a) {
927 constexpr bool div_ambiguity = !std::is_class<TA>::value;
928 static_assert(div_ambiguity,
929 "TVM supports multiple types of integer divisions, "
930 "please call div, indexdiv/indexmod, "
931 "floordiv/floormod or truncdiv/truncmod directly "
932 "to avoid ambiguity in the code. "
933 "Checkout these functions in ir/prim/op.h.");
934}
935
936// The following code are not intended to be used in the codebase.
937// Instead, they generate clear compiler errors that ask developers
938// to use the specific division function.
939// The second template argument is necessary to make sure the
940// code compiles lazily by the compiler during invocation.
941template <typename TB>
942inline PrimExpr operator/(const PrimExpr& a, const TB& b) {
944 return a;
945}
946
947template <typename TB>
948inline PrimExpr operator/=(const PrimExpr& a, const TB& b) {
950 return a;
951}
952
953template <typename TB>
954inline PrimExpr operator%(const PrimExpr& a, const TB& b) {
956 return a;
957}
958
959// Constant predicates
960namespace prim {
961
968inline bool IsConstInt(const PrimExpr& x, int64_t value);
969
976inline bool IsOne(const PrimExpr& x);
977
984inline bool IsZero(const PrimExpr& x);
985
990inline bool IsConstInt(const PrimExpr& x);
991
997inline bool IsConstNumber(const PrimExpr& x);
998
1007TVM_TIRX_DLL bool IsPowerOfTwoInt(const PrimExpr& x, int* shift);
1008
1010inline bool IsPositiveConst(const PrimExpr& a);
1011
1013inline bool IsNegativeConst(const PrimExpr& a);
1014
1015// Inline constant predicate implementations.
1016inline bool IsConstInt(const PrimExpr& x) { return x.as<IntImmObj>() != nullptr; }
1017
1018inline bool IsConstNumber(const PrimExpr& x) {
1019 if (x.as<IntImmObj>()) {
1020 return true;
1021 } else if (x.as<FloatImmObj>()) {
1022 return true;
1023 } else if (const auto* op = x.as<prim::BroadcastObj>()) {
1024 return (op->value->IsInstance<IntImmObj>() || op->value->IsInstance<FloatImmObj>());
1025 }
1026 return false;
1027}
1028
1029inline bool IsPositiveConst(const PrimExpr& a) {
1030 const auto* as_int = a.as<IntImmObj>();
1031 return as_int && as_int->value > 0;
1032}
1033
1034inline bool IsNegativeConst(const PrimExpr& a) {
1035 const auto* as_int = a.as<IntImmObj>();
1036 return as_int && as_int->value < 0;
1037}
1038
1039inline bool IsConstInt(const PrimExpr& x, int64_t value) {
1040 const auto* as_int = x.as<IntImmObj>();
1041 return as_int && as_int->value == value;
1042}
1043
1044inline bool IsOne(const PrimExpr& x) { return IsConstInt(x, 1); }
1045
1046inline bool IsZero(const PrimExpr& x) { return IsConstInt(x, 0); }
1047
1055
1063
1072
1080
1088
1096
1104
1116
1127
1135
1216
1219 return Call(x.ty(), fma_op(), {x, y, z}, {}, {}, loc).as_or_throw<PrimExpr>();
1220}
1221
1222inline void CheckMathUnaryOpInputDType(const char* op_name, const PrimType& dtype) {
1223 TVM_FFI_CHECK(dtype.code() == DLDataTypeCode::kDLFloat ||
1224 dtype.MatchesElementType(DLDataTypeCode::kDLBfloat, 16),
1225 TypeError)
1226 << "prim." << op_name << " only supports floating-point inputs, but got " << dtype;
1227}
1228
1229// Intrinsic operators
1230#define TVM_DECLARE_INTRIN_UNARY_WITH_CHECK(OpName, CheckInputDType) \
1231 inline PrimExpr OpName(PrimExpr x, Location loc = UnknownLoc()) { \
1232 static const Op op = Op::Get("prim." #OpName); \
1233 PrimType x_ty = x.ty(); \
1234 CheckInputDType(#OpName, x_ty); \
1235 if (x_ty.MatchesElementType(DLDataTypeCode::kDLBfloat, 16)) { \
1236 PrimType bf16_ty = x_ty; \
1237 PrimType f32_ty = \
1238 x_ty.IsScalableVector() \
1239 ? PrimType::ScalableVector(DLDataTypeCode::kDLFloat, 32, x_ty.VScaleFactor()) \
1240 : PrimType::Float(32, x_ty.lanes()); \
1241 PrimExpr x_fp32 = prim::Cast(f32_ty, x, loc); \
1242 PrimExpr result_fp32 = Call(f32_ty, op, {x_fp32}, {}, {}, loc).as_or_throw<PrimExpr>(); \
1243 return prim::Cast(bf16_ty, result_fp32, loc); \
1244 } else { \
1245 return Call(x_ty, op, {x}, {}, {}, loc).as_or_throw<PrimExpr>(); \
1246 } \
1247 }
1248
1249#define TVM_DECLARE_INTRIN_UNARY(OpName) \
1250 TVM_DECLARE_INTRIN_UNARY_WITH_CHECK(OpName, [](const char*, const PrimType&) {})
1251
1252#define TVM_DECLARE_FLOAT_INTRIN_UNARY(OpName) \
1253 TVM_DECLARE_INTRIN_UNARY_WITH_CHECK(OpName, CheckMathUnaryOpInputDType)
1254
1278
1279#define TVM_DECLARE_INTRIN_BINARY(OpName) \
1280 inline PrimExpr OpName(PrimExpr x, PrimExpr y, Location loc = UnknownLoc()) { \
1281 static const Op op = Op::Get("prim." #OpName); \
1282 return Call(x.ty(), op, {x, y}, {}, {}, loc).as_or_throw<PrimExpr>(); \
1283 }
1284
1290
1291template <typename FReduce>
1292inline PrimExpr foldl(FReduce freduce, PrimExpr init_value, const ffi::Array<PrimExpr>& values,
1293 Location loc = UnknownLoc()) {
1294 for (PrimExpr val : values) {
1295 init_value = freduce(init_value, val, loc);
1296 }
1297 return init_value;
1298}
1299
1300} // namespace prim
1301
1302} // namespace tvm
1303#endif // TVM_IR_PRIM_OP_H_
Canonical primitive operators and their registration.
TIR expressions.
#define TVM_DECLARE_INTRIN_UNARY(OpName)
Definition op.h:1249
#define TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD(Name)
Definition op.h:868
#define TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD_SPANNED(Name)
Definition op.h:860
#define TVM_DECLARE_FLOAT_INTRIN_UNARY(OpName)
Definition op.h:1252
#define TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD_SPANNED(Name)
Definition op.h:839
#define TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD(Name)
Definition op.h:830
#define TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD(Name)
Definition op.h:856
#define TVM_DECLARE_INTRIN_BINARY(OpName)
Definition op.h:1279
#define TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD_SPANNED(Name)
Definition op.h:872
#define TVM_TIRX_DLL
Definition base.h:55
Managed reference to CallObj.
Definition expr.h:825
Constant floating point literals in the program.
Definition expr.h:394
Managed reference class to FloatImmObj.
Definition expr.h:411
Constant integer literals in the program.
Definition expr.h:314
ffi::BigInt value
the Internal value.
Definition expr.h:317
Managed reference class to IntImmObj.
Definition expr.h:331
Non-nullable source-location metadata.
Definition location.h:91
Reference-counted handle to a canonical named operator.
Definition op.h:140
Typed reference/view over any Expr whose ExprObj::ty is PrimType.
Definition expr.h:187
Definition type.h:182
TVM_FFI_INLINE DLDataTypeCode code() const
Definition type.h:219
TVM_FFI_INLINE PrimType WithLanes(int lanes) const
Return the same scalar element type with a fixed lane count.
Definition type.h:319
TVM_FFI_INLINE bool IsScalableVector() const
Whether this type is a scalable vector.
Definition type.h:272
TVM_FFI_INLINE bool IsFixedLengthVector() const
Whether this type is a fixed-length vector.
Definition type.h:277
TVM_FFI_INLINE bool MatchesCode(Codes... codes) const
Check whether the dtype code matches any of the provided DLPack codes.
Definition type.h:253
TVM_FFI_INLINE bool MatchesElementType(DLDataTypeCode code, int bits) const
Check the scalar element code and bit width.
Definition type.h:243
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 type.h:324
TVM_FFI_INLINE int32_t lanes() const
Definition type.h:230
ExpectedType ty() const
Definition expr.h:164
Reference to the shared immutable unknown location.
Definition location.h:105
Create a vector where all the elements are value.
Definition vector_expr.h:82
Managed reference to BroadcastObj.
Definition vector_expr.h:104
Managed reference to MulObj.
Definition expr.h:266
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 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 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:1222
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:1292
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.
PrimExpr MakeConstScalar(PrimType dtype, ValueType value, Location loc=UnknownLoc())
Definition op.h:782
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 PrimExpr & neg_inf()
Symbolic negative infinity for unbounded integer intervals.
TVM_TIRX_DLL const Op & atan2_op()
Inverse tangent of y/x with quadrant selection. Arguments: y, x.
TVM_TIRX_DLL const PrimExpr & pos_inf()
Symbolic positive infinity for unbounded integer intervals.
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:1044
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.
TVM_TIRX_DLL bool is_pos_inf(const PrimExpr &value)
Check whether a value is the symbolic positive infinity sentinel.
TVM_TIRX_DLL PrimExpr cast(PrimExpr value, PrimType t, Location loc=UnknownLoc())
cast value to type.
bool IsConstNumber(const PrimExpr &x)
Check whether x is an integer or floating-point constant.
Definition op.h:1018
TVM_TIRX_DLL bool is_neg_inf(const PrimExpr &value)
Check whether a value is the symbolic negative infinity sentinel.
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:1046
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 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....
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:814
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:1034
TVM_TIRX_DLL const Op & asin_op()
Inverse sine. Argument: x.
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:1218
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 PrimExpr ceil(PrimExpr x, Location loc=UnknownLoc())
Round up to the nearest integral value, preserving the input 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:1029
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 analysis.h:41
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
PrimExpr operator-=(PrimExpr &a, PrimExpr b)
Subtract an expression in place.
Definition op.h:255
std::ostream & operator<<(std::ostream &os, CallEffectKind side_effect)
Definition expr.h:757
TVM_TIRX_DLL PrimExpr operator!=(PrimExpr a, PrimExpr b)
not_equal
TVM_TIRX_DLL PrimExpr bitwise_neg(PrimExpr a, Location loc=UnknownLoc())
take bitwise negation of two values
TVM_TIRX_DLL PrimExpr operator<(PrimExpr a, PrimExpr b)
less
void DivAmbiguityError(const TA &a)
Helper function to raise a compiler error about division ambiguity.
Definition op.h:926
TVM_TIRX_DLL PrimExpr operator!(PrimExpr a)
not
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 operator<=(PrimExpr a, PrimExpr b)
less_equal
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:948
TVM_TIRX_DLL PrimExpr operator~(PrimExpr a)
take bitwise negation of two values
TVM_TIRX_DLL PrimExpr neg(PrimExpr a, Location loc=UnknownLoc())
negation.
TVM_TIRX_DLL PrimExpr operator>=(PrimExpr a, PrimExpr b)
greater_equal
TVM_TIRX_DLL PrimExpr operator+(PrimExpr a, PrimExpr b)
add operator
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 operator>(PrimExpr a, PrimExpr b)
greater
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 operator||(PrimExpr a, PrimExpr b)
or
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 operator^(PrimExpr a, PrimExpr b)
take bitwise xor of two values
TVM_TIRX_DLL PrimExpr add(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
add operator
PrimExpr operator*=(PrimExpr &a, PrimExpr b)
Multiply an expression in place.
Definition op.h:261
TVM_TIRX_DLL PrimExpr operator&(PrimExpr a, PrimExpr b)
take bitwise and of two values
PrimExpr operator+=(PrimExpr &a, PrimExpr b)
Add an expression in place.
Definition op.h:249
TVM_TIRX_DLL PrimExpr operator==(PrimExpr a, PrimExpr b)
equal
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:954
TVM_TIRX_DLL PrimExpr operator>>(PrimExpr a, PrimExpr b)
right shift operator
TVM_TIRX_DLL PrimExpr shapediv(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
compute ceil(a / b) where a and b are non-negative.
PrimExpr max(PrimExpr source, ffi::Array< s_tir::IterVar > axis, ffi::Array< PrimExpr > init={}, Location loc=UnknownLoc())
max of source expression over axis
TVM_TIRX_DLL PrimExpr ceildiv(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
compute ceil(a / b)
TVM_TIRX_DLL PrimExpr operator|(PrimExpr a, PrimExpr b)
take bitwise or of two values
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
PrimExpr min(PrimExpr source, ffi::Array< s_tir::IterVar > axis, ffi::Array< PrimExpr > init={}, Location loc=UnknownLoc())
max of source expression over axis
TVM_TIRX_DLL PrimExpr operator&&(PrimExpr a, PrimExpr b)
and
TVM_TIRX_DLL PrimExpr operator*(PrimExpr a, PrimExpr b)
multiplication operator
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.
TVM_TIRX_DLL PrimExpr operator-(PrimExpr a, PrimExpr b)
subtraction operator