Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
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, typename std::enable_if<!std::is_pointer< T2 >::value >::type * = 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, typename std::enable_if< std::is_void< T2 >::value >::type * = nullptr>
 Param (const Param< OTHER_TYPE > &other)
 Construct a Param<void> from any other Param.
 
template<typename OTHER_TYPE , typename T2 = T, typename std::enable_if<!std::is_void< T2 >::value >::type * = 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, typename std::enable_if< std::is_void< T2 >::value >::type * = nullptr>
Param< T > & operator= (const Param< OTHER_TYPE > &other)
 Copy a Param<void> from any other Param.
 
template<typename OTHER_TYPE , typename T2 = T, typename std::enable_if<!std::is_void< T2 >::value >::type * = 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 Parameterparameter () const
 
Parameterparameter ()
 

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<T>::value
 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)
inlineexplicit

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)
inlineexplicit

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)
inlineexplicit

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, typename std::enable_if<!std::is_pointer< T2 >::value >::type * = nullptr>
Halide::Param< T >::Param ( not_void_T val)
inlineexplicit

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::Param< T >::has_static_type, Halide::Internal, and Halide::Param< T >::set().

◆ 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::Param< T >::has_static_type, and Halide::Param< T >::set().

◆ 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::Param< T >::has_static_type, Halide::Internal, Halide::Param< T >::set(), 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::Param< T >::has_static_type, Halide::Param< T >::set(), and Halide::Param< T >::set_range().

◆ Param() [10/11]

template<typename T = void>
template<typename OTHER_TYPE , typename T2 = T, typename std::enable_if< std::is_void< T2 >::value >::type * = 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, typename std::enable_if<!std::is_void< T2 >::value >::type * = 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::Param< T >::type(), Halide::type_of(), and user_assert.

Member Function Documentation

◆ static_type()

template<typename T = void>
static Type Halide::Param< T >::static_type ( )
inlinestatic

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::Param< T >::has_static_type, internal_assert, and Halide::type_of().

◆ operator=() [1/2]

template<typename T = void>
template<typename OTHER_TYPE , typename T2 = T, typename std::enable_if< std::is_void< T2 >::value >::type * = 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.

◆ operator=() [2/2]

template<typename T = void>
template<typename OTHER_TYPE , typename T2 = T, typename std::enable_if<!std::is_void< T2 >::value >::type * = 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::Param< T >::type(), Halide::type_of(), 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::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::Param< T >::Param(), Halide::Param< T >::Param(), Halide::Param< T >::Param(), and Halide::Param< T >::Param().

◆ type()

template<typename T = void>
Type Halide::Param< T >::type ( ) const
inline

◆ 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 225 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

◆ set_max_value()

template<typename T = void>
void Halide::Param< T >::set_max_value ( Expr max)
inline

◆ min_value()

template<typename T = void>
Expr Halide::Param< T >::min_value ( ) const
inline

Definition at line 244 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 248 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

◆ 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 299 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 305 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 312 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 317 of file Param.h.

◆ parameter() [2/2]

template<typename T = void>
Parameter & Halide::Param< T >::parameter ( )
inline

Definition at line 321 of file Param.h.

Member Data Documentation

◆ has_static_type

template<typename T = void>
bool Halide::Param< T >::has_static_type = !std::is_void<T>::value
staticconstexpr

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