Halide 19.0.0
Halide compiler and libraries
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:
Halide::Internal::IRVisitor Halide::Internal::HostClosure

Classes

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

Public Member Functions

 Closure ()=default
 
 Closure (const Closure &)=delete
 
Closureoperator= (const Closure &)=delete
 
 Closure (Closure &&)=default
 
Closureoperator= (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, Typevars
 External variables referenced.
 
std::map< std::string, Bufferbuffers
 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 Member Functions inherited from Halide::Internal::IRVisitor

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

◆ Closure() [2/3]

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

◆ Closure() [3/3]

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

Member Function Documentation

◆ visit() [1/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [2/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [3/48]

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

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

◆ visit() [4/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [5/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [6/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [7/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [8/48]

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<> & image )
protected

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ 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 * )
protectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [10/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [11/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [12/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [13/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [14/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [15/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [16/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [17/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [18/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [19/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [20/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [21/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [22/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [23/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [24/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [25/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [26/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [27/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [28/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [29/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [30/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [31/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [32/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [33/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [34/48]

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

Reimplemented from Halide::Internal::IRVisitor.

Reimplemented in Halide::Internal::HostClosure.

◆ visit() [35/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [36/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [37/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [38/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [39/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [40/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [41/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [42/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [43/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [44/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [45/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [46/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [47/48]

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

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [48/48]

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

Reimplemented from Halide::Internal::IRVisitor.

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: