tvm
Loading...
Searching...
No Matches
Namespaces | Macros | Functions
op.h File Reference

Common operators defined for Expr. More...

#include <tvm/ir/expr.h>
#include <tvm/ir/op.h>
#include <tvm/ir/prim/builtin.h>
#include <tvm/ir/prim/expr.h>
#include <tvm/ir/type.h>
#include <tvm/tirx/builtin.h>
#include <tvm/tirx/op_attr_types.h>
#include <tvm/tirx/stmt.h>
#include <algorithm>
#include <limits>
#include <type_traits>
#include <utility>
Include dependency graph for op.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  tvm
 An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
 
namespace  tvm::tirx
 

Macros

#define TVM_TIR_REGISTER_OP(OpName)
 
#define TVM_TIRX_REGISTER_OP(OpName)   TVM_TIR_REGISTER_OP(OpName)
 
#define TVM_DECLARE_INTRIN_UNARY_WITH_CHECK(OpName, CheckInputDType)
 
#define TVM_DECLARE_INTRIN_UNARY(OpName)    TVM_DECLARE_INTRIN_UNARY_WITH_CHECK(OpName, [](const char*, const PrimType&) {})
 
#define TVM_DECLARE_FLOAT_INTRIN_UNARY(OpName)    TVM_DECLARE_INTRIN_UNARY_WITH_CHECK(OpName, CheckMathUnaryOpInputDType)
 
#define TVM_DECLARE_INTRIN_BINARY(OpName)
 
#define TVM_DEFINE_ASSIGN_OP_OVERLOAD(Name, OpFunc)
 
#define TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD(Name)
 
#define TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD_SPANNED(Name)
 
#define TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD(Name)
 
#define TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD_SPANNED(Name)
 
#define TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD(Name)
 
#define TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD_SPANNED(Name)
 

Functions

Type tvm::GetType (const PrimExpr &expr)
 Get the type of the expression under the unified type system.
 
Type tvm::GetTypeFromRuntimeDataType (DLDataType dtype)
 Get the type corresponding to a runtime DLPack dtype.
 
PrimExpr tvm::thread_return (Span span=Span())
 Return from a thread.
 
PrimExpr tvm::continue_loop (Span span=Span())
 Continue current loop.
 
PrimExpr tvm::break_loop (Span span=Span())
 Break current loop.
 
PrimExpr tvm::max_value (PrimType dtype, Span span=Span())
 
PrimExpr tvm::min_value (PrimType dtype, Span span=Span())
 
PrimExpr tvm::infinity (PrimType dtype, Span span=Span())
 
PrimExpr tvm::cast (PrimType t, PrimExpr value, Span span=Span())
 cast value to type.
 
PrimExpr tvm::reinterpret (PrimType t, PrimExpr value, Span span=Span())
 perform reinterpret cast value to type.
 
Expr tvm::reinterpret (Type target_ty, Expr value, Span span=Span())
 Perform a reinterpret cast involving an exact primitive or pointer type.
 
PrimExpr tvm::add (PrimExpr a, PrimExpr b, Span span=Span())
 add operator
 
PrimExpr tvm::sub (PrimExpr a, PrimExpr b, Span span=Span())
 subtraction operator
 
PrimExpr tvm::neg (PrimExpr a, Span span=Span())
 negation.
 
PrimExpr tvm::mul (PrimExpr a, PrimExpr b, Span span=Span())
 multiplication operator
 
PrimExpr tvm::left_shift (PrimExpr a, PrimExpr b, Span span=Span())
 left shift operator
 
PrimExpr tvm::right_shift (PrimExpr a, PrimExpr b, Span span=Span())
 right shift operator
 
PrimExpr tvm::greater (PrimExpr a, PrimExpr b, Span span=Span())
 greater
 
PrimExpr tvm::greater_equal (PrimExpr a, PrimExpr b, Span span=Span())
 greater_equal
 
PrimExpr tvm::less (PrimExpr a, PrimExpr b, Span span=Span())
 less
 
PrimExpr tvm::less_equal (PrimExpr a, PrimExpr b, Span span=Span())
 less_equal
 
PrimExpr tvm::equal (PrimExpr a, PrimExpr b, Span span=Span())
 equal
 
PrimExpr tvm::not_equal (PrimExpr a, PrimExpr b, Span span=Span())
 not_equal
 
PrimExpr tvm::logical_and (PrimExpr a, PrimExpr b, Span span=Span())
 and
 
PrimExpr tvm::logical_or (PrimExpr a, PrimExpr b, Span span=Span())
 or
 
PrimExpr tvm::logical_not (PrimExpr a, Span span=Span())
 not
 
PrimExpr tvm::div (PrimExpr a, PrimExpr b, Span span=Span())
 compute division in C semantics.
 
PrimExpr tvm::truncdiv (PrimExpr a, PrimExpr b, Span span=Span())
 compute trunc(a / b)
 
PrimExpr tvm::truncmod (PrimExpr a, PrimExpr b, Span span=Span())
 compute the remainder of truncdiv
 
PrimExpr tvm::indexdiv (PrimExpr a, PrimExpr b, Span span=Span())
 compute floor(a / b) where a and b are non-negative.
 
PrimExpr tvm::shapediv (PrimExpr a, PrimExpr b, Span span=Span())
 compute ceil(a / b) where a and b are non-negative.
 
PrimExpr tvm::indexmod (PrimExpr a, PrimExpr b, Span span=Span())
 compute the remainder floor(a / b) where a and b are non-negative.
 
PrimExpr tvm::floordiv (PrimExpr a, PrimExpr b, Span span=Span())
 compute floor(a / b)
 
PrimExpr tvm::logaddexp (PrimExpr a, PrimExpr b, Span span=Span())
 Compute log(exp(a) + exp(b)).
 
PrimExpr tvm::ceildiv (PrimExpr a, PrimExpr b, Span span=Span())
 compute ceil(a / b)
 
PrimExpr tvm::floormod (PrimExpr a, PrimExpr b, Span span=Span())
 compute the remainder of floordiv
 
PrimExpr tvm::max (PrimExpr a, PrimExpr b, Span span=Span())
 take maximum of two values
 
PrimExpr tvm::min (PrimExpr a, PrimExpr b, Span span=Span())
 take minimum of two values
 
PrimExpr tvm::bitwise_and (PrimExpr a, PrimExpr b, Span span=Span())
 take bitwise and of two values
 
PrimExpr tvm::bitwise_or (PrimExpr a, PrimExpr b, Span span=Span())
 take bitwise or of two values
 
PrimExpr tvm::bitwise_xor (PrimExpr a, PrimExpr b, Span span=Span())
 take bitwise xor of two values
 
PrimExpr tvm::bitwise_neg (PrimExpr a, Span span=Span())
 take bitwise negation of two values
 
PrimExpr tvm::if_then_else (PrimExpr cond, PrimExpr true_value, PrimExpr false_value, Span span=Span())
 Conditional expression.
 
PrimExpr tvm::likely (PrimExpr cond, Span span=Span())
 Mark condition as likely.
 
PrimExpr tvm::pow (PrimExpr x, PrimExpr y, Span span=Span())
 Calculate power(x, y)
 
PrimExpr tvm::abs (PrimExpr x, Span span=Span())
 Calculate absolute value of x.
 
PrimExpr tvm::isnan (PrimExpr x, Span span=Span())
 Check if x is NaN.
 
PrimExpr tvm::isfinite (PrimExpr x, Span span=Span())
 Check if x is finite.
 
PrimExpr tvm::isinf (PrimExpr x, Span span=Span())
 Check if x is infinite.
 
PrimExpr tvm::sum (PrimExpr source, ffi::Array< tirx::IterVar > axis, ffi::Array< PrimExpr > init={}, Span span=Span())
 sum of source expression over axis
 
PrimExpr tvm::all (PrimExpr source, ffi::Array< tirx::IterVar > axis, ffi::Array< PrimExpr > init={}, Span span=Span())
 logical And of source expression over axis
 
PrimExpr tvm::any (PrimExpr source, ffi::Array< tirx::IterVar > axis, ffi::Array< PrimExpr > init={}, Span span=Span())
 logical Or of source expression over axis
 
PrimExpr tvm::max (PrimExpr source, ffi::Array< tirx::IterVar > axis, ffi::Array< PrimExpr > init={}, Span span=Span())
 max of source expression over axis
 
PrimExpr tvm::min (PrimExpr source, ffi::Array< tirx::IterVar > axis, ffi::Array< PrimExpr > init={}, Span span=Span())
 max of source expression over axis
 
PrimExpr tvm::prod (PrimExpr source, ffi::Array< tirx::IterVar > axis, ffi::Array< PrimExpr > init={}, Span span=Span())
 product of source expression over axis
 
PrimExpr tvm::floor (PrimExpr x, Span span=Span())
 Calculate floor(x)
 
PrimExpr tvm::ceil (PrimExpr x, Span span=Span())
 Calculate ceil(x)
 
PrimExpr tvm::round (PrimExpr x, Span span=Span())
 Round x to the nearest integer, ties to even.
 
PrimExpr tvm::nearbyint (PrimExpr x, Span span=Span())
 Round x to the nearest integer, ties to even.
 
PrimExpr tvm::trunc (PrimExpr x, Span span=Span())
 Calculate trunc(x)
 
PrimExpr tvm::LargeUIntImm (PrimType value_ty, int64_t low, int64_t high, Span span=Span())
 Construct a large uint constant by its low 32 bits and high 32bits.
 
PrimExpr tvm::q_multiply_shift (PrimExpr x, PrimExpr y, PrimExpr q, PrimExpr s, Span span=Span())
 Execute a multiplication between two Q-numbers x and y followed by a right shift s. The mathematical expression is:
 
PrimExpr tvm::fast_erf_float_expr (PrimExpr arg, int bits)
 Fast_erf_float expression from Eigen.
 
void tvm::CheckMathUnaryOpInputDType (const char *op_name, const PrimType &dtype)
 
PrimExpr tvm::exp (PrimExpr x, Span span=Span())
 
PrimExpr tvm::exp2 (PrimExpr x, Span span=Span())
 
PrimExpr tvm::exp10 (PrimExpr x, Span span=Span())
 
PrimExpr tvm::erf (PrimExpr x, Span span=Span())
 
PrimExpr tvm::tanh (PrimExpr x, Span span=Span())
 
PrimExpr tvm::sigmoid (PrimExpr x, Span span=Span())
 
PrimExpr tvm::sqrt (PrimExpr x, Span span=Span())
 
PrimExpr tvm::rsqrt (PrimExpr x, Span span=Span())
 
PrimExpr tvm::log (PrimExpr x, Span span=Span())
 
PrimExpr tvm::log2 (PrimExpr x, Span span=Span())
 
PrimExpr tvm::log10 (PrimExpr x, Span span=Span())
 
PrimExpr tvm::log1p (PrimExpr x, Span span=Span())
 
PrimExpr tvm::popcount (PrimExpr x, Span span=Span())
 
PrimExpr tvm::tan (PrimExpr x, Span span=Span())
 
PrimExpr tvm::cos (PrimExpr x, Span span=Span())
 
PrimExpr tvm::cosh (PrimExpr x, Span span=Span())
 
PrimExpr tvm::sin (PrimExpr x, Span span=Span())
 
PrimExpr tvm::sinh (PrimExpr x, Span span=Span())
 
PrimExpr tvm::asin (PrimExpr x, Span span=Span())
 
PrimExpr tvm::acos (PrimExpr x, Span span=Span())
 
PrimExpr tvm::atan (PrimExpr x, Span span=Span())
 
PrimExpr tvm::acosh (PrimExpr x, Span span=Span())
 
PrimExpr tvm::asinh (PrimExpr x, Span span=Span())
 
PrimExpr tvm::atanh (PrimExpr x, Span span=Span())
 
PrimExpr tvm::clz (PrimExpr x, Span span=Span())
 
PrimExpr tvm::atan2 (PrimExpr x, PrimExpr y, Span span=Span())
 
PrimExpr tvm::nextafter (PrimExpr x, PrimExpr y, Span span=Span())
 
PrimExpr tvm::copysign (PrimExpr x, PrimExpr y, Span span=Span())
 
PrimExpr tvm::hypot (PrimExpr x, PrimExpr y, Span span=Span())
 
PrimExpr tvm::ldexp (PrimExpr x, PrimExpr y, Span span=Span())
 
bool tvm::tirx::IsPointerType (const Type &type, DLDataType element_type)
 Check if type is a pointer to a runtime element type.
 
template<typename ValueType , typename = typename std::enable_if<std::is_standard_layout<ValueType>::value && std::is_trivial<ValueType>::value>::type>
PrimExpr tvm::tirx::MakeConst (PrimType dtype, ValueType value, Span span=Span())
 Make a const value with certain data type.
 
Expr tvm::tirx::ConstHandle (int64_t value, Span span=Span())
 Make a constant opaque-pointer value.
 
const int64_ttvm::tirx::as_const_int (const PrimExpr &x)
 Get x as constant int expression.
 
bool tvm::tirx::is_const_int (const PrimExpr &x, int64_t value)
 Check whether x is a constant integer expression.
 
bool tvm::tirx::is_no_op (const tirx::Stmt &stmt)
 Check whether stmt is nop.
 
bool tvm::tirx::is_one (const PrimExpr &x)
 Check whether x is a constant integer 1.
 
bool tvm::tirx::is_zero (const PrimExpr &x)
 Check whether x is a constant integer 0.
 
bool tvm::tirx::is_const_int (const PrimExpr &x)
 Check whether x is an integer constant.
 
bool tvm::tirx::is_const_number (const PrimExpr &x)
 Check whether x is an integer/float constant.
 
template<typename FReduce >
PrimExpr tvm::tirx::foldl (FReduce freduce, PrimExpr init_value, const ffi::Array< PrimExpr > &values, Span span=Span())
 Left fold.
 
bool tvm::tirx::is_const_power_of_two_integer (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.
 
bool tvm::tirx::is_positive_const (const PrimExpr &a)
 
bool tvm::tirx::is_negative_const (const PrimExpr &a)
 
template<typename ValueType >
PrimExpr tvm::tirx::MakeConstScalar (PrimType dtype, ValueType value, Span span=Span())
 
template<>
PrimExpr tvm::tirx::MakeConstScalar (PrimType dtype, bool value, Span span)
 
PrimExpr tvm::operator+= (PrimExpr &a, PrimExpr b)
 
PrimExpr tvm::operator-= (PrimExpr &a, PrimExpr b)
 
PrimExpr tvm::operator*= (PrimExpr &a, PrimExpr b)
 
PrimExpr tvm::operator+ (const PrimExpr &a, float b)
 
PrimExpr tvm::operator+ (float a, const PrimExpr &b)
 
PrimExpr tvm::operator+ (int a, const PrimExpr &b)
 
PrimExpr tvm::operator+ (const PrimExpr &a, int b)
 
PrimExpr tvm::operator+ (const PrimExpr &a, double b)
 
PrimExpr tvm::operator- (const PrimExpr &a, float b)
 
PrimExpr tvm::operator- (float a, const PrimExpr &b)
 
PrimExpr tvm::operator- (int a, const PrimExpr &b)
 
PrimExpr tvm::operator- (const PrimExpr &a, int b)
 
PrimExpr tvm::operator- (const PrimExpr &a, double b)
 
PrimExpr tvm::operator* (const PrimExpr &a, float b)
 
PrimExpr tvm::operator* (float a, const PrimExpr &b)
 
PrimExpr tvm::operator* (int a, const PrimExpr &b)
 
PrimExpr tvm::operator* (const PrimExpr &a, int b)
 
PrimExpr tvm::operator* (const PrimExpr &a, double b)
 
PrimExpr tvm::operator> (const PrimExpr &a, float b)
 
PrimExpr tvm::operator> (float a, const PrimExpr &b)
 
PrimExpr tvm::operator> (int a, const PrimExpr &b)
 
PrimExpr tvm::operator> (const PrimExpr &a, int b)
 
PrimExpr tvm::operator> (const PrimExpr &a, double b)
 
PrimExpr tvm::operator>= (const PrimExpr &a, float b)
 
PrimExpr tvm::operator>= (float a, const PrimExpr &b)
 
PrimExpr tvm::operator>= (int a, const PrimExpr &b)
 
PrimExpr tvm::operator>= (const PrimExpr &a, int b)
 
PrimExpr tvm::operator>= (const PrimExpr &a, double b)
 
PrimExpr tvm::operator< (const PrimExpr &a, float b)
 
PrimExpr tvm::operator< (float a, const PrimExpr &b)
 
PrimExpr tvm::operator< (int a, const PrimExpr &b)
 
PrimExpr tvm::operator< (const PrimExpr &a, int b)
 
PrimExpr tvm::operator< (const PrimExpr &a, double b)
 
PrimExpr tvm::operator<= (const PrimExpr &a, float b)
 
PrimExpr tvm::operator<= (float a, const PrimExpr &b)
 
PrimExpr tvm::operator<= (int a, const PrimExpr &b)
 
PrimExpr tvm::operator<= (const PrimExpr &a, int b)
 
PrimExpr tvm::operator<= (const PrimExpr &a, double b)
 
PrimExpr tvm::max (const PrimExpr &a, float b, Span span=Span())
 
PrimExpr tvm::max (float a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::max (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::max (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::max (const PrimExpr &a, double b, Span span=Span())
 
PrimExpr tvm::min (const PrimExpr &a, float b, Span span=Span())
 
PrimExpr tvm::min (float a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::min (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::min (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::min (const PrimExpr &a, double b, Span span=Span())
 
PrimExpr tvm::div (const PrimExpr &a, float b, Span span=Span())
 
PrimExpr tvm::div (float a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::div (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::div (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::div (const PrimExpr &a, double b, Span span=Span())
 
PrimExpr tvm::add (const PrimExpr &a, float b, Span span=Span())
 
PrimExpr tvm::add (float a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::add (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::add (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::add (const PrimExpr &a, double b, Span span=Span())
 
PrimExpr tvm::sub (const PrimExpr &a, float b, Span span=Span())
 
PrimExpr tvm::sub (float a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::sub (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::sub (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::sub (const PrimExpr &a, double b, Span span=Span())
 
PrimExpr tvm::mul (const PrimExpr &a, float b, Span span=Span())
 
PrimExpr tvm::mul (float a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::mul (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::mul (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::mul (const PrimExpr &a, double b, Span span=Span())
 
PrimExpr tvm::greater (const PrimExpr &a, float b, Span span=Span())
 
PrimExpr tvm::greater (float a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::greater (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::greater (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::greater (const PrimExpr &a, double b, Span span=Span())
 
PrimExpr tvm::greater_equal (const PrimExpr &a, float b, Span span=Span())
 
PrimExpr tvm::greater_equal (float a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::greater_equal (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::greater_equal (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::greater_equal (const PrimExpr &a, double b, Span span=Span())
 
PrimExpr tvm::less (const PrimExpr &a, float b, Span span=Span())
 
PrimExpr tvm::less (float a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::less (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::less (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::less (const PrimExpr &a, double b, Span span=Span())
 
PrimExpr tvm::less_equal (const PrimExpr &a, float b, Span span=Span())
 
PrimExpr tvm::less_equal (float a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::less_equal (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::less_equal (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::less_equal (const PrimExpr &a, double b, Span span=Span())
 
PrimExpr tvm::indexdiv (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::indexdiv (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::indexmod (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::indexmod (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::truncdiv (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::truncdiv (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::truncmod (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::truncmod (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::floordiv (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::floordiv (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::logaddexp (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::logaddexp (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::floormod (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::floormod (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::right_shift (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::right_shift (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::left_shift (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::left_shift (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::bitwise_and (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::bitwise_and (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::bitwise_or (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::bitwise_or (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::bitwise_xor (const PrimExpr &a, int b, Span span=Span())
 
PrimExpr tvm::bitwise_xor (int a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::operator>> (const PrimExpr &a, int b)
 
PrimExpr tvm::operator>> (int a, const PrimExpr &b)
 
PrimExpr tvm::operator<< (const PrimExpr &a, int b)
 
PrimExpr tvm::operator<< (int a, const PrimExpr &b)
 
PrimExpr tvm::operator& (const PrimExpr &a, int b)
 
PrimExpr tvm::operator& (int a, const PrimExpr &b)
 
PrimExpr tvm::operator| (const PrimExpr &a, int b)
 
PrimExpr tvm::operator| (int a, const PrimExpr &b)
 
PrimExpr tvm::operator^ (const PrimExpr &a, int b)
 
PrimExpr tvm::operator^ (int a, const PrimExpr &b)
 
PrimExpr tvm::operator&& (const PrimExpr &a, bool b)
 
PrimExpr tvm::operator&& (bool a, const PrimExpr &b)
 
PrimExpr tvm::operator|| (const PrimExpr &a, bool b)
 
PrimExpr tvm::operator|| (bool a, const PrimExpr &b)
 
PrimExpr tvm::logical_and (const PrimExpr &a, bool b, Span span=Span())
 
PrimExpr tvm::logical_and (bool a, const PrimExpr &b, Span span=Span())
 
PrimExpr tvm::logical_or (const PrimExpr &a, bool b, Span span=Span())
 
PrimExpr tvm::logical_or (bool a, const PrimExpr &b, Span span=Span())
 
template<typename TA >
void tvm::DivAmbiguityError (const TA &a)
 Helper function to raise a compiler error about division ambiguity.
 
template<typename TB >
PrimExpr tvm::operator/ (const PrimExpr &a, const TB &b)
 
template<typename TB >
PrimExpr tvm::operator/= (const PrimExpr &a, const TB &b)
 
template<typename TB >
PrimExpr tvm::operator% (const PrimExpr &a, const TB &b)
 

Detailed Description

Common operators defined for Expr.

Note
Most of the operator defined here perform simple constant folding when the type is int32 or int64 for simplifying the index expressions.

Macro Definition Documentation

◆ TVM_DECLARE_FLOAT_INTRIN_UNARY

#define TVM_DECLARE_FLOAT_INTRIN_UNARY (   OpName)     TVM_DECLARE_INTRIN_UNARY_WITH_CHECK(OpName, CheckMathUnaryOpInputDType)

◆ TVM_DECLARE_INTRIN_BINARY

#define TVM_DECLARE_INTRIN_BINARY (   OpName)
Value:
inline PrimExpr OpName(PrimExpr x, PrimExpr y, Span span = Span()) { \
static const Op op = Op::Get("tirx." #OpName); \
return Call(x.ty(), op, {x, y}, {}, {}, span).as_or_throw<PrimExpr>(); \
}

◆ TVM_DECLARE_INTRIN_UNARY

#define TVM_DECLARE_INTRIN_UNARY (   OpName)     TVM_DECLARE_INTRIN_UNARY_WITH_CHECK(OpName, [](const char*, const PrimType&) {})

◆ TVM_DECLARE_INTRIN_UNARY_WITH_CHECK

#define TVM_DECLARE_INTRIN_UNARY_WITH_CHECK (   OpName,
  CheckInputDType 
)
Value:
inline PrimExpr OpName(PrimExpr x, Span span = Span()) { \
static const Op op = Op::Get("tirx." #OpName); \
PrimType x_ty = x.ty(); \
CheckInputDType(#OpName, x_ty); \
if (x_ty.MatchesElementType(DLDataTypeCode::kDLBfloat, 16)) { \
PrimType bf16_ty = x_ty; \
PrimType f32_ty = \
x_ty.IsScalableVector() \
? PrimType::ScalableVector(DLDataTypeCode::kDLFloat, 32, x_ty.VScaleFactor()) \
: PrimType::Float(32, x_ty.lanes()); \
PrimExpr x_fp32 = prim::Cast(f32_ty, x, span); \
PrimExpr result_fp32 = Call(f32_ty, op, {x_fp32}, {}, {}, span).as_or_throw<PrimExpr>(); \
return prim::Cast(bf16_ty, result_fp32, span); \
} else { \
return Call(x_ty, op, {x}, {}, {}, span).as_or_throw<PrimExpr>(); \
} \
}

◆ TVM_DEFINE_ASSIGN_OP_OVERLOAD

#define TVM_DEFINE_ASSIGN_OP_OVERLOAD (   Name,
  OpFunc 
)
Value:
inline PrimExpr Name(PrimExpr& a, PrimExpr b) { \
a = OpFunc(a, b); \
return a; \
}

◆ TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD

#define TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD (   Name)
Value:
inline PrimExpr Name(const PrimExpr& a, float b) { return Name(a, PrimExpr(b)); } \
inline PrimExpr Name(float a, const PrimExpr& b) { return Name(PrimExpr(a), b); } \
inline PrimExpr Name(int a, const PrimExpr& b) { return Name(tirx::MakeConst(b.ty(), a), b); } \
inline PrimExpr Name(const PrimExpr& a, int b) { return Name(a, tirx::MakeConst(a.ty(), b)); } \
inline PrimExpr Name(const PrimExpr& a, double b) { \
return Name(a, FloatImm(PrimType::Float(64), b)); \
}

◆ TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD_SPANNED

#define TVM_DEFINE_BINOP_CONST_VAL_OVERLOAD_SPANNED (   Name)
Value:
inline PrimExpr Name(const PrimExpr& a, float b, Span span = Span()) { \
return Name(a, PrimExpr(b), span); \
} \
inline PrimExpr Name(float a, const PrimExpr& b, Span span = Span()) { \
return Name(PrimExpr(a), b, span); \
} \
inline PrimExpr Name(int a, const PrimExpr& b, Span span = Span()) { \
return Name(tirx::MakeConst(b.ty(), a), b, span); \
} \
inline PrimExpr Name(const PrimExpr& a, int b, Span span = Span()) { \
return Name(a, tirx::MakeConst(a.ty(), b), span); \
} \
inline PrimExpr Name(const PrimExpr& a, double b, Span span = Span()) { \
return Name(a, FloatImm(PrimType::Float(64), b), span); \
}

◆ TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD

#define TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD (   Name)
Value:
inline PrimExpr Name(const PrimExpr& a, int b) { return Name(a, tirx::MakeConst(a.ty(), b)); } \
inline PrimExpr Name(int a, const PrimExpr& b) { return Name(tirx::MakeConst(b.ty(), a), b); }

◆ TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD_SPANNED

#define TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD_SPANNED (   Name)
Value:
inline PrimExpr Name(const PrimExpr& a, int b, Span span = Span()) { \
return Name(a, tirx::MakeConst(a.ty(), b), span); \
} \
inline PrimExpr Name(int a, const PrimExpr& b, Span span = Span()) { \
return Name(tirx::MakeConst(b.ty(), a), b, span); \
}

◆ TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD

#define TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD (   Name)
Value:
inline PrimExpr Name(const PrimExpr& a, bool b) { return Name(a, PrimExpr(b)); } \
inline PrimExpr Name(bool a, const PrimExpr& b) { return Name(PrimExpr(a), b); }

◆ TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD_SPANNED

#define TVM_DEFINE_LOGICAL_OP_CONST_VAL_OVERLOAD_SPANNED (   Name)
Value:
inline PrimExpr Name(const PrimExpr& a, bool b, Span span = Span()) { \
return Name(a, PrimExpr(b), span); \
} \
inline PrimExpr Name(bool a, const PrimExpr& b, Span span = Span()) { \
return Name(PrimExpr(a), b, span); \
}

◆ TVM_TIR_REGISTER_OP

#define TVM_TIR_REGISTER_OP (   OpName)
Value:
TVM_REGISTER_OP("tirx." OpName) \
.set_attr<TScriptPrinterName>("TScriptPrinterName", OpName) \
.set_attr<TIRxOpCategory>("TIRxOpCategory", ffi::String("builtin"), /*plevel=*/1)
#define TVM_REGISTER_OP(OpName)
Register a new operator, or set attribute of the corresponding op.
Definition op.h:351

◆ TVM_TIRX_REGISTER_OP

#define TVM_TIRX_REGISTER_OP (   OpName)    TVM_TIR_REGISTER_OP(OpName)