Tiramisu Compiler
|
A class to represent tiramisu expressions. More...
#include <expr.h>
Inherited by tiramisu::sync, and tiramisu::var.
Public Member Functions | |
expr () | |
Create an undefined expression. More... | |
expr (tiramisu::op_t o, tiramisu::primitive_t dtype, tiramisu::expr expr0) | |
Create a cast expression to type t (a unary operator). More... | |
expr (tiramisu::op_t o, tiramisu::expr expr0) | |
Create an expression for a unary operator. More... | |
expr (tiramisu::op_t o, std::string name) | |
Create an expression for a unary operator that applies on a variable. More... | |
expr (tiramisu::op_t o, tiramisu::expr expr0, tiramisu::expr expr1) | |
Construct an expression for a binary operator. More... | |
expr (tiramisu::op_t o, tiramisu::expr expr0, tiramisu::expr expr1, tiramisu::expr expr2) | |
Construct an expression for a ternary operator. More... | |
expr (tiramisu::op_t o, std::string name, std::vector< tiramisu::expr > vec, tiramisu::primitive_t type) | |
Construct an access or a call. More... | |
expr (uint8_t val) | |
Construct an unsigned 8-bit integer expression. More... | |
expr (int8_t val) | |
Construct a signed 8-bit integer expression. More... | |
expr (uint16_t val) | |
Construct an unsigned 16-bit integer expression. More... | |
expr (int16_t val) | |
Construct a signed 16-bit integer expression. More... | |
expr (uint32_t val) | |
Construct an unsigned 32-bit integer expression. More... | |
expr (int32_t val) | |
Construct a signed 32-bit integer expression. More... | |
expr (uint64_t val) | |
Construct an unsigned 64-bit integer expression. More... | |
expr (int64_t val) | |
Construct a signed 64-bit integer expression. More... | |
expr (float val) | |
Construct a 32-bit float expression. More... | |
tiramisu::expr | copy () const |
Copy an expression. More... | |
expr (double val) | |
Construct a 64-bit float expression. More... | |
int64_t | get_int_val () const |
double | get_double_val () const |
const tiramisu::expr & | get_operand (int i) const |
Return the value of the i 'th operand of the expression. More... | |
int | get_n_arg () const |
Return the number of arguments of the operator. More... | |
tiramisu::expr_t | get_expr_type () const |
Return the type of the expression (tiramisu::expr_type). More... | |
tiramisu::primitive_t | get_data_type () const |
Get the data type of the expression. More... | |
const std::string & | get_name () const |
Get the name of the ID or the variable represented by this expressions. More... | |
void | set_name (std::string &name) |
tiramisu::expr | replace_op_in_expr (const std::string &to_replace, const std::string &replace_with) |
tiramisu::op_t | get_op_type () const |
Get the type of the operator (tiramisu::op_t). More... | |
const std::vector< tiramisu::expr > & | get_access () const |
Return a vector of the access of the computation or array. More... | |
const std::vector< tiramisu::expr > & | get_arguments () const |
Return the arguments of an external function call. More... | |
int | get_n_dim_access () const |
Get the number of dimensions in the access vector. More... | |
bool | is_defined () const |
Return true if the expression is defined. More... | |
bool | is_equal (tiramisu::expr e) const |
Return true if e is identical to this expression. More... | |
expr | operator+ (tiramisu::expr other) const |
Addition. More... | |
expr | operator- (tiramisu::expr other) const |
Subtraction. More... | |
expr | operator/ (tiramisu::expr other) const |
Division. More... | |
expr | operator* (tiramisu::expr other) const |
Multiplication. More... | |
expr | operator% (tiramisu::expr other) const |
Modulo. More... | |
expr | operator>> (tiramisu::expr other) const |
Right shift operator. More... | |
expr | operator<< (tiramisu::expr other) const |
Left shift operator. More... | |
tiramisu::expr | operator&& (tiramisu::expr e1) const |
Logical and of two expressions. More... | |
tiramisu::expr | operator|| (tiramisu::expr e1) const |
Logical and of two expressions. More... | |
tiramisu::expr | operator- () const |
Expression multiplied by (-1). More... | |
tiramisu::expr | operator! () const |
Logical NOT of an expression. More... | |
tiramisu::expr & | operator= (tiramisu::expr const &) |
tiramisu::expr | operator< (tiramisu::expr e1) const |
Less than operator. More... | |
tiramisu::expr | operator<= (tiramisu::expr e1) const |
Less than or equal operator. More... | |
tiramisu::expr | operator> (tiramisu::expr e1) const |
Greater than operator. More... | |
tiramisu::expr | operator>= (tiramisu::expr e1) const |
Greater than or equal operator. More... | |
void | set_access (std::vector< tiramisu::expr > vector) |
Set the access of a computation or an array. More... | |
void | set_access_dimension (int i, tiramisu::expr acc) |
Set an element of the vector of accesses of a computation. More... | |
void | set_arguments (std::vector< tiramisu::expr > vector) |
Set the arguments of an external function call. More... | |
void | dump (bool exhaustive) const |
Dump the object on standard output (dump most of the fields of the expression class). More... | |
bool | is_constant () const |
Return true if this expression is a literal constant (i.e., 0, 1, 2, ...). More... | |
bool | is_unbounded () const |
tiramisu::expr | simplify () const |
Simplify the expression. More... | |
std::string | to_str () const |
expr | substitute (std::vector< std::pair< var, expr >> substitutions) const |
Returns a new expression where for every (var, sub) pair in substitutions , var in the original expression is replaced by sub. More... | |
expr | substitute_access (std::string original, std::string substitute) const |
Returns an expression where every access to a computation named original is replaced with an access to a computation named substitute , with the same access indices. More... | |
expr | apply_to_operands (std::function< expr(const expr &)> f) const |
uint8_t | get_uint8_value () const |
Return the actual value of the expression. More... | |
int8_t | get_int8_value () const |
Return the actual value of the expression. More... | |
uint16_t | get_uint16_value () const |
Return the actual value of the expression. More... | |
int16_t | get_int16_value () const |
Return the actual value of the expression. More... | |
uint32_t | get_uint32_value () const |
Return the actual value of the expression. More... | |
int32_t | get_int32_value () const |
Return the actual value of the expression. More... | |
uint64_t | get_uint64_value () const |
Return the actual value of the expression. More... | |
int64_t | get_int64_value () const |
Return the actual value of the expression. More... | |
float | get_float32_value () const |
Return the actual value of the expression. More... | |
double | get_float64_value () const |
Return the actual value of the expression. More... | |
tiramisu::expr | operator== (tiramisu::expr e1) const |
Comparison operator. More... | |
tiramisu::expr | operator!= (tiramisu::expr e1) const |
Comparison operator. More... | |
Static Public Member Functions | |
static expr | unbounded () |
Create a variable that can be used that a dimension is unbounded. More... | |
Protected Attributes | |
std::string | name |
Identifier name. More... | |
tiramisu::primitive_t | dtype |
Data type. More... | |
tiramisu::expr_t | etype |
The type of the expression. More... | |
|
inline |
Create an undefined expression.
Definition at line 231 of file expr.h.
References tiramisu::e_none, tiramisu::o_none, and tiramisu::p_none.
|
inline |
Create a cast expression to type t
(a unary operator).
Definition at line 243 of file expr.h.
References tiramisu::e_op, and tiramisu::o_cast.
|
inline |
Create an expression for a unary operator.
Definition at line 258 of file expr.h.
References tiramisu::e_op, get_data_type(), tiramisu::o_cast, tiramisu::o_floor, tiramisu::p_float32, and tiramisu::p_float64.
|
inline |
Create an expression for a unary operator that applies on a variable.
For example: allocate(A) or free(B).
Definition at line 277 of file expr.h.
References tiramisu::e_op, and tiramisu::p_none.
|
inline |
Construct an expression for a binary operator.
Definition at line 290 of file expr.h.
References dump(), tiramisu::e_op, and get_data_type().
|
inline |
Construct an expression for a ternary operator.
Definition at line 314 of file expr.h.
References tiramisu::e_op, and get_data_type().
|
inline |
Construct an access or a call.
Definition at line 332 of file expr.h.
References tiramisu::e_op, tiramisu::o_access, tiramisu::o_address_of, tiramisu::o_buffer, tiramisu::o_call, and tiramisu::o_lin_index.
|
inline |
Construct an unsigned 8-bit integer expression.
Definition at line 368 of file expr.h.
References tiramisu::e_val, tiramisu::o_none, and tiramisu::p_uint8.
|
inline |
Construct a signed 8-bit integer expression.
Definition at line 381 of file expr.h.
References tiramisu::e_val, tiramisu::o_none, and tiramisu::p_int8.
|
inline |
Construct an unsigned 16-bit integer expression.
Definition at line 394 of file expr.h.
References tiramisu::e_val, tiramisu::o_none, and tiramisu::p_uint16.
|
inline |
Construct a signed 16-bit integer expression.
Definition at line 407 of file expr.h.
References tiramisu::e_val, tiramisu::o_none, and tiramisu::p_int16.
|
inline |
Construct an unsigned 32-bit integer expression.
Definition at line 420 of file expr.h.
References tiramisu::e_val, tiramisu::o_none, and tiramisu::p_uint32.
|
inline |
Construct a signed 32-bit integer expression.
Definition at line 433 of file expr.h.
References tiramisu::e_val, tiramisu::o_none, and tiramisu::p_int32.
|
inline |
Construct an unsigned 64-bit integer expression.
Definition at line 446 of file expr.h.
References tiramisu::e_val, tiramisu::o_none, and tiramisu::p_uint64.
|
inline |
Construct a signed 64-bit integer expression.
Definition at line 459 of file expr.h.
References tiramisu::e_val, tiramisu::o_none, and tiramisu::p_int64.
|
inline |
Construct a 32-bit float expression.
Definition at line 472 of file expr.h.
References tiramisu::e_val, tiramisu::o_none, and tiramisu::p_float32.
|
inline |
Construct a 64-bit float expression.
Definition at line 490 of file expr.h.
References tiramisu::e_val, tiramisu::o_none, and tiramisu::p_float64.
tiramisu::expr tiramisu::expr::copy | ( | ) | const |
Copy an expression.
|
inline |
Dump the object on standard output (dump most of the fields of the expression class).
This is mainly useful for debugging. If exhaustive
is set to true, all the fields of the class are printed. This is useful to find potential initialization problems.
Definition at line 1021 of file expr.h.
References tiramisu::e_none, tiramisu::e_op, tiramisu::e_sync, tiramisu::e_val, tiramisu::e_var, tiramisu::o_access, tiramisu::o_address, tiramisu::o_address_of, tiramisu::o_allocate, tiramisu::o_call, tiramisu::o_free, tiramisu::o_lin_index, tiramisu::p_float32, tiramisu::p_float64, tiramisu::p_int16, tiramisu::p_int32, tiramisu::p_int64, tiramisu::p_int8, tiramisu::p_uint16, tiramisu::p_uint32, tiramisu::p_uint64, tiramisu::p_uint8, tiramisu::str_from_tiramisu_type_expr(), tiramisu::str_from_tiramisu_type_primitive(), and tiramisu::str_tiramisu_type_op().
Referenced by expr(), and tiramisu::computation::operator()().
|
inline |
Return a vector of the access of the computation or array.
For example, for the computation C0(i,j), this function will return the vector {i, j} where i and j are both tiramisu expressions. For a buffer access A[i+1,j], it will return also {i+1, j}.
Definition at line 762 of file expr.h.
References tiramisu::e_op, tiramisu::o_access, tiramisu::o_address_of, tiramisu::o_buffer, tiramisu::o_dummy, and tiramisu::o_lin_index.
|
inline |
Return the arguments of an external function call.
Definition at line 775 of file expr.h.
References tiramisu::e_op, and tiramisu::o_call.
|
inline |
Get the data type of the expression.
Definition at line 694 of file expr.h.
Referenced by expr(), tiramisu::operator*(), tiramisu::operator+(), and tiramisu::operator-().
|
inline |
Definition at line 639 of file expr.h.
References tiramisu::e_val, tiramisu::p_float32, tiramisu::p_float64, and result.
Referenced by is_equal().
|
inline |
|
inline |
Return the actual value of the expression.
Definition at line 568 of file expr.h.
References tiramisu::e_val, and tiramisu::p_float32.
|
inline |
Return the actual value of the expression.
Definition at line 576 of file expr.h.
References tiramisu::e_val, and tiramisu::p_float64.
|
inline |
Return the actual value of the expression.
Definition at line 528 of file expr.h.
References tiramisu::e_val, and tiramisu::p_int16.
|
inline |
Return the actual value of the expression.
Definition at line 544 of file expr.h.
References tiramisu::e_val, and tiramisu::p_int32.
|
inline |
Return the actual value of the expression.
Definition at line 560 of file expr.h.
References tiramisu::e_val, and tiramisu::p_int64.
|
inline |
Return the actual value of the expression.
Definition at line 512 of file expr.h.
References tiramisu::e_val, and tiramisu::p_int8.
|
inline |
Definition at line 585 of file expr.h.
References tiramisu::e_val, tiramisu::p_float32, tiramisu::p_float64, tiramisu::p_int16, tiramisu::p_int32, tiramisu::p_int64, tiramisu::p_int8, tiramisu::p_uint16, tiramisu::p_uint32, tiramisu::p_uint64, tiramisu::p_uint8, and result.
Referenced by is_equal().
|
inline |
Return the number of arguments of the operator.
Definition at line 676 of file expr.h.
References tiramisu::e_op.
|
inline |
Get the number of dimensions in the access vector.
Definition at line 786 of file expr.h.
References tiramisu::e_op, and tiramisu::o_access.
|
inline |
Get the name of the ID or the variable represented by this expressions.
Definition at line 702 of file expr.h.
References tiramisu::e_var, tiramisu::o_access, tiramisu::o_address, tiramisu::o_address_of, tiramisu::o_allocate, tiramisu::o_buffer, tiramisu::o_call, tiramisu::o_dummy, tiramisu::o_free, and tiramisu::o_lin_index.
Referenced by tiramisu::computation::fuse_after().
|
inline |
Get the type of the operator (tiramisu::op_t).
|
inline |
Return the value of the i
'th operand of the expression.
i
can be 0, 1 or 2.
Definition at line 665 of file expr.h.
References tiramisu::e_op.
|
inline |
Return the actual value of the expression.
Definition at line 520 of file expr.h.
References tiramisu::e_val, and tiramisu::p_uint16.
|
inline |
Return the actual value of the expression.
Definition at line 536 of file expr.h.
References tiramisu::e_val, and tiramisu::p_uint32.
|
inline |
Return the actual value of the expression.
Definition at line 552 of file expr.h.
References tiramisu::e_val, and tiramisu::p_uint64.
|
inline |
Return the actual value of the expression.
Definition at line 504 of file expr.h.
References tiramisu::e_val, and tiramisu::p_uint8.
|
inline |
Return true if this expression is a literal constant (i.e., 0, 1, 2, ...).
Definition at line 1160 of file expr.h.
References tiramisu::e_val.
|
inline |
|
inline |
Return true if e
is identical to this expression.
Definition at line 805 of file expr.h.
References dtype, tiramisu::e_val, etype, get_double_val(), get_int_val(), name, tiramisu::operator%(), tiramisu::operator*(), tiramisu::operator+(), tiramisu::operator-(), tiramisu::operator/(), tiramisu::operator<<(), tiramisu::operator>>(), tiramisu::p_float32, and tiramisu::p_float64.
|
inline |
Logical NOT of an expression.
Definition at line 930 of file expr.h.
References tiramisu::o_logical_not.
|
inline |
expr tiramisu::expr::operator% | ( | tiramisu::expr | other | ) | const |
Modulo.
|
inline |
Logical and of two expressions.
Definition at line 906 of file expr.h.
References tiramisu::o_logical_and.
expr tiramisu::expr::operator* | ( | tiramisu::expr | other | ) | const |
Multiplication.
expr tiramisu::expr::operator+ | ( | tiramisu::expr | other | ) | const |
Addition.
expr tiramisu::expr::operator- | ( | tiramisu::expr | other | ) | const |
Subtraction.
|
inline |
expr tiramisu::expr::operator/ | ( | tiramisu::expr | other | ) | const |
Division.
|
inline |
expr tiramisu::expr::operator<< | ( | tiramisu::expr | other | ) | const |
Left shift operator.
|
inline |
tiramisu::expr& tiramisu::expr::operator= | ( | tiramisu::expr const & | ) |
|
inline |
|
inline |
|
inline |
expr tiramisu::expr::operator>> | ( | tiramisu::expr | other | ) | const |
Right shift operator.
|
inline |
Logical and of two expressions.
Definition at line 914 of file expr.h.
References tiramisu::o_logical_or.
|
inline |
Definition at line 732 of file expr.h.
References replace_op_in_expr().
Referenced by replace_op_in_expr().
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 718 of file expr.h.
References tiramisu::e_var, tiramisu::o_access, tiramisu::o_address_of, tiramisu::o_allocate, tiramisu::o_call, tiramisu::o_dummy, tiramisu::o_free, and tiramisu::o_lin_index.
|
inline |
Simplify the expression.
Definition at line 1179 of file expr.h.
References tiramisu::e_none, tiramisu::e_op, tiramisu::e_val, tiramisu::e_var, tiramisu::o_abs, tiramisu::o_access, tiramisu::o_acos, tiramisu::o_acosh, tiramisu::o_add, tiramisu::o_address, tiramisu::o_allocate, tiramisu::o_asin, tiramisu::o_asinh, tiramisu::o_atan, tiramisu::o_atanh, tiramisu::o_call, tiramisu::o_cast, tiramisu::o_ceil, tiramisu::o_cond, tiramisu::o_cos, tiramisu::o_cosh, tiramisu::o_div, tiramisu::o_eq, tiramisu::o_expo, tiramisu::o_floor, tiramisu::o_free, tiramisu::o_ge, tiramisu::o_gt, tiramisu::o_le, tiramisu::o_left_shift, tiramisu::o_lerp, tiramisu::o_log, tiramisu::o_logical_and, tiramisu::o_logical_not, tiramisu::o_logical_or, tiramisu::o_lt, tiramisu::o_max, tiramisu::o_min, tiramisu::o_minus, tiramisu::o_mod, tiramisu::o_mul, tiramisu::o_ne, tiramisu::o_right_shift, tiramisu::o_round, tiramisu::o_select, tiramisu::o_sin, tiramisu::o_sinh, tiramisu::o_sqrt, tiramisu::o_sub, tiramisu::o_tan, tiramisu::o_tanh, tiramisu::o_trunc, and tiramisu::p_int32.
Returns a new expression where for every (var, sub) pair in substitutions
, var in the original expression is replaced by sub.
For example: if substitutions
is {(i, 5), (j, i)}, and the original expression is i + j * 2, then this method returns 5 + i * 2.
Referenced by tiramisu::computation::operator()().
expr tiramisu::expr::substitute_access | ( | std::string | original, |
std::string | substitute | ||
) | const |
Returns an expression where every access to a computation named original
is replaced with an access to a computation named substitute
, with the same access indices.
An example where this is useful is when modifying a computation that was designed to work with a host buffer to work with a GPU buffer.
|
inline |
Definition at line 1318 of file expr.h.
References tiramisu::e_none, tiramisu::e_op, tiramisu::e_sync, tiramisu::e_val, tiramisu::e_var, tiramisu::o_abs, tiramisu::o_access, tiramisu::o_acos, tiramisu::o_acosh, tiramisu::o_add, tiramisu::o_address, tiramisu::o_address_of, tiramisu::o_allocate, tiramisu::o_asin, tiramisu::o_asinh, tiramisu::o_atan, tiramisu::o_atanh, tiramisu::o_buffer, tiramisu::o_call, tiramisu::o_cast, tiramisu::o_ceil, tiramisu::o_cond, tiramisu::o_cos, tiramisu::o_cosh, tiramisu::o_div, tiramisu::o_eq, tiramisu::o_expo, tiramisu::o_floor, tiramisu::o_free, tiramisu::o_ge, tiramisu::o_gt, tiramisu::o_le, tiramisu::o_left_shift, tiramisu::o_lerp, tiramisu::o_lin_index, tiramisu::o_log, tiramisu::o_logical_and, tiramisu::o_logical_not, tiramisu::o_logical_or, tiramisu::o_lt, tiramisu::o_max, tiramisu::o_memcpy, tiramisu::o_min, tiramisu::o_minus, tiramisu::o_mod, tiramisu::o_mul, tiramisu::o_ne, tiramisu::o_right_shift, tiramisu::o_round, tiramisu::o_select, tiramisu::o_sin, tiramisu::o_sinh, tiramisu::o_sqrt, tiramisu::o_sub, tiramisu::o_tan, tiramisu::o_tanh, tiramisu::o_trunc, tiramisu::p_float32, tiramisu::p_float64, tiramisu::p_int16, tiramisu::p_int32, tiramisu::p_int64, tiramisu::p_int8, tiramisu::p_uint16, tiramisu::p_uint32, tiramisu::p_uint64, and tiramisu::p_uint8.
|
inlinestatic |
Create a variable that can be used that a dimension is unbounded.
i < tiramisu::expr::unbounded() means that i does not have an upper bound. i > tiramisu::expr::unbounded() means that i does not have a lower bound.
Definition at line 1671 of file expr.h.
References dtype, tiramisu::e_val, etype, name, tiramisu::o_none, and tiramisu::p_none.
|
protected |
Data type.
Definition at line 219 of file expr.h.
Referenced by tiramisu::computation::computation(), is_equal(), and unbounded().
|
protected |
The type of the expression.
Definition at line 224 of file expr.h.
Referenced by is_equal(), and unbounded().
|
protected |