Halide
Halide::Internal::Closure Class Reference

A helper class to manage closures. More...

#include <Closure.h>

Inherits Halide::Internal::IRVisitor.

Inherited by Halide::Internal::HostClosure.

Classes

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

Public Member Functions

 Closure ()=default
 
 Closure (const Stmt &s, const std::string &loop_variable="")
 Traverse a statement and find all references to external symbols. More...
 
- Public Member Functions inherited from Halide::Internal::IRVisitor
 IRVisitor ()
 
virtual ~IRVisitor ()
 

Public Attributes

std::map< std::string, Typevars
 External variables referenced. More...
 
std::map< std::string, Bufferbuffers
 External allocations referenced. More...
 

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< void > &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 Variable *)
 
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 Load *)
 
virtual void visit (const Ramp *)
 
virtual void visit (const Broadcast *)
 
virtual void visit (const Call *)
 
virtual void visit (const Let *)
 
virtual void visit (const LetStmt *)
 
virtual void visit (const AssertStmt *)
 
virtual void visit (const ProducerConsumer *)
 
virtual void visit (const For *)
 
virtual void visit (const Store *)
 
virtual void visit (const Provide *)
 
virtual void visit (const Allocate *)
 
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 Atomic *)
 
- Protected Member Functions inherited from Halide::Internal::IRVisitor
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 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 *)
 

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 28 of file Closure.h.

Constructor & Destructor Documentation

◆ Closure() [1/2]

Halide::Internal::Closure::Closure ( )
default

◆ Closure() [2/2]

Halide::Internal::Closure::Closure ( 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'.

Member Function Documentation

◆ visit() [1/54]

void Halide::Internal::Closure::visit ( const Let op)
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [2/54]

void Halide::Internal::Closure::visit ( const LetStmt op)
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [3/54]

void Halide::Internal::Closure::visit ( const For op)
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

◆ visit() [4/54]

void Halide::Internal::Closure::visit ( const Load op)
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [5/54]

void Halide::Internal::Closure::visit ( const Store op)
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [6/54]

void Halide::Internal::Closure::visit ( const Allocate op)
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [7/54]

void Halide::Internal::Closure::visit ( const Variable op)
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [8/54]

void Halide::Internal::Closure::visit ( const Atomic op)
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ found_buffer_ref()

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

◆ visit() [9/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [10/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [11/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [12/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [13/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [14/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [15/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [16/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [17/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [18/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [19/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [20/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [21/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [22/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [23/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [24/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [25/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [26/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [27/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [28/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [29/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [30/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [31/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [32/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [33/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [34/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [35/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [36/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [37/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [38/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [39/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [40/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [41/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [42/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [43/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [44/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [45/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [46/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [47/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [48/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [49/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [50/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [51/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [52/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [53/54]

virtual void Halide::Internal::IRVisitor::visit
protected

◆ visit() [54/54]

virtual void Halide::Internal::IRVisitor::visit
protected

Member Data Documentation

◆ ignore

Scope Halide::Internal::Closure::ignore
protected

Definition at line 30 of file Closure.h.

◆ vars

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

External variables referenced.

Definition at line 83 of file Closure.h.

◆ buffers

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

External allocations referenced.

Definition at line 86 of file Closure.h.


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