1#ifndef HALIDE_PARAMETER_H
2#define HALIDE_PARAMETER_H
18struct ArgumentEstimates;
30#ifdef WITH_SERIALIZATION
34struct ParameterContents;
41 void check_defined()
const;
42 void check_is_buffer()
const;
43 void check_is_scalar()
const;
44 void check_dim_ok(
int dim)
const;
45 void check_type(
const Type &t)
const;
50#ifdef WITH_SERIALIZATION
51 friend class Internal::Deserializer;
52 friend class Internal::Serializer;
84 const std::optional<halide_scalar_value_t> &
scalar_data,
const Expr &scalar_default,
const Expr &scalar_min,
85 const Expr &scalar_max,
const Expr &scalar_estimate);
119 const std::string &
name()
const;
131 memcpy(&t, &sv.u.u64,
sizeof(t));
This file declares the routines used by Halide internally in its runtime.
Support classes for reference-counting via intrusive shared pointers.
Various utility functions used internally Halide.
#define HALIDE_NO_USER_CODE_INLINE
A Halide::Buffer is a named shared reference to a Halide::Runtime::Buffer.
A reference-counted handle to a parameter to a halide pipeline.
void set_stride_constraint(int dim, const Expr &e)
void set_default_value(const Expr &e)
Get and set the default values for scalar parameters.
Parameter & operator=(Parameter &&)=default
void set_min_constraint_estimate(int dim, const Expr &min)
void store_in(MemoryType memory_type)
void set_extent_constraint_estimate(int dim, const Expr &extent)
Expr default_value() const
int dimensions() const
Get the dimensionality of this parameter.
void set_max_value(const Expr &e)
void set_min_constraint(int dim, const Expr &e)
Get and set constraints for the min, extent, stride, and estimates on the min/extent.
const std::string & name() const
Get the name of this parameter.
void set_extent_constraint(int dim, const Expr &e)
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.
HALIDE_NO_USER_CODE_INLINE T scalar() const
If the parameter is a scalar parameter, get its currently bound value.
bool defined() const
Tests if this handle is non-nullptr.
void set_buffer(const Buffer< void > &b)
If the parameter is a buffer parameter, set its current value.
Expr stride_constraint(int dim) const
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.
void set_min_value(const Expr &e)
Get and set constraints for scalar parameters.
Expr min_constraint(int dim) const
bool has_scalar_value() const
This returns true if scalar_expr() would return a valid Expr, false if not.
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.
bool is_buffer() const
Does this parameter refer to a buffer/image?
HALIDE_NO_USER_CODE_INLINE void set_scalar(T val)
If the parameter is a scalar parameter, set its current value.
Parameter & operator=(const Parameter &)=default
void set_host_alignment(int bytes)
void set_estimate(Expr e)
Internal::IntrusivePtr< Internal::ParameterContents > contents
Parameter(Parameter &&)=default
halide_scalar_value_t scalar_data_checked() const
If the Parameter is a scalar and has a valid scalar value, return it.
Type type() const
Get the type of this parameter.
Expr extent_constraint_estimate(int dim) const
const void * read_only_scalar_address() const
Get the pointer to the current value of the scalar parameter.
ArgumentEstimates get_argument_estimates() const
Get the ArgumentEstimates appropriate for this Parameter.
Expr min_constraint_estimate(int dim) const
const halide_buffer_t * raw_buffer() const
Get the raw currently-bound buffer.
int host_alignment() const
Buffer< void > buffer() const
If the parameter is a buffer parameter, get its currently bound buffer.
MemoryType memory_type() const
Expr extent_constraint(int dim) const
void set_scalar(const Type &val_type, halide_scalar_value_t val)
If the parameter is a scalar parameter, set its current value.
Parameter(const Type &t, bool is_buffer, int dimensions)
Construct a new parameter of the given type.
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.
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.
Expr scalar_expr() const
This returns the current value of scalar<type()>() as an Expr.
const std::vector< BufferConstraint > & buffer_constraints() const
Get buffer constraints for all dimensions, only relevant when serializing.
Parameter(const Parameter &)=default
bool operator<(const Parameter &other) const
Order Parameters by their IntrusivePtr so they can be used to index maps.
bool same_as(const Parameter &other) const
Tests if this handle is the same as another handle.
Parameter()=default
Construct a new undefined handle.
A class representing a Halide pipeline.
void check_call_arg_types(const std::string &name, std::vector< Expr > *args, int dims)
Validate arguments to a call to a func, image or imageparam.
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.
MemoryType
An enum describing different address spaces to be used with Func::store_in.
void * memcpy(void *s1, const void *s2, size_t n)
A fragment of Halide syntax.
Intrusive shared pointers have a reference count (a RefCount object) stored in the class itself.
Types in the halide type system.
The raw representation of an image passed around by generated Halide code.
halide_scalar_value_t is a simple union able to represent all the well-known scalar values in a filte...
union halide_scalar_value_t::@3 u