Halide 22.0.0 Halide compiler and libraries

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Halide::Param< T > Class Template Reference

A scalar parameter to a halide pipeline. More...

`#include <Param.h>`

## Public Member Functions
| Param ()
| Construct a scalar parameter of type T with a unique auto-generated name.
| Param (Type t)
| Param (const std::string &n)
| Construct a scalar parameter of type T with the given name.
| Param (const char *n)
| Param (Type t, const std::string &n)
template<typename T2 = T, std::enable_if_t<!std::is_pointer_v< T2 > > * = nullptr>
| Param (not_void_T val)
| Construct a scalar parameter of type T an initial value of 'val'.
| Param (const std::string &n, not_void_T val)
| Construct a scalar parameter of type T with the given name and an initial value of 'val'.
| Param (not_void_T val, const Expr &min, const Expr &max)
| Construct a scalar parameter of type T with an initial value of 'val' and a given min and max.
| Param (const std::string &n, not_void_T val, const Expr &min, const Expr &max)
| Construct a scalar parameter of type T with the given name and an initial value of 'val' and a given min and max.
template<typename OTHER_TYPE , typename T2 = T, std::enable_if_t< std::is_void_v< T2 > > * = nullptr>
| Param (const Param< OTHER_TYPE > &other)
| Construct a Param<void> from any other Param.
template<typename OTHER_TYPE , typename T2 = T, std::enable_if_t<!std::is_void_v< T2 > > * = nullptr>
| Param (const Param< OTHER_TYPE > &other)
| Construct a Param<non-void> from a Param with matching type.
template<typename OTHER_TYPE , typename T2 = T, std::enable_if_t< std::is_void_v< T2 > > * = nullptr>
Param< T > & | operator= (const Param< OTHER_TYPE > &other)
| Copy a Param<void> from any other Param.
template<typename OTHER_TYPE , typename T2 = T, std::enable_if_t<!std::is_void_v< T2 > > * = nullptr>
Param< T > & | operator= (const Param< OTHER_TYPE > &other)
| Copy a Param<non-void> from a Param with matching type.
const std::string & | name () const
| Get the name of this parameter.
template<typename T2 = not_void_T>
HALIDE_NO_USER_CODE_INLINE T2 | get () const
| Get the current value of this parameter.
template<typename SOME_TYPE >
HALIDE_NO_USER_CODE_INLINE void | set (const SOME_TYPE &val)
| Set the current value of this parameter.
Type | type () const
| Get the halide type of the Param.
void | set_range (const Expr &min, const Expr &max)
| Get or set the possible range of this parameter.
void | set_min_value (Expr min)
void | set_max_value (Expr max)
Expr | min_value () const
Expr | max_value () const
template<typename SOME_TYPE >
HALIDE_NO_USER_CODE_INLINE void | set_estimate (const SOME_TYPE &val)
| operator Expr () const
| You can use this parameter as an expression in a halide function definition.
| operator ExternFuncArgument () const
| Using a param as the argument to an external stage treats it as an Expr.
| operator Argument () const
| Construct the appropriate argument matching this parameter, for the purpose of generating the right type signature when statically compiling halide pipelines.
const Parameter & | parameter () const
Parameter & | parameter ()

## Static Public Member Functions
static Type | static_type ()
| Get the Halide type of T.

## Static Public Attributes
static constexpr bool | has_static_type = !std::is_void_v<T>
| True if the Halide type is not void (or const void).

## Detailed Description

template<typename T = void>
class Halide::Param< T >

A scalar parameter to a halide pipeline.

If you're jitting, this should be bound to an actual value of type T using the set method before you realize the function uses this. If you're statically compiling, this param should appear in the argument list.

Examples
  tutorial/lesson_10_aot_compilation_generate.cpp, and tutorial/lesson_11_cross_compilation.cpp.

Definition at line 22 of file Param.h.

## Constructor & Destructor Documentation

## ◆ Param() [1/11]

template<typename T = void>

Halide::Param< T >::Param | ( |  | ) |
| inline

Construct a scalar parameter of type T with a unique auto-generated name.

Definition at line 60 of file Param.h.

References Halide::Param< T >::has_static_type, and Halide::Internal.

## ◆ Param() [2/11]

template<typename T = void>

Halide::Param< T >::Param | ( | Type | t | ) |
| inline explicit

Definition at line 64 of file Param.h.

References Halide::Param< T >::has_static_type, and Halide::Internal.

## ◆ Param() [3/11]

template<typename T = void>

Halide::Param< T >::Param | ( | const std::string & | n | ) |
| inline explicit

Construct a scalar parameter of type T with the given name.

Definition at line 72 of file Param.h.

References Halide::Param< T >::has_static_type.

## ◆ Param() [4/11]

template<typename T = void>

Halide::Param< T >::Param | ( | const char * | n | ) |
| inline explicit

Definition at line 77 of file Param.h.

References Halide::Param< T >::has_static_type.

## ◆ Param() [5/11]

template<typename T = void>

Halide::Param< T >::Param | ( | Type | t,
|  | const std::string & | n
| ) |  |
| inline

Definition at line 82 of file Param.h.

References Halide::Param< T >::has_static_type.

## ◆ Param() [6/11]

template<typename T = void>
template<typename T2 = T, std::enable_if_t<!std::is_pointer_v< T2 > > * = nullptr>

Halide::Param< T >::Param | ( | not_void_T | val | ) |
| inline explicit

Construct a scalar parameter of type T an initial value of 'val'.

Only triggers for non-pointer types.

Definition at line 92 of file Param.h.

References Halide::cast(), Halide::Param< T >::has_static_type, and Halide::Internal.

## ◆ Param() [7/11]

template<typename T = void>

Halide::Param< T >::Param | ( | const std::string & | n,
|  | not_void_T | val
| ) |  |
| inline

Construct a scalar parameter of type T with the given name and an initial value of 'val'.

Definition at line 100 of file Param.h.

References Halide::cast(), and Halide::Param< T >::has_static_type.

## ◆ Param() [8/11]

template<typename T = void>

Halide::Param< T >::Param | ( | not_void_T | val,
|  | const Expr & | min,
|  | const Expr & | max
| ) |  |
| inline

Construct a scalar parameter of type T with an initial value of 'val' and a given min and max.

Definition at line 109 of file Param.h.

References Halide::cast(), Halide::Param< T >::has_static_type, Halide::Internal, and Halide::Param< T >::set_range().

## ◆ Param() [9/11]

template<typename T = void>

Halide::Param< T >::Param | ( | const std::string & | n,
|  | not_void_T | val,
|  | const Expr & | min,
|  | const Expr & | max
| ) |  |
| inline

Construct a scalar parameter of type T with the given name and an initial value of 'val' and a given min and max.

Definition at line 118 of file Param.h.

References Halide::cast(), Halide::Param< T >::has_static_type, and Halide::Param< T >::set_range().

## ◆ Param() [10/11]

template<typename T = void>
template<typename OTHER_TYPE , typename T2 = T, std::enable_if_t< std::is_void_v< T2 > > * = nullptr>

Halide::Param< T >::Param | ( | const Param< OTHER_TYPE > & | other | ) |
| inline

Construct a Param<void> from any other Param.

Definition at line 128 of file Param.h.

## ◆ Param() [11/11]

template<typename T = void>
template<typename OTHER_TYPE , typename T2 = T, std::enable_if_t<!std::is_void_v< T2 > > * = nullptr>

Halide::Param< T >::Param | ( | const Param< OTHER_TYPE > & | other | ) |
| inline

Construct a Param<non-void> from a Param with matching type.

(Do the check at runtime so that we can assign from Param<void> if the types are compatible.)

Definition at line 136 of file Param.h.

References Halide::cast(), and user_assert.

## Member Function Documentation

## ◆ static_type()

template<typename T = void>

static Type Halide::Param< T >::static_type | ( |  | ) |
| inline static

Get the Halide type of T.

Callers should not use the result if has_static_halide_type is false.

Definition at line 52 of file Param.h.

References Halide::cast(), Halide::Param< T >::has_static_type, and internal_assert.

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

template<typename T = void>
template<typename OTHER_TYPE , typename T2 = T, std::enable_if_t< std::is_void_v< T2 > > * = nullptr>

Param< T > & Halide::Param< T >::operator= | ( | const Param< OTHER_TYPE > & | other | ) |
| inline

Copy a Param<void> from any other Param.

Definition at line 144 of file Param.h.

References Halide::cast().

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

template<typename T = void>
template<typename OTHER_TYPE , typename T2 = T, std::enable_if_t<!std::is_void_v< T2 > > * = nullptr>

Param< T > & Halide::Param< T >::operator= | ( | const Param< OTHER_TYPE > & | other | ) |
| inline

Copy a Param<non-void> from a Param with matching type.

(Do the check at runtime so that we can assign from Param<void> if the types are compatible.)

Definition at line 152 of file Param.h.

References Halide::cast(), and user_assert.

## ◆ name()

template<typename T = void>

const std::string & Halide::Param< T >::name | ( |  | ) | const
| inline

Get the name of this parameter.

Definition at line 160 of file Param.h.

References Halide::Parameter::name().

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

## ◆ get()

template<typename T = void>
template<typename T2 = not_void_T>

HALIDE_NO_USER_CODE_INLINE T2 Halide::Param< T >::get | ( |  | ) | const
| inline

Get the current value of this parameter.

Only meaningful when jitting. Asserts if type does not exactly match the Parameter's type.

Definition at line 167 of file Param.h.

References Halide::cast(), and Halide::Parameter::scalar().

## ◆ set()

template<typename T = void>
template<typename SOME_TYPE >

HALIDE_NO_USER_CODE_INLINE void Halide::Param< T >::set | ( | const SOME_TYPE & | val | ) |
| inline

Set the current value of this parameter.

Only meaningful when jitting. Asserts if type is not losslessly-convertible to Parameter's type.

Definition at line 174 of file Param.h.

References HALIDE_HANDLE_TYPE_DISPATCH, halide_type_float, halide_type_handle, halide_type_int, halide_type_uint, internal_error, Halide::Parameter::set_scalar(), Halide::Param< T >::type(), Halide::Parameter::type(), and user_assert.

Referenced by Halide::SimdOpCheckTest::check_one().

## ◆ type()

template<typename T = void>

Type Halide::Param< T >::type | ( |  | ) | const
| inline

Get the halide type of the Param.

Definition at line 215 of file Param.h.

References Halide::Parameter::type().

Referenced by Halide::Param< T >::operator Argument(), Halide::Param< T >::set(), and Halide::Param< T >::set_estimate().

## ◆ set_range()

template<typename T = void>

void Halide::Param< T >::set_range | ( | const Expr & | min,
|  | const Expr & | max
| ) |  |
| inline

Get or set the possible range of this parameter.

Use undefined Exprs to mean unbounded.

Definition at line 222 of file Param.h.

References Halide::Param< T >::set_max_value(), and Halide::Param< T >::set_min_value().

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

## ◆ set_min_value()

template<typename T = void>

void Halide::Param< T >::set_min_value | ( | Expr | min | ) |
| inline

Definition at line 227 of file Param.h.

References Halide::Internal::Cast::make(), Halide::Parameter::set_min_value(), and Halide::Parameter::type().

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

## ◆ set_max_value()

template<typename T = void>

void Halide::Param< T >::set_max_value | ( | Expr | max | ) |
| inline

Definition at line 234 of file Param.h.

References Halide::Internal::Cast::make(), Halide::Parameter::set_max_value(), and Halide::Parameter::type().

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

## ◆ min_value()

template<typename T = void>

Expr Halide::Param< T >::min_value | ( |  | ) | const
| inline

Definition at line 241 of file Param.h.

References Halide::Parameter::min_value().

## ◆ max_value()

template<typename T = void>

Expr Halide::Param< T >::max_value | ( |  | ) | const
| inline

Definition at line 245 of file Param.h.

References Halide::Parameter::max_value().

## ◆ set_estimate()

template<typename T = void>
template<typename SOME_TYPE >

HALIDE_NO_USER_CODE_INLINE void Halide::Param< T >::set_estimate | ( | const SOME_TYPE & | val | ) |
| inline

Definition at line 251 of file Param.h.

References Halide::cast(), HALIDE_HANDLE_TYPE_DISPATCH, halide_type_float, halide_type_handle, halide_type_int, halide_type_uint, internal_error, Halide::Parameter::set_estimate(), Halide::Param< T >::type(), Halide::Parameter::type(), and user_assert.

## ◆ operator Expr()

template<typename T = void>

Halide::Param< T >::operator Expr | ( |  | ) | const
| inline

You can use this parameter as an expression in a halide function definition.

Definition at line 293 of file Param.h.

References Halide::Internal::Variable::make(), Halide::Param< T >::name(), and Halide::Parameter::type().

## ◆ operator ExternFuncArgument()

template<typename T = void>

Halide::Param< T >::operator ExternFuncArgument | ( |  | ) | const
| inline

Using a param as the argument to an external stage treats it as an Expr.

Definition at line 299 of file Param.h.

## ◆ operator Argument()

template<typename T = void>

Halide::Param< T >::operator Argument | ( |  | ) | const
| inline

Construct the appropriate argument matching this parameter, for the purpose of generating the right type signature when statically compiling halide pipelines.

Definition at line 306 of file Param.h.

References Halide::Parameter::get_argument_estimates(), Halide::Argument::InputScalar, Halide::Param< T >::name(), and Halide::Param< T >::type().

## ◆ parameter() [1/2]

template<typename T = void>

const Parameter & Halide::Param< T >::parameter | ( |  | ) | const
| inline

Definition at line 311 of file Param.h.

## ◆ parameter() [2/2]

template<typename T = void>

Parameter & Halide::Param< T >::parameter | ( |  | ) |
| inline

Definition at line 315 of file Param.h.

## Member Data Documentation

## ◆ has_static_type

template<typename T = void>

constexpr bool Halide::Param< T >::has_static_type = !std::is_void_v<T>
| static constexpr

True if the Halide type is not void (or const void).

Definition at line 48 of file Param.h.

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

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

- src/Param.h