Halide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Halide::ImageParam Class Reference

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

#include <ImageParam.h>

Inherits Halide::OutputImageParam.

Public Member Functions

 ImageParam ()
 Construct a nullptr image parameter handle. More...
 
EXPORT ImageParam (Type t, int d)
 Construct an image parameter of the given type and dimensionality, with an auto-generated unique name. More...
 
EXPORT ImageParam (Type t, int d, const std::string &n)
 Construct an image parameter of the given type and dimensionality, with the given name. More...
 
EXPORT void reset ()
 Unbind any bound Buffer. More...
 
EXPORT operator Func () const
 Return the intrinsic Func representation of this ImageParam. More...
 
EXPORT void set (Buffer<> im)
 Bind an Image to this ImageParam. More...
 
EXPORT Buffer get () const
 Get a reference to the Buffer bound to this ImageParam. More...
 
template<typename... Args>
NO_INLINE Expr operator() (Args &&...args) const
 Construct an expression which loads from this image parameter. More...
 
EXPORT Expr operator() (std::vector< Expr >) const
 Construct an expression which loads from this image parameter. More...
 
EXPORT Expr operator() (std::vector< Var >) const
 Construct an expression which loads from this image parameter. More...
 
EXPORT Func in (const Func &f)
 Creates and returns a new Func that wraps this ImageParam. More...
 
EXPORT Func in (const std::vector< Func > &fs)
 Creates and returns a new Func that wraps this ImageParam. More...
 
EXPORT Func in ()
 Creates and returns a new Func that wraps this ImageParam. More...
 
- Public Member Functions inherited from Halide::OutputImageParam
 OutputImageParam ()
 Construct a null image parameter handle. More...
 
EXPORT OutputImageParam (const Internal::Parameter &p, Argument::Kind k)
 Construct an OutputImageParam that wraps an Internal Parameter object. More...
 
EXPORT const std::string & name () const
 Get the name of this Param. More...
 
EXPORT Type type () const
 Get the type of the image data this Param refers to. More...
 
EXPORT bool defined () const
 Is this parameter handle non-nullptr. More...
 
EXPORT 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. More...
 
EXPORT const Internal::Dimension dim (int i) const
 Get a handle on one of the dimensions for the purposes of inspecting its min, extent, or stride. More...
 
EXPORT int host_alignment () const
 Get the alignment of the host pointer in bytes. More...
 
EXPORT OutputImageParamset_host_alignment (int)
 Set the expected alignment of the host pointer in bytes. More...
 
EXPORT int dimensions () const
 Get the dimensionality of this image parameter. More...
 
EXPORT 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. More...
 
EXPORT 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. More...
 
EXPORT Expr top () const
 Get an expression giving the minimum coordinate in dimension 1, which by convention is the top of the image. More...
 
EXPORT Expr bottom () const
 Get an expression giving the maximum coordinate in dimension 1, which by convention is the bottom of the image. More...
 
EXPORT Expr width () const
 Get an expression giving the extent in dimension 0, which by convention is the width of the image. More...
 
EXPORT Expr height () const
 Get an expression giving the extent in dimension 1, which by convention is the height of the image. More...
 
EXPORT Expr channels () const
 Get an expression giving the extent in dimension 2, which by convention is the channel-count of the image. More...
 
EXPORT Internal::Parameter parameter () const
 Get at the internal parameter object representing this ImageParam. More...
 
EXPORT operator Argument () const
 Construct the appropriate argument matching this parameter, for the purpose of generating the right type signature when statically compiling halide pipelines. More...
 
EXPORT operator ExternFuncArgument () const
 Using a param as the argument to an external stage treats it as an Expr. More...
 
 HALIDE_ATTRIBUTE_DEPRECATED ("set_min() is deprecated. use dim(n).set_min() instead.") OutputImageParam set_min(int i
 Get or constrain the shape of the dimensions. More...
 
 HALIDE_ATTRIBUTE_DEPRECATED ("set_extent() is deprecated. use dim(n).set_extent() instead.") OutputImageParam set_extent(int i
 Get or constrain the shape of the dimensions. More...
 
 HALIDE_ATTRIBUTE_DEPRECATED ("set_bounds() is deprecated. use dim(n).set_bounds() instead.") OutputImageParam set_bounds(int i
 Get or constrain the shape of the dimensions. More...
 
 HALIDE_ATTRIBUTE_DEPRECATED ("set_stride() is deprecated. use dim(n).set_stride() instead.") OutputImageParam set_stride(int i
 Get or constrain the shape of the dimensions. More...
 
 HALIDE_ATTRIBUTE_DEPRECATED ("min() is deprecated. use dim(n).min() instead.") Expr min(int i) const
 Get or constrain the shape of the dimensions. More...
 
 HALIDE_ATTRIBUTE_DEPRECATED ("extent() is deprecated. use dim(n).extent() instead.") Expr extent(int i) const
 Get or constrain the shape of the dimensions. More...
 
 HALIDE_ATTRIBUTE_DEPRECATED ("stride() is deprecated. use dim(n).stride() instead.") Expr stride(int i) const
 Get or constrain the shape of the dimensions. More...
 

Additional Inherited Members

- Public Attributes inherited from Halide::OutputImageParam
Expr e {dim(i).set_min(e)
 Get or constrain the shape of the dimensions. More...
 
return * this
 Get or constrain the shape of the dimensions. More...
 
Expr a
 Get or constrain the shape of the dimensions. More...
 
Expr Expr b {dim(i).set_bounds(a, b)
 Get or constrain the shape of the dimensions. More...
 
- 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
 
- Protected Attributes inherited from Halide::OutputImageParam
Internal::Parameter param
 A reference-counted handle on the internal parameter object. More...
 
Argument::Kind kind
 Is this an input or an output? OutputImageParam is the base class for both. More...
 

Detailed Description

An Image parameter to a halide pipeline.

E.g., the input image.

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

Definition at line 16 of file ImageParam.h.

Constructor & Destructor Documentation

Halide::ImageParam::ImageParam ( )
inline

Construct a nullptr image parameter handle.

Definition at line 29 of file ImageParam.h.

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

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

EXPORT 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

EXPORT void Halide::ImageParam::set ( Buffer<>  im)

Bind an Image to this ImageParam.

Only relevant for jitting

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

Get a reference to the Buffer bound to this ImageParam.

Only relevant for jitting.

EXPORT void Halide::ImageParam::reset ( )

Unbind any bound Buffer.

template<typename... Args>
NO_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 59 of file ImageParam.h.

EXPORT Expr Halide::ImageParam::operator() ( std::vector< Expr ) const

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)

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

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)

EXPORT 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);

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

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

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);

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.

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

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

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);

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.

EXPORT Func Halide::ImageParam::in ( )

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

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);

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.


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