Parameter#

class Parameter#

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

May be a scalar parameter or a buffer

Public 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.

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(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).

Type type() const#

Get the type of this parameter.

int dimensions() const#

Get the dimensionality of this parameter.

Zero for scalars.

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>
inline T scalar() const#

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

Only relevant when jitting

Expr 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.

bool has_scalar_value() const#

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

template<typename T>
inline void set_scalar(T val)#

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

Only relevant when jitting

void 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<void> buffer() const#

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

Only relevant when jitting

void set_buffer(const Buffer<void> &b)#

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

Only relevant when jitting

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.

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.

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

void 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).

inline 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.