Loading...
Searching...
No Matches
Halide::Internal::Closure Class Reference

A helper class to manage closures. More...

`#include <Closure.h>`

Inheritance diagram for Halide::Internal::Closure:

## Classes

struct | Buffer
| Information about a buffer reference from a closure. More...

## Public Member Functions

| Closure ()=default
| Closure (const Closure &)=delete
Closure & | operator= (const Closure &)=delete
| Closure (Closure &&)=default
Closure & | operator= (Closure &&)=default
void | include (const Stmt &s, const std::string &loop_variable="")
| Traverse a statement and find all references to external symbols.
Expr | pack_into_struct () const
| Pack a closure into a struct.
Stmt | unpack_from_struct (const Expr &, const Stmt &) const
| Unpack a closure around a Stmt, putting all the names in scope.
Public Member Functions inherited from Halide::Internal::IRVisitor
| IRVisitor ()=default
virtual | ~IRVisitor ()=default

## Public Attributes

std::map< std::string, Type > | vars
| External variables referenced.
std::map< std::string, Buffer > | buffers
| External allocations referenced.

## Protected Member Functions

void | visit (const Let *op) override
void | visit (const LetStmt *op) override
void | visit (const For *op) override
void | visit (const Load *op) override
void | visit (const Store *op) override
void | visit (const Allocate *op) override
void | visit (const Variable *op) override
void | visit (const Atomic *op) override
void | found_buffer_ref (const std::string &name, Type type, bool read, bool written, const Halide::Buffer<> &image)
virtual void | visit (const IntImm *)
virtual void | visit (const UIntImm *)
virtual void | visit (const FloatImm *)
virtual void | visit (const StringImm *)
virtual void | visit (const Cast *)
virtual void | visit (const Reinterpret *)
virtual void | visit (const Add *)
virtual void | visit (const Sub *)
virtual void | visit (const Mul *)
virtual void | visit (const Div *)
virtual void | visit (const Mod *)
virtual void | visit (const Min *)
virtual void | visit (const Max *)
virtual void | visit (const EQ *)
virtual void | visit (const NE *)
virtual void | visit (const LT *)
virtual void | visit (const LE *)
virtual void | visit (const GT *)
virtual void | visit (const GE *)
virtual void | visit (const And *)
virtual void | visit (const Or *)
virtual void | visit (const Not *)
virtual void | visit (const Select *)
virtual void | visit (const Ramp *)
virtual void | visit (const Broadcast *)
virtual void | visit (const Call *)
virtual void | visit (const AssertStmt *)
virtual void | visit (const ProducerConsumer *)
virtual void | visit (const Provide *)
virtual void | visit (const Free *)
virtual void | visit (const Realize *)
virtual void | visit (const Block *)
virtual void | visit (const IfThenElse *)
virtual void | visit (const Evaluate *)
virtual void | visit (const Shuffle *)
virtual void | visit (const VectorReduce *)
virtual void | visit (const Prefetch *)
virtual void | visit (const Fork *)
virtual void | visit (const Acquire *)
virtual void | visit (const HoistedStorage *)

## Protected Attributes

Scope | ignore

## Detailed Description

A helper class to manage closures.

Walks over a statement and retrieves all the references within it to external symbols (variables and allocations). It then helps you build a struct containing the current values of these symbols that you can use as a closure if you want to migrate the body of the statement to its own function (e.g. because it's the body of a parallel for loop.

Definition at line 26 of file Closure.h.

## Constructor & Destructor Documentation

## Closure() [1/3]

Halide::Internal::Closure::Closure | ( |  | ) |

default

Referenced by Closure(), Closure(), operator=(), and operator=().

## Closure() [2/3]

Halide::Internal::Closure::Closure | ( | const Closure & |  | ) |

delete

References Closure().

## Closure() [3/3]

Halide::Internal::Closure::Closure | ( | Closure && |  | ) |

default

References Closure().

## Member Function Documentation

## visit() [1/48]

void Halide::Internal::Closure::visit | ( | const Let * | op | ) |

override protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

Referenced by Halide::Internal::HostClosure::arguments().

## visit() [2/48]

void Halide::Internal::Closure::visit | ( | const LetStmt * | op | ) |

override protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [3/48]

void Halide::Internal::Closure::visit | ( | const For * | op | ) |

override protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [4/48]

void Halide::Internal::Closure::visit | ( | const Load * | op | ) |

override protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [5/48]

void Halide::Internal::Closure::visit | ( | const Store * | op | ) |

override protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [6/48]

void Halide::Internal::Closure::visit | ( | const Allocate * | op | ) |

override protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [7/48]

void Halide::Internal::Closure::visit | ( | const Variable * | op | ) |

override protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [8/48]

void Halide::Internal::Closure::visit | ( | const Atomic * | op | ) |

override protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## found_buffer_ref()

void Halide::Internal::Closure::found_buffer_ref | ( | const std::string & | name,
|  | Type | type,
|  | bool | read,
|  | bool | written,
|  | const Halide::Buffer<> & | image )

protected

## operator=() [1/2]

Closure & Halide::Internal::Closure::operator= | ( | const Closure & |  | ) |

delete

References Closure().

## operator=() [2/2]

Closure & Halide::Internal::Closure::operator= | ( | Closure && |  | ) |

default

References Closure().

## include()

void Halide::Internal::Closure::include | ( | const Stmt & | s,
|  | const std::string & | loop_variable = "" )

Traverse a statement and find all references to external symbols.

When the closure encounters a read or write to 'foo', it assumes that the host pointer is found in the symbol table as 'foo.host', and any halide_buffer_t pointer is found under 'foo.buffer'.

Calling this multiple times (on multiple statements) is legal (and will produce a unified closure).

## pack_into_struct()

Expr Halide::Internal::Closure::pack_into_struct | ( |  | ) | const

Pack a closure into a struct.

## unpack_from_struct()

Stmt Halide::Internal::Closure::unpack_from_struct | ( | const Expr & | ,
|  | const Stmt & | ) const

Unpack a closure around a Stmt, putting all the names in scope.

## visit() [9/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const IntImm * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [10/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const UIntImm * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [11/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const FloatImm * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [12/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const StringImm * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [13/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Cast * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [14/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Reinterpret * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [15/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Add * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [16/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Sub * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [17/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Mul * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [18/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Div * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [19/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Mod * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [20/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Min * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [21/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Max * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [22/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const EQ * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [23/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const NE * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [24/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const LT * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [25/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const LE * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [26/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const GT * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [27/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const GE * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [28/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const And * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [29/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Or * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [30/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Not * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [31/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Select * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [32/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Ramp * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [33/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Broadcast * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [34/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Call * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [35/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const AssertStmt * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [36/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const ProducerConsumer * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [37/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Provide * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [38/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Free * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [39/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Realize * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [40/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Block * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [41/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const IfThenElse * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [42/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Evaluate * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [43/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Shuffle * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [44/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const VectorReduce * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [45/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Prefetch * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [46/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Fork * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [47/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const Acquire * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## visit() [48/48]

virtual void Halide::Internal::IRVisitor::visit | ( | const HoistedStorage * |  | ) |

protected virtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

## Member Data Documentation

## ignore

Scope Halide::Internal::Closure::ignore

protected

Definition at line 28 of file Closure.h.

## vars

std::map<std::string, Type> Halide::Internal::Closure::vars

External variables referenced.

There's code that assumes iterating over this repeatedly gives a consistent order, so don't swap out the data type for something non-deterministic.

Definition at line 94 of file Closure.h.

## buffers

std::map<std::string, Buffer> Halide::Internal::Closure::buffers

External allocations referenced.

Definition at line 97 of file Closure.h.

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

- src/Closure.h