Halide 22.0.0 Halide compiler and libraries

Loading...
Searching...
No Matches
Public Member Functions | List of all members
Halide::ImageParam Class Reference

An Image parameter to a halide pipeline. More...

`#include <ImageParam.h>`

Inheritance diagram for Halide::ImageParam:

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

## Detailed Description

An Image parameter to a halide pipeline.

E.g., the input image.

Examples
  tutorial/lesson_10_aot_compilation_generate.cpp, and tutorial/lesson_11_cross_compilation.cpp.

Definition at line 23 of file ImageParam.h.

## Constructor & Destructor Documentation

## ◆ ImageParam() [1/3]

Halide::ImageParam::ImageParam | ( |  | ) |
| default

Construct a nullptr image parameter handle.

## ◆ ImageParam() [2/3]

Halide::ImageParam::ImageParam | ( | Type | t,
|  | int | d
| ) |  |

Construct an image parameter of the given type and dimensionality, with an auto-generated unique name.

## ◆ ImageParam() [3/3]

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.

## Member Function Documentation

## ◆ set()

void Halide::ImageParam::set | ( | const Buffer<> & | im | ) |

Bind an Image to this ImageParam.

Only relevant for jitting

## ◆ get()

Buffer Halide::ImageParam::get | ( |  | ) | const

Get a reference to the Buffer bound to this ImageParam.

Only relevant for jitting.

## ◆ reset()

void Halide::ImageParam::reset | ( |  | ) |

Unbind any bound Buffer.

## ◆ operator()() [1/3]

template<typename... Args>

HALIDE_NO_USER_CODE_INLINE Expr Halide::ImageParam::operator() | ( | Args &&... | args | ) | const
| 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.

## ◆ operator()() [2/3]

Expr Halide::ImageParam::operator() | ( | std::vector< Expr > |  | ) | const

## ◆ operator()() [3/3]

Expr Halide::ImageParam::operator() | ( | std::vector< Var > |  | ) | const

## ◆ operator 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:

func.unroll(_0, 2).unroll(_1, 2);
Halide::Func::unroll
Func & unroll(const VarOrRVar &var)
Mark a dimension to be completely unrolled.
Halide::OutputImageParam::func
Func func
If Input: Func representation of the ImageParam.
Definition OutputImageParam.h:32

'_0' represents the first dimension of the Func, while _1 represents the second dimension of the Func.

## ◆ in() [1/3]

Func Halide::ImageParam::in | ( | const Func & | f | ) |

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:

ImageParam img(Int(32), 2);
Func g;
g(x, y) = ... img(x, y) ...
Halide::Func
A halide function.
Definition Func.h:706
Halide::ImageParam
An Image parameter to a halide pipeline.
Definition ImageParam.h:23
Halide::Int
Type Int(int bits, int lanes=1)
Constructing a signed integer type.
Definition Type.h:539
Halide::cast
Internal::ConstantInterval cast(Type t, const Internal::ConstantInterval &a)
Cast operators for ConstantIntervals.

into a pipeline like this:

ImageParam img(Int(32), 2);
Func img_wrap, g;
img_wrap(x, y) = img(x, y);
g(x, y) = ... img_wrap(x, y) ...

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:

ImageParam img(Int(32), 2);
output(x, y) = img(y, x);
Var tx, ty;
output.compute_root().gpu_tile(x, y, tx, ty, 8, 8);
img.in().compute_at(output, x).unroll(_0, 2).unroll(_1, 2).gpu_threads(_0, _1);
Halide::Var
A Halide variable, to be used when defining functions.
Definition Var.h:19

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.

## ◆ in() [2/3]

Func Halide::ImageParam::in | ( | const std::vector< Func > & | fs | ) |

## ◆ in() [3/3]

Func Halide::ImageParam::in | ( |  | ) |

## ◆ trace_loads()

void Halide::ImageParam::trace_loads | ( |  | ) |

Trace all loads from this ImageParam by emitting calls to halide_trace.

## ◆ add_trace_tag()

ImageParam & Halide::ImageParam::add_trace_tag | ( | const std::string & | trace_tag | ) |

Add a trace tag to this ImageParam's Func.

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

- src/ImageParam.h