ImageParam#
-
class ImageParam : public Halide::OutputImageParam#
An Image parameter to a halide pipeline.
E.g., the input image.
Public 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.
Only relevant for jitting
-
Buffer get() const#
Get a reference to the Buffer bound to this ImageParam.
Only relevant for jitting.
-
template<typename ...Args>
inline Expr operator()(Args&&... args) 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)
-
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.func.unroll(_0, 2).unroll(_1, 2);
-
Func 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:
into a pipeline like this:ImageParam img(Int(32), 2); Func g; g(x, y) = ... img(x, y) ...
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.
-
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.
-
ImageParam() = default#