tvm
|
A Reducer class to reduce the structural equality result of two objects. More...
#include <structural_equal.h>
Classes | |
class | Handler |
Internal handler that defines custom behaviors.. More... | |
Public Member Functions | |
SEqualReducer ()=default | |
default constructor More... | |
SEqualReducer (Handler *handler, const PathTracingData *tracing_data, bool map_free_vars) | |
Constructor with a specific handler. More... | |
bool | operator() (const double &lhs, const double &rhs, Optional< ObjectPathPair > paths=NullOpt) const |
Reduce condition to comparison of two attribute values. More... | |
bool | operator() (const int64_t &lhs, const int64_t &rhs, Optional< ObjectPathPair > paths=NullOpt) const |
bool | operator() (const uint64_t &lhs, const uint64_t &rhs, Optional< ObjectPathPair > paths=NullOpt) const |
bool | operator() (const int &lhs, const int &rhs, Optional< ObjectPathPair > paths=NullOpt) const |
bool | operator() (const bool &lhs, const bool &rhs, Optional< ObjectPathPair > paths=NullOpt) const |
bool | operator() (const std::string &lhs, const std::string &rhs, Optional< ObjectPathPair > paths=NullOpt) const |
bool | operator() (const DataType &lhs, const DataType &rhs, Optional< ObjectPathPair > paths=NullOpt) const |
template<typename ENum , typename = typename std::enable_if<std::is_enum<ENum>::value>::type> | |
bool | operator() (const ENum &lhs, const ENum &rhs, Optional< ObjectPathPair > paths=NullOpt) const |
template<typename T , typename Callable , typename = std::enable_if_t< std::is_same_v<std::invoke_result_t<Callable, const ObjectPath&>, ObjectPath>>> | |
bool | operator() (const T &lhs, const T &rhs, const Callable &callable) |
bool | operator() (const ObjectRef &lhs, const ObjectRef &rhs) const |
Reduce condition to comparison of two objects. More... | |
bool | operator() (const ObjectRef &lhs, const ObjectRef &rhs, const ObjectPathPair &paths) const |
Reduce condition to comparison of two objects. More... | |
bool | DefEqual (const ObjectRef &lhs, const ObjectRef &rhs) |
Reduce condition to comparison of two definitions, where free vars can be mapped. More... | |
template<typename T > | |
bool | operator() (const Array< T > &lhs, const Array< T > &rhs) const |
Reduce condition to comparison of two arrays. More... | |
bool | FreeVarEqualImpl (const runtime::Object *lhs, const runtime::Object *rhs) const |
Implementation for equality rule of var type objects(e.g. TypeVar, tir::Var). More... | |
Handler * | operator-> () const |
bool | IsPathTracingEnabled () const |
Check if this reducer is tracing paths to the first mismatch. More... | |
const ObjectPathPair & | GetCurrentObjectPaths () const |
Get the paths of the currently compared objects. More... | |
void | RecordMismatchPaths (const ObjectPathPair &paths) const |
Specify the object paths of a detected mismatch. More... | |
A Reducer class to reduce the structural equality result of two objects.
The reducer will call the SEqualReduce function of each objects recursively. Importantly, the reducer may not directly use recursive calls to resolve the equality checking. Instead, it can store the necessary equality conditions and check later via an internally managed stack.
|
default |
default constructor
|
inlineexplicit |
Constructor with a specific handler.
handler | The equal handler for objects. |
tracing_data | Optional pointer to the path tracing data. |
map_free_vars | Whether or not to map free variables. |
Reduce condition to comparison of two definitions, where free vars can be mapped.
Call this function to compare definition points such as function params and var in a let-binding.
lhs | The left operand. |
rhs | The right operand. |
|
inline |
Implementation for equality rule of var type objects(e.g. TypeVar, tir::Var).
lhs | The left operand. |
rhs | The right operand. |
const ObjectPathPair& tvm::SEqualReducer::GetCurrentObjectPaths | ( | ) | const |
Get the paths of the currently compared objects.
Can only be called when IsPathTracingEnabled()
is true.
|
inline |
Check if this reducer is tracing paths to the first mismatch.
|
inline |
Reduce condition to comparison of two arrays.
lhs | The left operand. |
rhs | The right operand. |
bool tvm::SEqualReducer::operator() | ( | const bool & | lhs, |
const bool & | rhs, | ||
Optional< ObjectPathPair > | paths = NullOpt |
||
) | const |
bool tvm::SEqualReducer::operator() | ( | const DataType & | lhs, |
const DataType & | rhs, | ||
Optional< ObjectPathPair > | paths = NullOpt |
||
) | const |
bool tvm::SEqualReducer::operator() | ( | const double & | lhs, |
const double & | rhs, | ||
Optional< ObjectPathPair > | paths = NullOpt |
||
) | const |
Reduce condition to comparison of two attribute values.
lhs | The left operand. |
rhs | The right operand. |
paths | The paths to the LHS and RHS operands. If unspecified, will attempt to identify the attribute's address within the most recent ObjectRef. In general, the paths only require explicit handling for computed parameters (e.g. array.size() ) |
|
inline |
bool tvm::SEqualReducer::operator() | ( | const int & | lhs, |
const int & | rhs, | ||
Optional< ObjectPathPair > | paths = NullOpt |
||
) | const |
bool tvm::SEqualReducer::operator() | ( | const int64_t & | lhs, |
const int64_t & | rhs, | ||
Optional< ObjectPathPair > | paths = NullOpt |
||
) | const |
Reduce condition to comparison of two objects.
lhs | The left operand. |
rhs | The right operand. |
|
inline |
Reduce condition to comparison of two objects.
Like operator()
, but with an additional paths
parameter that specifies explicit object paths for lhs
and rhs
. This is useful for implementing SEqualReduce() methods for container objects like Array and Map, or other custom objects that store nested objects that are not simply attributes.
Can only be called when IsPathTracingEnabled()
is true
.
lhs | The left operand. |
rhs | The right operand. |
paths | Object paths for lhs and rhs . |
bool tvm::SEqualReducer::operator() | ( | const std::string & | lhs, |
const std::string & | rhs, | ||
Optional< ObjectPathPair > | paths = NullOpt |
||
) | const |
|
inline |
bool tvm::SEqualReducer::operator() | ( | const uint64_t & | lhs, |
const uint64_t & | rhs, | ||
Optional< ObjectPathPair > | paths = NullOpt |
||
) | const |
|
inline |
void tvm::SEqualReducer::RecordMismatchPaths | ( | const ObjectPathPair & | paths | ) | const |
Specify the object paths of a detected mismatch.
Can only be called when IsPathTracingEnabled()
is true.