Halide::Internal::AssociativeOp Struct Reference

Represent the equivalent associative op of an update definition. More...

#include <Associativity.h>


struct  Replacement

Public Member Functions

 AssociativeOp ()
 AssociativeOp (size_t size)
 AssociativeOp (const AssociativePattern &p, const std::vector< Replacement > &xs, const std::vector< Replacement > &ys, bool is_associative)
bool associative () const
bool commutative () const
size_t size () const

Public Attributes

AssociativePattern pattern
 List of pairs of binary associative op and its identity. More...
std::vector< Replacementxs
std::vector< Replacementys
bool is_associative

Detailed Description

Represent the equivalent associative op of an update definition.

For example, the following associative Expr, min(f(x), g(r.x) + 2), where f(x) is the self-recurrence term, is represented as:

AssociativePattern(min(x, y), +inf, true),
{Replacement("x", f(x))},
{Replacement("y", g(r.x) + 2)},

'pattern' contains the list of equivalent binary/unary operators (+ identities) for each Tuple element in the update definition. 'pattern' also contains a boolean that indicates if the op is also commutative. 'xs' and 'ys' contain the corresponding definition of each variable in the list of binary operators.

For unary operator, 'xs' is not set, i.e. it will be a pair of empty string and undefined Expr: {"", Expr()}. 'pattern' will only contain the 'y' term in this case. For example, min(g(r.x), 4), will be represented as:

AssociativePattern(y, 0, false),
{Replacement("", Expr())},
{Replacement("y", min(g(r.x), 4))},

Self-assignment, f(x) = f(x), will be represented as:

AssociativePattern(x, 0, true),
{Replacement("x", f(x))},
{Replacement("", Expr())},

For both unary operator and self-assignment cases, the identity does not matter. It can be anything.

Definition at line 63 of file Associativity.h.

Constructor & Destructor Documentation

◆ AssociativeOp() [1/3]

Halide::Internal::AssociativeOp::AssociativeOp ( )

Definition at line 88 of file Associativity.h.

◆ AssociativeOp() [2/3]

Halide::Internal::AssociativeOp::AssociativeOp ( size_t  size)

Definition at line 91 of file Associativity.h.

◆ AssociativeOp() [3/3]

Halide::Internal::AssociativeOp::AssociativeOp ( const AssociativePattern p,
const std::vector< Replacement > &  xs,
const std::vector< Replacement > &  ys,
bool  is_associative 

Definition at line 94 of file Associativity.h.

Member Function Documentation

◆ associative()

bool Halide::Internal::AssociativeOp::associative ( ) const

Definition at line 99 of file Associativity.h.

References is_associative.

◆ commutative()

bool Halide::Internal::AssociativeOp::commutative ( ) const

◆ size()

size_t Halide::Internal::AssociativeOp::size ( ) const

Definition at line 105 of file Associativity.h.

References pattern, and Halide::Internal::AssociativePattern::size().

Member Data Documentation

◆ pattern

AssociativePattern Halide::Internal::AssociativeOp::pattern

List of pairs of binary associative op and its identity.

Definition at line 83 of file Associativity.h.

Referenced by commutative(), and size().

◆ xs

std::vector<Replacement> Halide::Internal::AssociativeOp::xs

Definition at line 84 of file Associativity.h.

◆ ys

std::vector<Replacement> Halide::Internal::AssociativeOp::ys

Definition at line 85 of file Associativity.h.

◆ is_associative

bool Halide::Internal::AssociativeOp::is_associative

Definition at line 86 of file Associativity.h.

Referenced by associative().

The documentation for this struct was generated from the following file:
Expr min(const FuncRef &a, const FuncRef &b)
Explicit overloads of min and max for FuncRef.
Definition: Func.h:577
Definition: Associativity.h:88