tvm
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/type.h>
#include <tvm/tir/builtin.h>
#include <tvm/tir/expr.h>
#include <tvm/tir/stmt.h>
#include <algorithm>
#include <limits>
#include <type_traits>
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

 tvm
 runtime implementation for LibTorch/TorchScript.
 
 tvm::tir
 

Macros

#define TVM_TIR_REGISTER_OP(OpName)    TVM_REGISTER_OP("tir." OpName).set_attr<TScriptPrinterName>("TScriptPrinterName", OpName)
 
#define TVM_DECLARE_INTRIN_UNARY(OpName)
 
#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. More...
 
Type tvm::GetTypeFromRuntimeDataType (const DataType &dtype)
 Get the type corresponding to DataType. More...
 
runtime::DataType tvm::GetRuntimeDataType (const Type &type)
 Get the implied DataType for storing values with type during runtime. More...
 
PrimExpr tvm::ret (PrimExpr value, Span span=Span())
 Return the value. More...
 
PrimExpr tvm::max_value (const DataType &dtype, Span span=Span())
 
PrimExpr tvm::min_value (const DataType &dtype, Span span=Span())
 
PrimExpr tvm::infinity (const DataType &dtype, Span span=Span())
 
PrimExpr tvm::cast (const DataType &t, PrimExpr value, Span span=Span())
 cast value to type. More...
 
PrimExpr tvm::reinterpret (const DataType &t, PrimExpr value, Span span=Span())
 perform reinterpret cast value to type. More...
 
PrimExpr tvm::add (PrimExpr a, PrimExpr b, Span span=Span())
 add operator More...
 
PrimExpr tvm::sub (PrimExpr a, PrimExpr b, Span span=Span())
 subtraction operator More...
 
PrimExpr tvm::neg (PrimExpr a, Span span=Span())
 negation. More...
 
PrimExpr tvm::mul (PrimExpr a, PrimExpr b, Span span=Span())
 multiplication operator More...
 
PrimExpr tvm::left_shift (PrimExpr a, PrimExpr b, Span span=Span())
 left shift operator More...
 
PrimExpr tvm::right_shift (PrimExpr a, PrimExpr b, Span span=Span())
 right shift operator More...
 
PrimExpr tvm::greater (PrimExpr a, PrimExpr b, Span span=Span())
 greater More...
 
PrimExpr tvm::greater_equal (PrimExpr a, PrimExpr b, Span span=Span())
 greater_equal More...
 
PrimExpr tvm::less (PrimExpr a, PrimExpr b, Span span=Span())
 less More...
 
PrimExpr tvm::less_equal (PrimExpr a, PrimExpr b, Span span=Span())
 less_equal More...
 
PrimExpr tvm::equal (PrimExpr a, PrimExpr b, Span span=Span())
 equal More...
 
PrimExpr tvm::not_equal (PrimExpr a, PrimExpr b, Span span=Span())
 not_equal More...
 
PrimExpr tvm::logical_and (PrimExpr a, PrimExpr b, Span span=Span())
 and More...
 
PrimExpr tvm::logical_or (PrimExpr a, PrimExpr b, Span span=Span())
 or More...
 
PrimExpr tvm::logical_not (PrimExpr a, Span span=Span())
 not More...
 
PrimExpr tvm::div (PrimExpr a, PrimExpr b, Span span=Span())
 compute division in C semantics. More...
 
PrimExpr tvm::truncdiv (PrimExpr a, PrimExpr b, Span span=Span())
 compute trunc(a / b) More...
 
PrimExpr tvm::truncmod (PrimExpr a, PrimExpr b, Span span=Span())
 compute the remainder of truncdiv More...
 
PrimExpr tvm::indexdiv (PrimExpr a, PrimExpr b, Span span=Span())
 compute floor(a / b) where a and b are non-negative. More...
 
PrimExpr tvm::shapediv (PrimExpr a, PrimExpr b, Span span=Span())
 compute ceil(a / b) where a and b are non-negative. More...
 
PrimExpr tvm::indexmod (PrimExpr a, PrimExpr b, Span span=Span())
 compute the remainder floor(a / b) where a and b are non-negative. More...
 
PrimExpr tvm::floordiv (PrimExpr a, PrimExpr b, Span span=Span())
 compute floor(a / b) More...
 
PrimExpr tvm::ceildiv (PrimExpr a, PrimExpr b, Span span=Span())
 compute ceil(a / b) More...
 
PrimExpr tvm::floormod (PrimExpr a, PrimExpr b, Span span=Span())
 compute the remainder of floordiv More...
 
PrimExpr tvm::max (PrimExpr a, PrimExpr b, Span span=Span())
 take maximum of two values More...
 
PrimExpr tvm::min (PrimExpr a, PrimExpr b, Span span=Span())
 take minimum of two values More...
 
PrimExpr tvm::bitwise_and (PrimExpr a, PrimExpr b, Span span=Span())
 take bitwise and of two values More...
 
PrimExpr tvm::bitwise_or (PrimExpr a, PrimExpr b, Span span=Span())
 take bitwise or of two values More...
 
PrimExpr tvm::bitwise_xor (PrimExpr a, PrimExpr b, Span span=Span())
 take bitwise xor of two values More...
 
PrimExpr tvm::bitwise_neg (PrimExpr a, Span span=Span())
 take bitwise negation of two values More...
 
PrimExpr tvm::if_then_else (PrimExpr cond, PrimExpr true_value, PrimExpr false_value, Span span=Span())
 Conditional expression. More...
 
PrimExpr tvm::likely (PrimExpr cond, Span span=Span())
 Mark condition as likely. More...
 
PrimExpr tvm::pow (PrimExpr x, PrimExpr y, Span span=Span())
 Calculate power(x, y) More...
 
PrimExpr tvm::abs (PrimExpr x, Span span=Span())
 Calculate absolute value of x. More...
 
PrimExpr tvm::isnan (PrimExpr x, Span span=Span())
 Check if x is NaN. More...
 
PrimExpr tvm::isfinite (PrimExpr x, Span span=Span())
 Check if x is finite. More...
 
PrimExpr tvm::isinf (PrimExpr x, Span span=Span())
 Check if x is infinite. More...
 
PrimExpr tvm::sum (PrimExpr source, Array< tir::IterVar > axis, Array< PrimExpr > init={}, Span span=Span())
 sum of source expression over axis More...
 
PrimExpr tvm::all (PrimExpr source, Array< tir::IterVar > axis, Array< PrimExpr > init={}, Span span=Span())
 logical And of source expression over axis More...
 
PrimExpr tvm::any (PrimExpr source, Array< tir::IterVar > axis, Array< PrimExpr > init={}, Span span=Span())
 logical Or of source expression over axis More...
 
PrimExpr tvm::max (PrimExpr source, Array< tir::IterVar > axis, Array< PrimExpr > init={}, Span span=Span())
 max of source expression over axis More...
 
PrimExpr tvm::min (PrimExpr source, Array< tir::IterVar > axis, Array< PrimExpr > init={}, Span span=Span())
 max of source expression over axis More...
 
PrimExpr tvm::prod (PrimExpr source, Array< tir::IterVar > axis, Array< PrimExpr > init={}, Span span=Span())
 product of source expression over axis More...
 
PrimExpr tvm::floor (PrimExpr x, Span span=Span())
 Calculate floor(x) More...
 
PrimExpr tvm::ceil (PrimExpr x, Span span=Span())
 Calculate ceil(x) More...
 
PrimExpr tvm::round (PrimExpr x, Span span=Span())
 Calculate round(x) More...
 
PrimExpr tvm::nearbyint (PrimExpr x, Span span=Span())
 Calculates std::nearbyint(x) More...
 
PrimExpr tvm::trunc (PrimExpr x, Span span=Span())
 Calculate trunc(x) More...
 
PrimExpr tvm::LargeUIntImm (DataType dtype, int64_t low, int64_t high, Span span=Span())
 Construct a large uint constant by its low 32 bits and high 32bits. More...
 
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: More...
 
PrimExpr tvm::fast_erf_float_expr (PrimExpr arg, int bits)
 Fast_erf_float expression from Eigen. More...
 
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::tir::IsPointerType (const Type &type, const DataType &element_type)
 Check if type is a pointer to a runtime element type. More...
 
template<typename ValueType , typename = typename std::enable_if<std::is_pod<ValueType>::value>::type>
PrimExpr tvm::tir::make_const (DataType t, ValueType value, Span span=Span())
 Make a const value with certain data type. More...
 
PrimExpr tvm::tir::make_zero (DataType t, Span span=Span())
 Make a const zero expr. More...
 
PrimExpr tvm::tir::const_true (int lanes=1, Span span=Span())
 Make a constant true expression. More...
 
PrimExpr tvm::tir::const_false (int lanes=1, Span span=Span())
 Make a constant false expression. More...
 
const int64_t * tvm::tir::as_const_int (const PrimExpr &x)
 Get x as constant int expression. More...
 
bool tvm::tir::is_const_int (const PrimExpr &x, int64_t value)
 Check whether x is a constant integer expression. More...
 
bool tvm::tir::is_no_op (const tir::Stmt &stmt)
 Check whether stmt is nop. More...
 
bool tvm::tir::is_one (const PrimExpr &x)
 Check whether x is a constant integer 1. More...
 
bool tvm::tir::is_zero (const PrimExpr &x)
 Check whether x is a constant integer 0. More...
 
bool tvm::tir::is_const_int (const PrimExpr &x)
 Check whether x is an integer constant. More...
 
bool tvm::tir::is_const_number (const PrimExpr &x)
 Check whether x is an integer/float constant. More...
 
template<typename FReduce >
PrimExpr tvm::tir::foldl (FReduce freduce, PrimExpr init_value, const Array< PrimExpr > &values, Span span=Span())
 Left fold. More...
 
bool tvm::tir::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. More...
 
bool tvm::tir::is_positive_const (const PrimExpr &a)
 
bool tvm::tir::is_negative_const (const PrimExpr &a)
 
template<typename ValueType >
PrimExpr tvm::tir::MakeConstScalar (DataType t, ValueType value, Span span=Span())
 
template<>
PrimExpr tvm::tir::MakeConstScalar (DataType t, 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::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. More...
 
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_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("tir." #OpName); \
return tir::Call(x.dtype(), op, {x, y}, span); \
}
tvm::Op Op
Definition: op.h:34
tvm::Span Span
Definition: base.h:65

◆ TVM_DECLARE_INTRIN_UNARY

#define TVM_DECLARE_INTRIN_UNARY (   OpName)
Value:
inline PrimExpr OpName(PrimExpr x, Span span = Span()) { \
static const Op& op = Op::Get("tir." #OpName); \
if (x.dtype().is_bfloat16()) { \
DataType bf16_dtype = x.dtype(); \
DataType fp32_dtype(kDLFloat, 32, bf16_dtype.lanes()); \
PrimExpr x_fp32 = tir::Cast(fp32_dtype, {x}, span); \
PrimExpr result_fp32 = tir::Call(fp32_dtype, op, {x_fp32}, span); \
return tir::Cast(bf16_dtype, {result_fp32}, span); \
} else { \
return tir::Call(x.dtype(), op, {x}, span); \
} \
}

◆ 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(tir::make_const(b.dtype(), a), b); \
} \
inline PrimExpr Name(const PrimExpr& a, int b) { \
return Name(a, tir::make_const(a.dtype(), b)); \
} \
inline PrimExpr Name(const PrimExpr& a, double b) { \
return Name(a, tir::make_const(DataType::Float(64), b)); \
}
Box< double > Float
Boxed version of C++ double.
Definition: boxed_primitive.h:107
PrimExpr make_const(DataType t, ValueType value, Span span=Span())
Make a const value with certain data type.
Definition: op.h:962

◆ 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(tir::make_const(b.dtype(), a), b, span); \
} \
inline PrimExpr Name(const PrimExpr& a, int b, Span span = Span()) { \
return Name(a, tir::make_const(a.dtype(), b), span); \
} \
inline PrimExpr Name(const PrimExpr& a, double b, Span span = Span()) { \
return Name(a, tir::make_const(DataType::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, tir::make_const(a.dtype(), b)); \
} \
inline PrimExpr Name(int a, const PrimExpr& b) { return Name(tir::make_const(b.dtype(), 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, tir::make_const(a.dtype(), b), span); \
} \
inline PrimExpr Name(int a, const PrimExpr& b, Span span = Span()) { \
return Name(tir::make_const(b.dtype(), 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)     TVM_REGISTER_OP("tir." OpName).set_attr<TScriptPrinterName>("TScriptPrinterName", OpName)