Halide 19.0.0
Halide compiler and libraries
|
An Image parameter to a halide pipeline. More...
#include <ImageParam.h>
Public Member Functions | |
ImageParam ()=default | |
Construct a nullptr image parameter handle. | |
ImageParam (Type t, int d) | |
Construct an image parameter of the given type and dimensionality, with an auto-generated unique name. | |
ImageParam (Type t, int d, const std::string &n) | |
Construct an image parameter of the given type and dimensionality, with the given name. | |
void | set (const Buffer<> &im) |
Bind an Image to this ImageParam. | |
Buffer | get () const |
Get a reference to the Buffer bound to this ImageParam. | |
void | reset () |
Unbind any bound Buffer. | |
template<typename... Args> | |
HALIDE_NO_USER_CODE_INLINE Expr | operator() (Args &&...args) const |
Construct an expression which loads from this image parameter. | |
Expr | operator() (std::vector< Expr >) const |
Expr | operator() (std::vector< Var >) const |
operator Func () const | |
Return the intrinsic Func representation of this ImageParam. | |
Func | in (const Func &f) |
Creates and returns a new Func that wraps this ImageParam. | |
Func | in (const std::vector< Func > &fs) |
Func | in () |
void | trace_loads () |
Trace all loads from this ImageParam by emitting calls to halide_trace. | |
ImageParam & | add_trace_tag (const std::string &trace_tag) |
Add a trace tag to this ImageParam's Func. | |
Public Member Functions inherited from Halide::OutputImageParam | |
OutputImageParam ()=default | |
Construct a null image parameter handle. | |
const std::string & | name () const |
Get the name of this Param. | |
Type | type () const |
Get the type of the image data this Param refers to. | |
bool | defined () const |
Is this parameter handle non-nullptr. | |
Internal::Dimension | dim (int i) |
Get a handle on one of the dimensions for the purposes of inspecting or constraining its min, extent, or stride. | |
Internal::Dimension | dim (int i) const |
Get a handle on one of the dimensions for the purposes of inspecting its min, extent, or stride. | |
int | host_alignment () const |
Get the alignment of the host pointer in bytes. | |
OutputImageParam & | set_host_alignment (int) |
Set the expected alignment of the host pointer in bytes. | |
int | dimensions () const |
Get the dimensionality of this image parameter. | |
Expr | left () const |
Get an expression giving the minimum coordinate in dimension 0, which by convention is the coordinate of the left edge of the image. | |
Expr | right () const |
Get an expression giving the maximum coordinate in dimension 0, which by convention is the coordinate of the right edge of the image. | |
Expr | top () const |
Get an expression giving the minimum coordinate in dimension 1, which by convention is the top of the image. | |
Expr | bottom () const |
Get an expression giving the maximum coordinate in dimension 1, which by convention is the bottom of the image. | |
Expr | width () const |
Get an expression giving the extent in dimension 0, which by convention is the width of the image. | |
Expr | height () const |
Get an expression giving the extent in dimension 1, which by convention is the height of the image. | |
Expr | channels () const |
Get an expression giving the extent in dimension 2, which by convention is the channel-count of the image. | |
Parameter | parameter () const |
Get at the internal parameter object representing this ImageParam. | |
operator Argument () const | |
Construct the appropriate argument matching this parameter, for the purpose of generating the right type signature when statically compiling halide pipelines. | |
operator ExternFuncArgument () const | |
Using a param as the argument to an external stage treats it as an Expr. | |
OutputImageParam & | set_estimates (const Region &estimates) |
Set (min, extent) estimates for all dimensions in the ImageParam at once; this is equivalent to calling dim(n).set_estimate(min, extent) repeatedly, but slightly terser. | |
OutputImageParam & | store_in (MemoryType type) |
Set the desired storage type for this parameter. | |
Additional Inherited Members | |
Protected Member Functions inherited from Halide::OutputImageParam | |
void | add_implicit_args_if_placeholder (std::vector< Expr > &args, Expr last_arg, int total_args, bool *placeholder_seen) const |
OutputImageParam (const Parameter &p, Argument::Kind k, Func f) | |
Construct an OutputImageParam that wraps an Internal Parameter object. | |
Protected Attributes inherited from Halide::OutputImageParam | |
Parameter | param |
A reference-counted handle on the internal parameter object. | |
Argument::Kind | kind = Argument::InputScalar |
Is this an input or an output? OutputImageParam is the base class for both. | |
Func | func |
If Input: Func representation of the ImageParam. | |
An Image parameter to a halide pipeline.
E.g., the input image.
Definition at line 23 of file ImageParam.h.
|
default |
Construct a nullptr image parameter handle.
Halide::ImageParam::ImageParam | ( | Type | t, |
int | d ) |
Construct an image parameter of the given type and dimensionality, with an auto-generated unique name.
Halide::ImageParam::ImageParam | ( | Type | t, |
int | d, | ||
const std::string & | n ) |
Construct an image parameter of the given type and dimensionality, with the given name.
void Halide::ImageParam::set | ( | const Buffer<> & | im | ) |
Bind an Image to this ImageParam.
Only relevant for jitting
Buffer Halide::ImageParam::get | ( | ) | const |
Get a reference to the Buffer bound to this ImageParam.
Only relevant for jitting.
void Halide::ImageParam::reset | ( | ) |
Unbind any bound Buffer.
|
inline |
Construct an expression which loads from this image parameter.
The location is extended with enough implicit variables to match the dimensionality of the image (see Var::implicit)
Definition at line 67 of file ImageParam.h.
References Halide::OutputImageParam::func.
Halide::ImageParam::operator Func | ( | ) | const |
Return the intrinsic Func representation of this ImageParam.
This allows an ImageParam to be implicitly converted to a Func.
Note that we use implicit vars to name the dimensions of Funcs associated with the ImageParam: both its internal Func representation and wrappers (See ImageParam::in). For example, to unroll the first and second dimensions of the associated Func by a factor of 2, we would do the following:
'_0' represents the first dimension of the Func, while _1 represents the second dimension of the Func.
Creates and returns a new Func that wraps this ImageParam.
During compilation, Halide will replace calls to this ImageParam with calls to the wrapper as appropriate. If this ImageParam is already wrapped for use in some Func, it will return the existing wrapper.
For example, img.in(g) would rewrite a pipeline like this:
into a pipeline like this:
This has a variety of uses. One use case is to stage loads from an ImageParam via some intermediate buffer (e.g. on the stack or in shared GPU memory).
The following example illustrates how you would use the 'in()' directive to stage loads from an ImageParam into the GPU shared memory:
Note that we use implicit vars to name the dimensions of the wrapper Func. See Func::in for more possible use cases of the 'in()' directive.
Func Halide::ImageParam::in | ( | ) |
void Halide::ImageParam::trace_loads | ( | ) |
Trace all loads from this ImageParam by emitting calls to halide_trace.
ImageParam & Halide::ImageParam::add_trace_tag | ( | const std::string & | trace_tag | ) |
Add a trace tag to this ImageParam's Func.