Halide  17.0.2
Halide compiler and libraries
OutputImageParam.h
Go to the documentation of this file.
1 #ifndef HALIDE_OUTPUT_IMAGE_PARAM_H
2 #define HALIDE_OUTPUT_IMAGE_PARAM_H
3 
4 /** \file
5  *
6  * Classes for declaring output image parameters to halide pipelines
7  */
8 
9 #include "Argument.h"
10 #include "Dimension.h"
11 #include "Func.h"
12 #include "Var.h"
13 #include "runtime/HalideRuntime.h"
14 
15 namespace Halide {
16 
17 /** A handle on the output buffer of a pipeline. Used to make static
18  * promises about the output size and stride. */
20 protected:
21  friend class Func;
22 
23  /** A reference-counted handle on the internal parameter object */
25 
26  /** Is this an input or an output? OutputImageParam is the base class for both. */
28 
29  /** If Input: Func representation of the ImageParam.
30  * If Output: Func that creates this OutputImageParam.
31  */
33 
34  void add_implicit_args_if_placeholder(std::vector<Expr> &args,
35  Expr last_arg,
36  int total_args,
37  bool *placeholder_seen) const;
38 
39  /** Construct an OutputImageParam that wraps an Internal Parameter object. */
41 
42 public:
43  /** Construct a null image parameter handle. */
44  OutputImageParam() = default;
45 
46  /** Get the name of this Param */
47  const std::string &name() const;
48 
49  /** Get the type of the image data this Param refers to */
50  Type type() const;
51 
52  /** Is this parameter handle non-nullptr */
53  bool defined() const;
54 
55  /** Get a handle on one of the dimensions for the purposes of
56  * inspecting or constraining its min, extent, or stride. */
57  Internal::Dimension dim(int i);
58 
59  /** Get a handle on one of the dimensions for the purposes of
60  * inspecting its min, extent, or stride. */
61  Internal::Dimension dim(int i) const;
62 
63  /** Get the alignment of the host pointer in bytes. Defaults to
64  * the size of type. */
65  int host_alignment() const;
66 
67  /** Set the expected alignment of the host pointer in bytes. */
69 
70  /** Get the dimensionality of this image parameter */
71  int dimensions() const;
72 
73  /** Get an expression giving the minimum coordinate in dimension 0, which
74  * by convention is the coordinate of the left edge of the image */
75  Expr left() const;
76 
77  /** Get an expression giving the maximum coordinate in dimension 0, which
78  * by convention is the coordinate of the right edge of the image */
79  Expr right() const;
80 
81  /** Get an expression giving the minimum coordinate in dimension 1, which
82  * by convention is the top of the image */
83  Expr top() const;
84 
85  /** Get an expression giving the maximum coordinate in dimension 1, which
86  * by convention is the bottom of the image */
87  Expr bottom() const;
88 
89  /** Get an expression giving the extent in dimension 0, which by
90  * convention is the width of the image */
91  Expr width() const;
92 
93  /** Get an expression giving the extent in dimension 1, which by
94  * convention is the height of the image */
95  Expr height() const;
96 
97  /** Get an expression giving the extent in dimension 2, which by
98  * convention is the channel-count of the image */
99  Expr channels() const;
100 
101  /** Get at the internal parameter object representing this ImageParam. */
102  Parameter parameter() const;
103 
104  /** Construct the appropriate argument matching this parameter,
105  * for the purpose of generating the right type signature when
106  * statically compiling halide pipelines. */
107  operator Argument() const;
108 
109  /** Using a param as the argument to an external stage treats it
110  * as an Expr */
111  operator ExternFuncArgument() const;
112 
113  /** Set (min, extent) estimates for all dimensions in the ImageParam
114  * at once; this is equivalent to calling `dim(n).set_estimate(min, extent)`
115  * repeatedly, but slightly terser. The size of the estimates vector
116  * must match the dimensionality of the ImageParam. */
117  OutputImageParam &set_estimates(const Region &estimates);
118 
119  /** Set the desired storage type for this parameter. Only useful
120  * for MemoryType::GPUTexture at present */
122 };
123 
124 } // namespace Halide
125 
126 #endif
std::vector< Range > Region
A multi-dimensional box.
Definition: Expr.h:345
int host_alignment() const
Get the alignment of the host pointer in bytes.
Func func
If Input: Func representation of the ImageParam.
A fragment of Halide syntax.
Definition: Expr.h:258
Expr height() const
Get an expression giving the extent in dimension 1, which by convention is the height of the image...
int dimensions() const
Get the dimensionality of this image parameter.
A halide function.
Definition: Func.h:706
bool defined() const
Is this parameter handle non-nullptr.
A struct representing an argument to a halide-generated function.
Definition: Argument.h:37
Expr left() const
Get an expression giving the minimum coordinate in dimension 0, which by convention is the coordinate...
Type type() const
Get the type of the image data this Param refers to.
A reference-counted handle to a parameter to a halide pipeline.
Definition: Parameter.h:40
OutputImageParam & set_host_alignment(int)
Set the expected alignment of the host pointer in bytes.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline, and contains methods to using Halide&#39;s bounds tools to query properties of it.
OutputImageParam()=default
Construct a null image parameter handle.
OutputImageParam & set_estimates(const Region &estimates)
Set (min, extent) estimates for all dimensions in the ImageParam at once; this is equivalent to calli...
Defines Func - the front-end handle on a halide function, and related classes.
Parameter parameter() const
Get at the internal parameter object representing this ImageParam.
Internal::Dimension dim(int i)
Get a handle on one of the dimensions for the purposes of inspecting or constraining its min...
This file declares the routines used by Halide internally in its runtime.
Expr top() const
Get an expression giving the minimum coordinate in dimension 1, which by convention is the top of the...
A handle on the output buffer of a pipeline.
const std::string & name() const
Get the name of this Param.
Expr channels() const
Get an expression giving the extent in dimension 2, which by convention is the channel-count of the i...
void add_implicit_args_if_placeholder(std::vector< Expr > &args, Expr last_arg, int total_args, bool *placeholder_seen) const
Defines the Var - the front-end variable.
Defines the Dimension utility class for Halide pipelines.
Defines a type used for expressing the type signature of a generated halide pipeline.
Expr bottom() const
Get an expression giving the maximum coordinate in dimension 1, which by convention is the bottom of ...
An argument to an extern-defined Func.
Types in the halide type system.
Definition: Type.h:276
Expr width() const
Get an expression giving the extent in dimension 0, which by convention is the width of the image...
OutputImageParam & store_in(MemoryType type)
Set the desired storage type for this parameter.
Kind
An argument is either a primitive type (for parameters), or a buffer pointer.
Definition: Argument.h:52
Parameter param
A reference-counted handle on the internal parameter object.
Argument::Kind kind
Is this an input or an output? OutputImageParam is the base class for both.
Expr right() const
Get an expression giving the maximum coordinate in dimension 0, which by convention is the coordinate...
MemoryType
An enum describing different address spaces to be used with Func::store_in.
Definition: Expr.h:348