Halide 22.0.0 Halide compiler and libraries

Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | List of all members
Halide::Internal::AssociativeOp Struct Reference

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

`#include <Associativity.h>`

## Classes
struct | Replacement

## Public Member Functions
| AssociativeOp ()=default
| 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.
std::vector< Replacement > | xs
std::vector< Replacement > | ys
bool | is_associative = false

## 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:

AssociativeOp assoc(
AssociativePattern(min(x, y), +inf, true),
{Replacement("x", f(x))},
{Replacement("y", g(r.x) + 2)},
true
);
Halide::Internal::min
ConstantInterval min(const ConstantInterval &a, const ConstantInterval &b)
Halide::cast
Internal::ConstantInterval cast(Type t, const Internal::ConstantInterval &a)
Cast operators for ConstantIntervals.
Halide::Internal::AssociativeOp::Replacement
Definition Associativity.h:62
Halide::Internal::AssociativeOp
Represent the equivalent associative op of an update definition.
Definition Associativity.h:61
Halide::Internal::AssociativePattern
Represent an associative op with its identity.
Definition AssociativeOpsTable.h:31

'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:

AssociativeOp assoc(
AssociativePattern(y, 0, false),
{Replacement("", Expr())},
{Replacement("y", min(g(r.x), 4))},
true
);
Halide::Expr
A fragment of Halide syntax.
Definition Expr.h:258

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

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

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

Definition at line 61 of file Associativity.h.

## Constructor & Destructor Documentation

## ◆ AssociativeOp() [1/3]

Halide::Internal::AssociativeOp::AssociativeOp | ( |  | ) |
| default

## ◆ AssociativeOp() [2/3]

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

Definition at line 87 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
| ) |  |
| inline

Definition at line 90 of file Associativity.h.

## Member Function Documentation

## ◆ associative()

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

Definition at line 95 of file Associativity.h.

References is_associative.

## ◆ commutative()

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

Definition at line 98 of file Associativity.h.

References Halide::Internal::AssociativePattern::is_commutative, and pattern.

## ◆ size()

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

Definition at line 101 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 81 of file Associativity.h.

Referenced by commutative(), and size().

## ◆ xs

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

Definition at line 82 of file Associativity.h.

## ◆ ys

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

Definition at line 83 of file Associativity.h.

## ◆ is_associative

bool Halide::Internal::AssociativeOp::is_associative = false

Definition at line 84 of file Associativity.h.

Referenced by associative().

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

- src/Associativity.h