Halide 22.0.0 Halide compiler and libraries

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Halide::Parameter Class Reference

A reference-counted handle to a parameter to a halide pipeline. More...

`#include <Parameter.h>`

## Public Member Functions
| Parameter ()=default
| Construct a new undefined handle.
| Parameter (const Type &t, bool is_buffer, int dimensions)
| Construct a new parameter of the given type.
| Parameter (const Type &t, bool is_buffer, int dimensions, const std::string &name)
| Construct a new parameter of the given type with name given by the third argument.
| Parameter (const Parameter &)=default
Parameter & | operator= (const Parameter &)=default
| Parameter (Parameter &&)=default
Parameter & | operator= (Parameter &&)=default
Type | type () const
| Get the type of this parameter.
int | dimensions () const
| Get the dimensionality of this parameter.
const std::string & | name () const
| Get the name of this parameter.
bool | is_buffer () const
| Does this parameter refer to a buffer/image?
template<typename T >
HALIDE_NO_USER_CODE_INLINE T | scalar () const
| If the parameter is a scalar parameter, get its currently bound value.
Expr | scalar_expr () const
| This returns the current value of scalar<type()>() as an Expr.
bool | has_scalar_value () const
| This returns true if scalar_expr() would return a valid Expr, false if not.
template<typename T >
HALIDE_NO_USER_CODE_INLINE void | set_scalar (T val)
| If the parameter is a scalar parameter, set its current value.
void | set_scalar (const Type &val_type, halide_scalar_value_t val)
| If the parameter is a scalar parameter, set its current value.
Buffer< void > | buffer () const
| If the parameter is a buffer parameter, get its currently bound buffer.
void | set_buffer (const Buffer< void > &b)
| If the parameter is a buffer parameter, set its current value.
bool | same_as (const Parameter &other) const
| Tests if this handle is the same as another handle.
bool | defined () const
| Tests if this handle is non-nullptr.
void | set_min_constraint (int dim, const Expr &e)
| Get and set constraints for the min, extent, stride, and estimates on the min/extent.
void | set_extent_constraint (int dim, const Expr &e)
void | set_stride_constraint (int dim, const Expr &e)
void | set_min_constraint_estimate (int dim, const Expr &min)
void | set_extent_constraint_estimate (int dim, const Expr &extent)
void | set_host_alignment (int bytes)
Expr | min_constraint (int dim) const
Expr | extent_constraint (int dim) const
Expr | stride_constraint (int dim) const
Expr | min_constraint_estimate (int dim) const
Expr | extent_constraint_estimate (int dim) const
int | host_alignment () const
const std::vector< BufferConstraint > & | buffer_constraints () const
| Get buffer constraints for all dimensions, only relevant when serializing.
void | set_min_value (const Expr &e)
| Get and set constraints for scalar parameters.
Expr | min_value () const
void | set_max_value (const Expr &e)
Expr | max_value () const
void | set_estimate (Expr e)
Expr | estimate () const
void | set_default_value (const Expr &e)
| Get and set the default values for scalar parameters.
Expr | default_value () const
bool | operator< (const Parameter &other) const
| Order Parameters by their IntrusivePtr so they can be used to index maps.
ArgumentEstimates | get_argument_estimates () const
| Get the ArgumentEstimates appropriate for this Parameter.
void | store_in (MemoryType memory_type)
MemoryType | memory_type () const
void | trace_loads ()
bool | is_tracing_loads () const
void | add_trace_tag (const std::string &trace_tag)
std::vector< std::string > | get_trace_tags () const

## Protected Member Functions
const halide_buffer_t * | raw_buffer () const
| Get the raw currently-bound buffer.
const void * | read_only_scalar_address () const
| Get the pointer to the current value of the scalar parameter.
std::optional< halide_scalar_value_t > | scalar_data () const
| If the Parameter is a scalar, and the scalar data is valid, return the scalar data.
halide_scalar_value_t | scalar_data_checked () const
| If the Parameter is a scalar and has a valid scalar value, return it.
halide_scalar_value_t | scalar_data_checked (const Type &val_type) const
| If the Parameter is a scalar of the given type and has a valid scalar value, return it.
| Parameter (const Type &t, int dimensions, const std::string &name, const Buffer< void > &buffer, int host_alignment, const std::vector< BufferConstraint > &buffer_constraints, MemoryType memory_type)
| Construct a new buffer parameter via deserialization.
| Parameter (const Type &t, int dimensions, const std::string &name, const std::optional< halide_scalar_value_t > &scalar_data, const Expr &scalar_default, const Expr &scalar_min, const Expr &scalar_max, const Expr &scalar_estimate)
| Construct a new scalar parameter via deserialization.

## Protected Attributes
Internal::IntrusivePtr< Internal::ParameterContents > | contents

## Detailed Description

A reference-counted handle to a parameter to a halide pipeline.

May be a scalar parameter or a buffer

Definition at line 40 of file Parameter.h.

## Constructor & Destructor Documentation

## ◆ Parameter() [1/7]

Halide::Parameter::Parameter | ( | const Type & | t,
|  | int | dimensions,
|  | const std::string & | name,
|  | const Buffer< void > & | buffer,
|  | int | host_alignment,
|  | const std::vector< BufferConstraint > & | buffer_constraints,
|  | MemoryType | memory_type
| ) |  |
| protected

Construct a new buffer parameter via deserialization.

## ◆ Parameter() [2/7]

Halide::Parameter::Parameter | ( | const Type & | t,
|  | int | dimensions,
|  | const std::string & | name,
|  | const std::optional< halide_scalar_value_t > & | scalar_data,
|  | const Expr & | scalar_default,
|  | const Expr & | scalar_min,
|  | const Expr & | scalar_max,
|  | const Expr & | scalar_estimate
| ) |  |
| protected

Construct a new scalar parameter via deserialization.

## ◆ Parameter() [3/7]

Halide::Parameter::Parameter | ( |  | ) |
| default

Construct a new undefined handle.

## ◆ Parameter() [4/7]

Halide::Parameter::Parameter | ( | const Type & | t,
|  | bool | is_buffer,
|  | int | dimensions
| ) |  |

Construct a new parameter of the given type.

If the second argument is true, this is a buffer parameter of the given dimensionality, otherwise, it is a scalar parameter (and the dimensionality should be zero). The parameter will be given a unique auto-generated name.

## ◆ Parameter() [5/7]

Halide::Parameter::Parameter | ( | const Type & | t,
|  | bool | is_buffer,
|  | int | dimensions,
|  | const std::string & | name
| ) |  |

Construct a new parameter of the given type with name given by the third argument.

If the second argument is true, this is a buffer parameter, otherwise, it is a scalar parameter. The third argument gives the dimensionality of the buffer parameter. It should be zero for scalar parameters. If the fifth argument is true, the the name being passed in was explicitly specified (as opposed to autogenerated).

## ◆ Parameter() [6/7]

Halide::Parameter::Parameter | ( | const Parameter & |  | ) |
| default

## ◆ Parameter() [7/7]

Halide::Parameter::Parameter | ( | Parameter && |  | ) |
| default

## Member Function Documentation

## ◆ raw_buffer()

const halide_buffer_t * Halide::Parameter::raw_buffer | ( |  | ) | const
| protected

Get the raw currently-bound buffer.

null if unbound

## ◆ read_only_scalar_address()

const void * Halide::Parameter::read_only_scalar_address | ( |  | ) | const
| protected

Get the pointer to the current value of the scalar parameter.

For a given parameter, this address will never change. Note that this can only be used to read from – it must not be written to, so don't cast away the constness. Only relevant when jitting.

## ◆ scalar_data()

std::optional< halide_scalar_value_t > Halide::Parameter::scalar_data | ( |  | ) | const
| protected

If the Parameter is a scalar, and the scalar data is valid, return the scalar data.

Otherwise, return nullopt.

## ◆ scalar_data_checked() [1/2]

halide_scalar_value_t Halide::Parameter::scalar_data_checked | ( |  | ) | const
| protected

If the Parameter is a scalar and has a valid scalar value, return it.

Otherwise, assert-fail.

Referenced by scalar().

## ◆ scalar_data_checked() [2/2]

halide_scalar_value_t Halide::Parameter::scalar_data_checked | ( | const Type & | val_type | ) | const
| protected

If the Parameter is a scalar of the given type and has a valid scalar value, return it.

Otherwise, assert-fail.

## ◆ operator=() [1/2]

Parameter & Halide::Parameter::operator= | ( | const Parameter & |  | ) |
| default

## ◆ operator=() [2/2]

Parameter & Halide::Parameter::operator= | ( | Parameter && |  | ) |
| default

## ◆ type()

Type Halide::Parameter::type | ( |  | ) | const

Get the type of this parameter.

Referenced by Halide::Internal::Call::make(), Halide::Param< T >::operator Expr(), Halide::Param< T >::set(), Halide::Param< T >::set_estimate(), Halide::Param< T >::set_max_value(), Halide::Param< T >::set_min_value(), and Halide::Param< T >::type().

## ◆ dimensions()

int Halide::Parameter::dimensions | ( |  | ) | const

Get the dimensionality of this parameter.

Zero for scalars.

## ◆ name()

const std::string & Halide::Parameter::name | ( |  | ) | const

Get the name of this parameter.

Referenced by Halide::Internal::Call::make(), and Halide::Param< T >::name().

## ◆ is_buffer()

bool Halide::Parameter::is_buffer | ( |  | ) | const

Does this parameter refer to a buffer/image?

## ◆ scalar()

template<typename T >

HALIDE_NO_USER_CODE_INLINE T Halide::Parameter::scalar | ( |  | ) | const
| inline

If the parameter is a scalar parameter, get its currently bound value.

Only relevant when jitting

Definition at line 127 of file Parameter.h.

References Halide::cast(), memcpy(), and scalar_data_checked().

Referenced by Halide::Param< T >::get().

## ◆ scalar_expr()

Expr Halide::Parameter::scalar_expr | ( |  | ) | const

This returns the current value of scalar<type()>() as an Expr.

If the Parameter is not scalar, or its scalar data is not valid, this will assert-fail.

## ◆ has_scalar_value()

bool Halide::Parameter::has_scalar_value | ( |  | ) | const

This returns true if scalar_expr() would return a valid Expr, false if not.

## ◆ set_scalar() [1/2]

template<typename T >

HALIDE_NO_USER_CODE_INLINE void Halide::Parameter::set_scalar | ( | T | val | ) |
| inline

If the parameter is a scalar parameter, set its current value.

Only relevant when jitting

Definition at line 146 of file Parameter.h.

References Halide::cast(), memcpy(), and set_scalar().

Referenced by Halide::Param< T >::set(), and set_scalar().

## ◆ set_scalar() [2/2]

void Halide::Parameter::set_scalar | ( | const Type & | val_type,
|  | halide_scalar_value_t | val
| ) |  |

If the parameter is a scalar parameter, set its current value.

Only relevant when jitting

## ◆ buffer()

Buffer< void > Halide::Parameter::buffer | ( |  | ) | const

If the parameter is a buffer parameter, get its currently bound buffer.

Only relevant when jitting

## ◆ set_buffer()

void Halide::Parameter::set_buffer | ( | const Buffer< void > & | b | ) |

If the parameter is a buffer parameter, set its current value.

Only relevant when jitting

## ◆ same_as()

bool Halide::Parameter::same_as | ( | const Parameter & | other | ) | const

Tests if this handle is the same as another handle.

## ◆ defined()

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

Tests if this handle is non-nullptr.

## ◆ set_min_constraint()

void Halide::Parameter::set_min_constraint | ( | int | dim,
|  | const Expr & | e
| ) |  |

Get and set constraints for the min, extent, stride, and estimates on the min/extent.

## ◆ set_extent_constraint()

void Halide::Parameter::set_extent_constraint | ( | int | dim,
|  | const Expr & | e
| ) |  |

## ◆ set_stride_constraint()

void Halide::Parameter::set_stride_constraint | ( | int | dim,
|  | const Expr & | e
| ) |  |

## ◆ set_min_constraint_estimate()

void Halide::Parameter::set_min_constraint_estimate | ( | int | dim,
|  | const Expr & | min
| ) |  |

## ◆ set_extent_constraint_estimate()

void Halide::Parameter::set_extent_constraint_estimate | ( | int | dim,
|  | const Expr & | extent
| ) |  |

## ◆ set_host_alignment()

void Halide::Parameter::set_host_alignment | ( | int | bytes | ) |

## ◆ min_constraint()

Expr Halide::Parameter::min_constraint | ( | int | dim | ) | const

## ◆ extent_constraint()

Expr Halide::Parameter::extent_constraint | ( | int | dim | ) | const

## ◆ stride_constraint()

Expr Halide::Parameter::stride_constraint | ( | int | dim | ) | const

## ◆ min_constraint_estimate()

Expr Halide::Parameter::min_constraint_estimate | ( | int | dim | ) | const

## ◆ extent_constraint_estimate()

Expr Halide::Parameter::extent_constraint_estimate | ( | int | dim | ) | const

## ◆ host_alignment()

int Halide::Parameter::host_alignment | ( |  | ) | const

## ◆ buffer_constraints()

const std::vector< BufferConstraint > & Halide::Parameter::buffer_constraints | ( |  | ) | const

Get buffer constraints for all dimensions, only relevant when serializing.

## ◆ set_min_value()

void Halide::Parameter::set_min_value | ( | const Expr & | e | ) |

Get and set constraints for scalar parameters.

These are used directly by Param, so they must be exported.

Referenced by Halide::Param< T >::set_min_value().

## ◆ min_value()

Expr Halide::Parameter::min_value | ( |  | ) | const

Referenced by Halide::Param< T >::min_value().

## ◆ set_max_value()

void Halide::Parameter::set_max_value | ( | const Expr & | e | ) |

Referenced by Halide::Param< T >::set_max_value().

## ◆ max_value()

Expr Halide::Parameter::max_value | ( |  | ) | const

Referenced by Halide::Param< T >::max_value().

## ◆ set_estimate()

void Halide::Parameter::set_estimate | ( | Expr | e | ) |

Referenced by Halide::Internal::GeneratorInput_DynamicScalar< T >::set_estimate(), Halide::Param< T >::set_estimate(), and Halide::Internal::GeneratorInput_Scalar< T >::set_estimate().

## ◆ estimate()

Expr Halide::Parameter::estimate | ( |  | ) | const

## ◆ set_default_value()

void Halide::Parameter::set_default_value | ( | const Expr & | e | ) |

Get and set the default values for scalar parameters.

At present, these are used only to emit the default values in the metadata. There isn't yet a public API in Param<> for them (this is used internally by the Generator code).

Referenced by Halide::Internal::GeneratorInput_Scalar< T >::set_def_min_max().

## ◆ default_value()

Expr Halide::Parameter::default_value | ( |  | ) | const

## ◆ operator<()

bool Halide::Parameter::operator< | ( | const Parameter & | other | ) | const
| inline

Order Parameters by their IntrusivePtr so they can be used to index maps.

Definition at line 213 of file Parameter.h.

References Halide::cast(), and contents.

## ◆ get_argument_estimates()

ArgumentEstimates Halide::Parameter::get_argument_estimates | ( |  | ) | const

Get the ArgumentEstimates appropriate for this Parameter.

Referenced by Halide::Param< T >::operator Argument().

## ◆ store_in()

void Halide::Parameter::store_in | ( | MemoryType | memory_type | ) |

## ◆ memory_type()

MemoryType Halide::Parameter::memory_type | ( |  | ) | const

## ◆ trace_loads()

void Halide::Parameter::trace_loads | ( |  | ) |

## ◆ is_tracing_loads()

bool Halide::Parameter::is_tracing_loads | ( |  | ) | const

## ◆ add_trace_tag()

void Halide::Parameter::add_trace_tag | ( | const std::string & | trace_tag | ) |

## ◆ get_trace_tags()

std::vector< std::string > Halide::Parameter::get_trace_tags | ( |  | ) | const

## Member Data Documentation

## ◆ contents

Internal::IntrusivePtr<Internal::ParameterContents> Halide::Parameter::contents
| protected

Definition at line 48 of file Parameter.h.

Referenced by operator<().

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

- src/Parameter.h