Halide 22.0.0 Halide compiler and libraries

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Halide::LoopLevel Class Reference

A reference to a site in a Halide statement at the top of the body of a particular for loop. More...

`#include <Schedule.h>`

## Public Member Functions
int | stage_index () const
| Return the index of the function stage associated with this loop level.
| LoopLevel (const Internal::Function &f, const VarOrRVar &v, int stage_index=-1)
| Identify the loop nest corresponding to some dimension of some function.
| LoopLevel (const Func &f, const VarOrRVar &v, int stage_index=-1)
| LoopLevel ()
| Construct an undefined LoopLevel.
| LoopLevel (const std::string &func_name, const std::string &var_name, bool is_rvar, int stage_index, bool locked=false)
| For deserialization only.
void | set (const LoopLevel &other)
| Mutate our contents to match the contents of 'other'.
LoopLevel & | lock ()
std::string | func () const
VarOrRVar | var () const
bool | defined () const
bool | is_inlined () const
bool | is_root () const
int | get_stage_index () const
std::string | func_name () const
std::string | var_name () const
bool | is_rvar () const
bool | locked () const
std::string | to_string () const
bool | match (const std::string &loop) const
bool | match (const LoopLevel &other) const
bool | operator== (const LoopLevel &other) const
bool | operator!= (const LoopLevel &other) const

## Static Public Member Functions
static LoopLevel | inlined ()
| Construct a special LoopLevel value that implies that a function should be inlined away.
static LoopLevel | root ()
| Construct a special LoopLevel value which represents the location outside of all for loops.

## Detailed Description

A reference to a site in a Halide statement at the top of the body of a particular for loop.

Evaluating a region of a halide function is done by generating a loop nest that spans its dimensions. We schedule the inputs to that function by recursively injecting realizations for them at particular sites in this loop nest. A LoopLevel identifies such a site. The site can either be a loop nest within all stages of a function or it can refer to a loop nest within a particular function's stage (initial definition or updates).

Note that a LoopLevel is essentially a pointer to an underlying value; all copies of a LoopLevel refer to the same site, so mutating one copy (via the set() method) will effectively mutate all copies:

Func f;
Var x;
LoopLevel a(f, x);
// Both a and b refer to LoopLevel(f, x)
LoopLevel b = a;
// Now both a and b refer to LoopLevel::root()
a.set(LoopLevel::root());
Halide::Func
A halide function.
Definition Func.h:728
Halide::LoopLevel
A reference to a site in a Halide statement at the top of the body of a particular for loop.
Definition Schedule.h:203
Halide::LoopLevel::root
static LoopLevel root()
Construct a special LoopLevel value which represents the location outside of all for loops.
Halide::LoopLevel::set
void set(const LoopLevel &other)
Mutate our contents to match the contents of 'other'.
Halide::Var
A Halide variable, to be used when defining functions.
Definition Var.h:19

This is quite useful when splitting Halide code into utility libraries, as it allows a library to schedule code according to a caller's specifications, even if the caller hasn't fully defined its pipeline yet:

Func demosaic(Func input,
LoopLevel intermed_compute_at,
LoopLevel intermed_store_at,
LoopLevel output_compute_at) {
Func intermed = ...;
Func output = ...;
intermed.compute_at(intermed_compute_at).store_at(intermed_store_at);
output.compute_at(output_compute_at);
return output;
}
void process() {
// Note that these LoopLevels are all undefined when we pass them to demosaic()
LoopLevel intermed_compute_at, intermed_store_at, output_compute_at;
Func input = ...;
Func demosaiced = demosaic(input, intermed_compute_at, intermed_store_at, output_compute_at);
Func output = ...;
// We need to ensure all LoopLevels have a well-defined value prior to lowering:
intermed_compute_at.set(LoopLevel(output, y));
intermed_store_at.set(LoopLevel(output, y));
output_compute_at.set(LoopLevel(output, x));
}
Halide::LoopLevel::LoopLevel
LoopLevel()
Construct an undefined LoopLevel.
Halide::cast
Internal::ConstantInterval cast(Type t, const Internal::ConstantInterval &a)
Cast operators for ConstantIntervals.

Definition at line 203 of file Schedule.h.

## Constructor & Destructor Documentation

## ◆ LoopLevel() [1/4]

Halide::LoopLevel::LoopLevel | ( | const Internal::Function & | f,
|  | const VarOrRVar & | v,
|  | int | stage_index = `-1`
| ) |  |

Identify the loop nest corresponding to some dimension of some function.

## ◆ LoopLevel() [2/4]

Halide::LoopLevel::LoopLevel | ( | const Func & | f,
|  | const VarOrRVar & | v,
|  | int | stage_index = `-1`
| ) |  |

## ◆ LoopLevel() [3/4]

Halide::LoopLevel::LoopLevel | ( |  | ) |

Construct an undefined LoopLevel.

Calling any method on an undefined LoopLevel (other than set()) will assert.

## ◆ LoopLevel() [4/4]

Halide::LoopLevel::LoopLevel | ( | const std::string & | func_name,
|  | const std::string & | var_name,
|  | bool | is_rvar,
|  | int | stage_index,
|  | bool | locked = `false`
| ) |  |

For deserialization only.

## Member Function Documentation

## ◆ stage_index()

int Halide::LoopLevel::stage_index | ( |  | ) | const

Return the index of the function stage associated with this loop level.

Asserts if undefined

## ◆ inlined()

static LoopLevel Halide::LoopLevel::inlined | ( |  | ) |
| static

Construct a special LoopLevel value that implies that a function should be inlined away.

Referenced by Halide::Internal::GeneratorParam_LoopLevel::set_from_string().

## ◆ root()

static LoopLevel Halide::LoopLevel::root | ( |  | ) |
| static

Construct a special LoopLevel value which represents the location outside of all for loops.

Referenced by Halide::Internal::GeneratorParam_LoopLevel::set_from_string().

## ◆ set()

void Halide::LoopLevel::set | ( | const LoopLevel & | other | ) |

Mutate our contents to match the contents of 'other'.

Referenced by Halide::Internal::GeneratorParam_LoopLevel::get_default_value(), and Halide::Internal::GeneratorParam_LoopLevel::set().

## ◆ lock()

LoopLevel & Halide::LoopLevel::lock | ( |  | ) |

Referenced by Halide::Internal::GeneratorParam_LoopLevel::get_default_value().

## ◆ func()

std::string Halide::LoopLevel::func | ( |  | ) | const

## ◆ var()

VarOrRVar Halide::LoopLevel::var | ( |  | ) | const

## ◆ defined()

bool Halide::LoopLevel::defined | ( |  | ) | const

## ◆ is_inlined()

bool Halide::LoopLevel::is_inlined | ( |  | ) | const

Referenced by Halide::Internal::GeneratorParam_LoopLevel::get_default_value().

## ◆ is_root()

bool Halide::LoopLevel::is_root | ( |  | ) | const

Referenced by Halide::Internal::GeneratorParam_LoopLevel::get_default_value().

## ◆ get_stage_index()

int Halide::LoopLevel::get_stage_index | ( |  | ) | const

## ◆ func_name()

std::string Halide::LoopLevel::func_name | ( |  | ) | const

## ◆ var_name()

std::string Halide::LoopLevel::var_name | ( |  | ) | const

## ◆ is_rvar()

bool Halide::LoopLevel::is_rvar | ( |  | ) | const

## ◆ locked()

bool Halide::LoopLevel::locked | ( |  | ) | const

## ◆ to_string()

std::string Halide::LoopLevel::to_string | ( |  | ) | const

## ◆ match() [1/2]

bool Halide::LoopLevel::match | ( | const std::string & | loop | ) | const

## ◆ match() [2/2]

bool Halide::LoopLevel::match | ( | const LoopLevel & | other | ) | const

## ◆ operator==()

bool Halide::LoopLevel::operator== | ( | const LoopLevel & | other | ) | const

## ◆ operator!=()

bool Halide::LoopLevel::operator!= | ( | const LoopLevel & | other | ) | const
| inline

Definition at line 294 of file Schedule.h.

References Halide::cast().

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

- src/Schedule.h