Halide
Halide::GeneratorContext Class Reference

GeneratorContext is a base class that is used when using Generators (or Stubs) directly; it is used to allow the outer context (typically, either a Generator or "top-level" code) to specify certain information to the inner context to ensure that inner and outer Generators are compiled in a compatible way. More...

#include <Generator.h>

Inherited by Halide::Internal::GeneratorBase.

Public Types

using ExternsMap = std::map< std::string, ExternalCode >
 

Public Member Functions

 GeneratorContext (const Target &t, bool auto_schedule=false, const MachineParams &machine_params=MachineParams::generic())
 
virtual ~GeneratorContext ()
 
Target get_target () const
 
bool get_auto_schedule () const
 
MachineParams get_machine_params () const
 
std::shared_ptr< ExternsMapget_externs_map () const
 Generators can register ExternalCode objects onto themselves. More...
 
template<typename T >
std::unique_ptr< T > create () const
 
template<typename T , typename... Args>
std::unique_ptr< T > apply (const Args &...args) const
 

Protected Member Functions

 GeneratorContext ()
 
void init_from_context (const Halide::GeneratorContext &context)
 
std::shared_ptr< Internal::ValueTrackerget_value_tracker () const
 
 GeneratorContext (const GeneratorContext &)=delete
 
void operator= (const GeneratorContext &)=delete
 
 GeneratorContext (GeneratorContext &&)=delete
 
void operator= (GeneratorContext &&)=delete
 

Protected Attributes

GeneratorParam< Targettarget
 
GeneratorParam< bool > auto_schedule
 
GeneratorParam< MachineParamsmachine_params
 
std::shared_ptr< ExternsMapexterns_map
 
std::shared_ptr< Internal::ValueTrackervalue_tracker
 

Detailed Description

GeneratorContext is a base class that is used when using Generators (or Stubs) directly; it is used to allow the outer context (typically, either a Generator or "top-level" code) to specify certain information to the inner context to ensure that inner and outer Generators are compiled in a compatible way.

If you are using this at "top level" (e.g. with the JIT), you can construct a GeneratorContext with a Target:

auto my_stub = MyStub(
// inputs
{ ... },
// generator params
{ ... }
);

Note that all Generators inherit from GeneratorContext, so if you are using a Stub from within a Generator, you can just pass 'this' for the GeneratorContext:

struct SomeGen : Generator<SomeGen> {
void generate() {
...
auto my_stub = MyStub(
this, // GeneratorContext
// inputs
{ ... },
// generator params
{ ... }
);
...
}
};

Definition at line 2362 of file Generator.h.

Member Typedef Documentation

◆ ExternsMap

using Halide::GeneratorContext::ExternsMap = std::map<std::string, ExternalCode>

Definition at line 2364 of file Generator.h.

Constructor & Destructor Documentation

◆ GeneratorContext() [1/4]

Halide::GeneratorContext::GeneratorContext ( const Target t,
bool  auto_schedule = false,
const MachineParams machine_params = MachineParams::generic() 
)
inlineexplicit

Definition at line 2366 of file Generator.h.

◆ ~GeneratorContext()

virtual Halide::GeneratorContext::~GeneratorContext ( )
inlinevirtual

Definition at line 2374 of file Generator.h.

◆ GeneratorContext() [2/4]

Halide::GeneratorContext::GeneratorContext ( )
inlineprotected

Definition at line 2418 of file Generator.h.

◆ GeneratorContext() [3/4]

Halide::GeneratorContext::GeneratorContext ( const GeneratorContext )
protecteddelete

◆ GeneratorContext() [4/4]

Halide::GeneratorContext::GeneratorContext ( GeneratorContext &&  )
protecteddelete

Member Function Documentation

◆ get_target()

Target Halide::GeneratorContext::get_target ( ) const
inline

Definition at line 2376 of file Generator.h.

Referenced by init_from_context().

◆ get_auto_schedule()

bool Halide::GeneratorContext::get_auto_schedule ( ) const
inline

Definition at line 2377 of file Generator.h.

Referenced by init_from_context().

◆ get_machine_params()

MachineParams Halide::GeneratorContext::get_machine_params ( ) const
inline

Definition at line 2378 of file Generator.h.

Referenced by init_from_context().

◆ get_externs_map()

std::shared_ptr<ExternsMap> Halide::GeneratorContext::get_externs_map ( ) const
inline

Generators can register ExternalCode objects onto themselves.

The Generator infrastructure will arrange to have this ExternalCode appended to the Module that is finally compiled using the Generator. This allows encapsulating functionality that depends on external libraries or handwritten code for various targets. The name argument should match the name of the ExternalCode block and is used to ensure the same code block is not duplicated in the output. Halide does not do anything other than to compare names for equality. To guarantee uniqueness in public code, we suggest using a Java style inverted domain name followed by organization specific naming. E.g.: com.yoyodyne.overthruster.0719acd19b66df2a9d8d628a8fefba911a0ab2b7

See test/generator/external_code_generator.cpp for example use.

Definition at line 2395 of file Generator.h.

Referenced by init_from_context().

◆ create()

template<typename T >
std::unique_ptr<T> Halide::GeneratorContext::create ( ) const
inline

Definition at line 2400 of file Generator.h.

Referenced by Halide::Generator< T >::create().

◆ apply()

template<typename T , typename... Args>
std::unique_ptr<T> Halide::GeneratorContext::apply ( const Args &...  args) const
inline

Definition at line 2405 of file Generator.h.

Referenced by Halide::Generator< T >::create().

◆ init_from_context()

void Halide::GeneratorContext::init_from_context ( const Halide::GeneratorContext context)
inlineprotected

◆ get_value_tracker()

std::shared_ptr<Internal::ValueTracker> Halide::GeneratorContext::get_value_tracker ( ) const
inlineprotected

Definition at line 2428 of file Generator.h.

Referenced by init_from_context().

◆ operator=() [1/2]

void Halide::GeneratorContext::operator= ( const GeneratorContext )
protecteddelete

◆ operator=() [2/2]

void Halide::GeneratorContext::operator= ( GeneratorContext &&  )
protecteddelete

Member Data Documentation

◆ target

GeneratorParam<Target> Halide::GeneratorContext::target
protected

Definition at line 2412 of file Generator.h.

◆ auto_schedule

GeneratorParam<bool> Halide::GeneratorContext::auto_schedule
protected

Definition at line 2413 of file Generator.h.

◆ machine_params

GeneratorParam<MachineParams> Halide::GeneratorContext::machine_params
protected

Definition at line 2414 of file Generator.h.

◆ externs_map

std::shared_ptr<ExternsMap> Halide::GeneratorContext::externs_map
protected

Definition at line 2415 of file Generator.h.

◆ value_tracker

std::shared_ptr<Internal::ValueTracker> Halide::GeneratorContext::value_tracker
protected

Definition at line 2416 of file Generator.h.


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