21 template<
typename T =
void>
29 struct DynamicParamType;
32 using not_void_T =
typename std::conditional<std::is_void<T>::value, DynamicParamType *, T>
::type;
34 void check_name()
const {
36 <<
"Param<void*>(\"__user_context\") "
37 <<
"is no longer used to control whether Halide functions take explicit "
38 <<
"user_context arguments. Use set_custom_user_context() when jitting, "
39 <<
"or add Target::UserContext to the Target feature set when compiling ahead of time.";
44 return (((
int)code) << 8) | bits;
48 template<
typename OTHER_TYPE>
67 static_assert(
has_static_type,
"Cannot use this ctor without an explicit type.");
71 static_assert(!
has_static_type,
"Cannot use this ctor with an explicit type.");
77 explicit Param(
const std::string &n)
78 : param(
type_of<T>(), false, 0, n) {
79 static_assert(
has_static_type,
"Cannot use this ctor without an explicit type.");
83 : param(
type_of<T>(), false, 0, n) {
84 static_assert(
has_static_type,
"Cannot use this ctor without an explicit type.");
88 : param(t, false, 0, n) {
89 static_assert(!
has_static_type,
"Cannot use this ctor with an explicit type.");
96 template<typename T2 = T, typename std::enable_if<!std::is_pointer<T2>::value>
::type * =
nullptr>
99 static_assert(
has_static_type,
"Cannot use this ctor without an explicit type.");
100 set<not_void_T>(val);
105 Param(
const std::string &n, not_void_T val)
106 : param(
type_of<T>(), false, 0, n) {
108 static_assert(
has_static_type,
"Cannot use this ctor without an explicit type.");
109 set<not_void_T>(val);
116 static_assert(
has_static_type,
"Cannot use this ctor without an explicit type.");
118 set<not_void_T>(val);
124 : param(
type_of<T>(), false, 0, n) {
125 static_assert(
has_static_type,
"Cannot use this ctor without an explicit type.");
128 set<not_void_T>(val);
132 template<typename OTHER_TYPE, typename T2 = T, typename std::enable_if<std::is_void<T2>::value>
::type * =
nullptr>
134 : param(other.param) {
140 template<typename OTHER_TYPE, typename T2 = T, typename std::enable_if<!std::is_void<T2>::value>
::type * =
nullptr>
142 : param(other.param) {
144 <<
"Param<" << type_of<T>() <<
"> cannot be constructed from a Param with type " << other.
type();
148 template<typename OTHER_TYPE, typename T2 = T, typename std::enable_if<std::is_void<T2>::value>
::type * =
nullptr>
156 template<typename OTHER_TYPE, typename T2 = T, typename std::enable_if<!std::is_void<T2>::value>
::type * =
nullptr>
159 <<
"Param<" << type_of<T>() <<
"> cannot be copied from a Param with type " << other.
type();
165 const std::string &
name()
const {
171 template<
typename T2 = not_
void_T>
173 return param.
scalar<T2>();
179 template<typename SOME_TYPE, typename T2 = T, typename std::enable_if<!std::is_void<T2>::value>
::type * =
nullptr>
182 <<
"The value " << val <<
" cannot be losslessly converted to type " <<
type();
189 template<typename SOME_TYPE, typename T2 = T, typename std::enable_if<std::is_void<T2>::value>
::type * =
nullptr>
191 #define HALIDE_HANDLE_TYPE_DISPATCH(CODE, BITS, TYPE) \
192 case halide_type_code(CODE, BITS): \
193 user_assert(Internal::IsRoundtrippable<TYPE>::value(val)) \
194 << "The value " << val << " cannot be losslessly converted to type " << type; \
195 param.set_scalar<TYPE>(Internal::StaticCast<TYPE>::value(val)); \
216 #undef HALIDE_HANDLE_TYPE_DISPATCH
256 template<
typename SOME_TYPE>
259 <<
"The value " << value <<
" cannot be losslessly converted to type " <<
type();
Defines a type used for expressing the type signature of a generated halide pipeline.
#define internal_assert(c)
Defines the internal representation of a halide ExternFuncArgument.
halide_type_code_t
Types in the halide type system.
@ halide_type_float
IEEE floating point numbers.
@ halide_type_handle
opaque pointer type (void *)
@ halide_type_int
signed integers
@ halide_type_uint
unsigned integers
Subtypes for Halide expressions (Halide::Expr) and statements (Halide::Internal::Stmt)
#define HALIDE_HANDLE_TYPE_DISPATCH(CODE, BITS, TYPE)
#define HALIDE_NO_USER_CODE_INLINE
A reference-counted handle to a parameter to a halide pipeline.
ArgumentEstimates get_argument_estimates() const
Get the ArgumentEstimates appropriate for this Parameter.
void set_estimate(Expr e)
HALIDE_NO_USER_CODE_INLINE T scalar() const
If the parameter is a scalar parameter, get its currently bound value.
HALIDE_NO_USER_CODE_INLINE void set_scalar(T val)
If the parameter is a scalar parameter, set its current value.
const std::string & name() const
Get the name of this parameter.
Type type() const
Get the type of this parameter.
void set_min_value(const Expr &e)
Get and set constraints for scalar parameters.
void set_max_value(const Expr &e)
A scalar parameter to a halide pipeline.
const std::string & name() const
Get the name of this parameter.
void set_range(const Expr &min, const Expr &max)
Get or set the possible range of this parameter.
Param(const Param< OTHER_TYPE > &other)
Construct a Param<void> from any other Param.
void set_estimate(const SOME_TYPE &value)
Internal::Parameter & parameter()
void set_min_value(Expr min)
HALIDE_NO_USER_CODE_INLINE void set(const SOME_TYPE &val)
Set the current value of this parameter.
Param(not_void_T val)
Construct a scalar parameter of type T an initial value of 'val'.
const Internal::Parameter & parameter() const
void set_max_value(Expr max)
Type type() const
Get the halide type of the Param.
Param(Type t, const std::string &n)
static Type static_type()
Get the Halide type of T.
Param< T > & operator=(const Param< OTHER_TYPE > &other)
Copy a Param<void> from any other Param.
static constexpr bool has_static_type
True if the Halide type is not void (or const void).
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()
Construct a scalar parameter of type T with a unique auto-generated name.
Param(const std::string &n)
Construct a scalar parameter of type T with the given name.
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 ...
HALIDE_NO_USER_CODE_INLINE T2 get() const
Get the current value of this parameter.
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'.
std::string make_entity_name(void *stack_ptr, const std::string &type, char prefix)
Make a unique name for an object based on the name of the stack variable passed in.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
Type type_of()
Construct the halide equivalent of a C type.
Expr min(const FuncRef &a, const FuncRef &b)
Explicit overloads of min and max for FuncRef.
Type Handle(int lanes=1, const halide_handle_cplusplus_type *handle_type=nullptr)
Construct a handle type.
Expr user_context_value()
Returns an Expr corresponding to the user context passed to the function (if any).
Expr max(const FuncRef &a, const FuncRef &b)
unsigned __INT64_TYPE__ uint64_t
signed __INT64_TYPE__ int64_t
signed __INT32_TYPE__ int32_t
unsigned __INT8_TYPE__ uint8_t
unsigned __INT16_TYPE__ uint16_t
unsigned __INT32_TYPE__ uint32_t
signed __INT16_TYPE__ int16_t
signed __INT8_TYPE__ int8_t
A struct representing an argument to a halide-generated function.
A fragment of Halide syntax.
HALIDE_ALWAYS_INLINE Type type() const
Get the type of this expression node.
An argument to an extern-defined Func.
static Expr make(Type t, Expr v)
HALIDE_ALWAYS_INLINE bool defined() const
static Expr make(Type type, const std::string &name)
Types in the halide type system.
HALIDE_ALWAYS_INLINE halide_type_code_t code() const
Return the underlying data type of an element as an enum value.
HALIDE_ALWAYS_INLINE int bits() const
Return the bit size of a single element of this type.