Halide
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. */
45  : kind(Argument::InputScalar) {
46  }
47 
48  /** Get the name of this Param */
49  const std::string &name() const;
50 
51  /** Get the type of the image data this Param refers to */
52  Type type() const;
53 
54  /** Is this parameter handle non-nullptr */
55  bool defined() const;
56 
57  /** Get a handle on one of the dimensions for the purposes of
58  * inspecting or constraining its min, extent, or stride. */
59  Internal::Dimension dim(int i);
60 
61  /** Get a handle on one of the dimensions for the purposes of
62  * inspecting its min, extent, or stride. */
63  const Internal::Dimension dim(int i) const;
64 
65  /** Get the alignment of the host pointer in bytes. Defaults to
66  * the size of type. */
67  int host_alignment() const;
68 
69  /** Set the expected alignment of the host pointer in bytes. */
71 
72  /** Get the dimensionality of this image parameter */
73  int dimensions() const;
74 
75  /** Get an expression giving the minimum coordinate in dimension 0, which
76  * by convention is the coordinate of the left edge of the image */
77  Expr left() const;
78 
79  /** Get an expression giving the maximum coordinate in dimension 0, which
80  * by convention is the coordinate of the right edge of the image */
81  Expr right() const;
82 
83  /** Get an expression giving the minimum coordinate in dimension 1, which
84  * by convention is the top of the image */
85  Expr top() const;
86 
87  /** Get an expression giving the maximum coordinate in dimension 1, which
88  * by convention is the bottom of the image */
89  Expr bottom() const;
90 
91  /** Get an expression giving the extent in dimension 0, which by
92  * convention is the width of the image */
93  Expr width() const;
94 
95  /** Get an expression giving the extent in dimension 1, which by
96  * convention is the height of the image */
97  Expr height() const;
98 
99  /** Get an expression giving the extent in dimension 2, which by
100  * convention is the channel-count of the image */
101  Expr channels() const;
102 
103  /** Get at the internal parameter object representing this ImageParam. */
105 
106  /** Construct the appropriate argument matching this parameter,
107  * for the purpose of generating the right type signature when
108  * statically compiling halide pipelines. */
109  operator Argument() const;
110 
111  /** Using a param as the argument to an external stage treats it
112  * as an Expr */
113  operator ExternFuncArgument() const;
114 
115  /** Set (min, extent) estimates for all dimensions in the ImageParam
116  * at once; this is equivalent to calling `dim(n).set_estimate(min, extent)`
117  * repeatedly, but slightly terser. The size of the estimates vector
118  * must match the dimensionality of the ImageParam. */
119  OutputImageParam &set_estimates(const Region &estimates);
120 };
121 
122 } // namespace Halide
123 
124 #endif
Halide::OutputImageParam::set_host_alignment
OutputImageParam & set_host_alignment(int)
Set the expected alignment of the host pointer in bytes.
Halide::OutputImageParam::width
Expr width() const
Get an expression giving the extent in dimension 0, which by convention is the width of the image.
Halide::OutputImageParam::parameter
Internal::Parameter parameter() const
Get at the internal parameter object representing this ImageParam.
Halide::Region
std::vector< Range > Region
A multi-dimensional box.
Definition: Expr.h:343
Halide::OutputImageParam::left
Expr left() const
Get an expression giving the minimum coordinate in dimension 0, which by convention is the coordinate...
Halide::Internal::Parameter
A reference-counted handle to a parameter to a halide pipeline.
Definition: Parameter.h:28
Dimension.h
Halide::OutputImageParam::host_alignment
int host_alignment() const
Get the alignment of the host pointer in bytes.
Halide::OutputImageParam::kind
Argument::Kind kind
Is this an input or an output? OutputImageParam is the base class for both.
Definition: OutputImageParam.h:27
Halide::OutputImageParam::func
Func func
If Input: Func representation of the ImageParam.
Definition: OutputImageParam.h:32
Halide::OutputImageParam::right
Expr right() const
Get an expression giving the maximum coordinate in dimension 0, which by convention is the coordinate...
Halide::Argument
A struct representing an argument to a halide-generated function.
Definition: Argument.h:37
Var.h
Halide::Type
Types in the halide type system.
Definition: Type.h:269
Halide::OutputImageParam::OutputImageParam
OutputImageParam()
Construct a null image parameter handle.
Definition: OutputImageParam.h:44
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition: AddAtomicMutex.h:21
Halide::OutputImageParam::defined
bool defined() const
Is this parameter handle non-nullptr.
Halide::ExternFuncArgument
An argument to an extern-defined Func.
Definition: ExternFuncArgument.h:17
Halide::OutputImageParam::name
const std::string & name() const
Get the name of this Param.
Argument.h
Func.h
Halide::Argument::Kind
Kind
An argument is either a primitive type (for parameters), or a buffer pointer.
Definition: Argument.h:52
Halide::OutputImageParam::add_implicit_args_if_placeholder
void add_implicit_args_if_placeholder(std::vector< Expr > &args, Expr last_arg, int total_args, bool *placeholder_seen) const
Halide::OutputImageParam::set_estimates
OutputImageParam & set_estimates(const Region &estimates)
Set (min, extent) estimates for all dimensions in the ImageParam at once; this is equivalent to calli...
Halide::OutputImageParam
A handle on the output buffer of a pipeline.
Definition: OutputImageParam.h:19
Halide::OutputImageParam::param
Internal::Parameter param
A reference-counted handle on the internal parameter object.
Definition: OutputImageParam.h:24
Halide::OutputImageParam::bottom
Expr bottom() const
Get an expression giving the maximum coordinate in dimension 1, which by convention is the bottom of ...
Halide::Func
A halide function.
Definition: Func.h:667
Halide::OutputImageParam::top
Expr top() const
Get an expression giving the minimum coordinate in dimension 1, which by convention is the top of the...
Halide::Internal::Dimension
Definition: Dimension.h:16
Halide::OutputImageParam::channels
Expr channels() const
Get an expression giving the extent in dimension 2, which by convention is the channel-count of the i...
Halide::OutputImageParam::dim
Internal::Dimension dim(int i)
Get a handle on one of the dimensions for the purposes of inspecting or constraining its min,...
HalideRuntime.h
Halide::Expr
A fragment of Halide syntax.
Definition: Expr.h:256
Halide::OutputImageParam::height
Expr height() const
Get an expression giving the extent in dimension 1, which by convention is the height of the image.
Halide::OutputImageParam::dimensions
int dimensions() const
Get the dimensionality of this image parameter.
Halide::OutputImageParam::type
Type type() const
Get the type of the image data this Param refers to.