tvm
Public Member Functions | Protected Member Functions | List of all members
tvm::SEqualHandlerDefault Class Reference

The default handler for equality testing. More...

#include <structural_equal.h>

Inheritance diagram for tvm::SEqualHandlerDefault:
Collaboration diagram for tvm::SEqualHandlerDefault:

Public Member Functions

 SEqualHandlerDefault (bool assert_mode, Optional< ObjectPathPair > *first_mismatch, bool defer_fails)
 
virtual ~SEqualHandlerDefault ()
 
bool SEqualReduce (const ObjectRef &lhs, const ObjectRef &rhs, bool map_free_vars, const Optional< ObjectPathPair > &current_paths) override
 Reduce condition to equality of lhs and rhs. More...
 
void DeferFail (const ObjectPathPair &mismatch_paths) override
 Mark the comparison as failed, but don't fail immediately. More...
 
bool IsFailDeferralEnabled () override
 Check if fail defferal is enabled. More...
 
ObjectRef MapLhsToRhs (const ObjectRef &lhs) override
 Lookup the graph node equal map for vars that are already mapped. More...
 
void MarkGraphNode () override
 Mark current comparison as graph node equal comparison. More...
 
virtual bool Equal (const ObjectRef &lhs, const ObjectRef &rhs, bool map_free_vars)
 The entry point for equality testing. More...
 

Protected Member Functions

virtual bool DispatchSEqualReduce (const ObjectRef &lhs, const ObjectRef &rhs, bool map_free_vars, const Optional< ObjectPathPair > &current_paths)
 The dispatcher for equality testing of intermediate objects. More...
 

Additional Inherited Members

- Protected Types inherited from tvm::SEqualReducer::Handler
using PathTracingData = SEqualReducer::PathTracingData
 

Detailed Description

The default handler for equality testing.

Users can derive from this class and override the DispatchSEqualReduce method, to customize equality testing.

Constructor & Destructor Documentation

◆ SEqualHandlerDefault()

tvm::SEqualHandlerDefault::SEqualHandlerDefault ( bool  assert_mode,
Optional< ObjectPathPair > *  first_mismatch,
bool  defer_fails 
)

◆ ~SEqualHandlerDefault()

virtual tvm::SEqualHandlerDefault::~SEqualHandlerDefault ( )
virtual

Member Function Documentation

◆ DeferFail()

void tvm::SEqualHandlerDefault::DeferFail ( const ObjectPathPair mismatch_paths)
overridevirtual

Mark the comparison as failed, but don't fail immediately.

This is useful for producing better error messages when comparing containers. For example, if two array sizes mismatch, it's better to mark the comparison as failed but compare array elements anyway, so that we could find the true first mismatch.

Implements tvm::SEqualReducer::Handler.

◆ DispatchSEqualReduce()

virtual bool tvm::SEqualHandlerDefault::DispatchSEqualReduce ( const ObjectRef lhs,
const ObjectRef rhs,
bool  map_free_vars,
const Optional< ObjectPathPair > &  current_paths 
)
protectedvirtual

The dispatcher for equality testing of intermediate objects.

Parameters
lhsThe left operand.
rhsThe right operand.
map_free_varsWhether or not to remap variables if possible.
current_pathsOptional paths to lhs and rhs objects, for error traceability.
Returns
The equality result.

◆ Equal()

virtual bool tvm::SEqualHandlerDefault::Equal ( const ObjectRef lhs,
const ObjectRef rhs,
bool  map_free_vars 
)
virtual

The entry point for equality testing.

Parameters
lhsThe left operand.
rhsThe right operand.
map_free_varsWhether or not to remap variables if possible.
Returns
The equality result.

◆ IsFailDeferralEnabled()

bool tvm::SEqualHandlerDefault::IsFailDeferralEnabled ( )
overridevirtual

Check if fail defferal is enabled.

Returns
false if the fail deferral is not enabled, true otherwise.

Implements tvm::SEqualReducer::Handler.

◆ MapLhsToRhs()

ObjectRef tvm::SEqualHandlerDefault::MapLhsToRhs ( const ObjectRef lhs)
overridevirtual

Lookup the graph node equal map for vars that are already mapped.

This is an auxiliary method to check the Map<Var, Value> equality.

Parameters
lhsan lhs value.
Returns
The corresponding rhs value if any, nullptr if not available.

Implements tvm::SEqualReducer::Handler.

◆ MarkGraphNode()

void tvm::SEqualHandlerDefault::MarkGraphNode ( )
overridevirtual

Mark current comparison as graph node equal comparison.

Implements tvm::SEqualReducer::Handler.

◆ SEqualReduce()

bool tvm::SEqualHandlerDefault::SEqualReduce ( const ObjectRef lhs,
const ObjectRef rhs,
bool  map_free_vars,
const Optional< ObjectPathPair > &  current_paths 
)
overridevirtual

Reduce condition to equality of lhs and rhs.

Parameters
lhsThe left operand.
rhsThe right operand.
map_free_varsWhether do we allow remap variables if possible.
current_pathsOptional paths to lhs and rhs objects, for error traceability.
Returns
false if there is an immediate failure, true otherwise.
Note
This function may save the equality condition of (lhs == rhs) in an internal stack and try to resolve later.

Implements tvm::SEqualReducer::Handler.


The documentation for this class was generated from the following file: