tvm
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
tvm::Pattern< Derived > Class Template Reference

Base class of all the patterns. More...

#include <pattern_match.h>

Inheritance diagram for tvm::Pattern< Derived >:
Collaboration diagram for tvm::Pattern< Derived >:

Public Types

using Nested = Derived
 Nested storage type in the expression.
 

Public Member Functions

template<typename NodeType >
bool Match (const NodeType &value) const
 Check if value matches the current pattern.
 
template<typename NodeType , typename Condition >
bool Match (const NodeType &value, Condition cond) const
 Check if value matches the current pattern.
 
const Derived & derived () const
 

Detailed Description

template<typename Derived>
class tvm::Pattern< Derived >

Base class of all the patterns.

There are two major member functions supported by each pattern.

We use curiously recurring template pattern to construct expression templates.

Template Parameters
DerivedThe type of the derived class.

Member Typedef Documentation

◆ Nested

template<typename Derived >
using tvm::Pattern< Derived >::Nested = Derived

Nested storage type in the expression.

Depending on the Derived class, Nested can be Derived (nest by value) or const Derived& (nest by reference).

The trick of Nested typedef originates from Eigen.

Note
We use nest by value for intermediate expressions, and nest by reference for PVars.

Member Function Documentation

◆ derived()

template<typename Derived >
const Derived & tvm::Pattern< Derived >::derived ( ) const
inline
Returns
Derived instance of current class.

◆ Match() [1/2]

template<typename Derived >
template<typename NodeType >
bool tvm::Pattern< Derived >::Match ( const NodeType &  value) const
inline

Check if value matches the current pattern.

This call also populates the PVars with matched value. The values in PVars are valid until the next call to Match.

Parameters
valueThe value to be matched against
Returns
whether value matches the pattern.

◆ Match() [2/2]

template<typename Derived >
template<typename NodeType , typename Condition >
bool tvm::Pattern< Derived >::Match ( const NodeType &  value,
Condition  cond 
) const
inline

Check if value matches the current pattern.

This call also populates the PVars with matched value. The values in PVars are valid until the next call to Match.

Parameters
valueThe value to be matched against
condA callable that performs additional validation, returning true if the match passes. This will typically be a lambda function written in terms of the filled PVars.
Returns
whether value matches the pattern.

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