Halide
Dimension.h
Go to the documentation of this file.
1 #ifndef HALIDE_DIMENSION_H
2 #define HALIDE_DIMENSION_H
3 
4 /** \file
5  * Defines the Dimension utility class for Halide pipelines
6  */
7 
8 #include <utility>
9 
10 #include "Func.h"
11 #include "Parameter.h"
12 
13 namespace Halide {
14 namespace Internal {
15 
16 class Dimension {
17 public:
18  /** Get an expression representing the minimum coordinates of this image
19  * parameter in the given dimension. */
20  Expr min() const;
21 
22  /** Get an expression representing the extent of this image
23  * parameter in the given dimension */
24  Expr extent() const;
25 
26  /** Get an expression representing the maximum coordinates of
27  * this image parameter in the given dimension. */
28  Expr max() const;
29 
30  /** Get an expression representing the stride of this image in the
31  * given dimension */
32  Expr stride() const;
33 
34  /** Set the min in a given dimension to equal the given
35  * expression. Setting the mins to zero may simplify some
36  * addressing math. */
38 
39  /** Set the extent in a given dimension to equal the given
40  * expression. Images passed in that fail this check will generate
41  * a runtime error. Returns a reference to the ImageParam so that
42  * these calls may be chained.
43  *
44  * This may help the compiler generate better
45  * code. E.g:
46  \code
47  im.dim(0).set_extent(100);
48  \endcode
49  * tells the compiler that dimension zero must be of extent 100,
50  * which may result in simplification of boundary checks. The
51  * value can be an arbitrary expression:
52  \code
53  im.dim(0).set_extent(im.dim(1).extent());
54  \endcode
55  * declares that im is a square image (of unknown size), whereas:
56  \code
57  im.dim(0).set_extent((im.dim(0).extent()/32)*32);
58  \endcode
59  * tells the compiler that the extent is a multiple of 32. */
61 
62  /** Set the stride in a given dimension to equal the given
63  * value. This is particularly helpful to set when
64  * vectorizing. Known strides for the vectorized dimension
65  * generate better code. */
67 
68  /** Set the min and extent in one call. */
70 
71  /** Set the min and extent estimates in one call. These values are only
72  * used by the auto-scheduler and/or the RunGen tool/ */
74 
75  HALIDE_ATTRIBUTE_DEPRECATED("Use set_estimate() instead")
77  return set_estimate(std::move(min), std::move(extent));
78  }
79 
80  Expr min_estimate() const;
81  Expr extent_estimate() const;
82 
83  /** Get a different dimension of the same buffer */
84  // @{
85  Dimension dim(int i);
86  const Dimension dim(int i) const;
87  // @}
88 
89 private:
90  friend class ::Halide::OutputImageParam;
91 
92  /** Construct a Dimension representing dimension d of some
93  * Internal::Parameter p. Only friends may construct
94  * these. */
95  Dimension(const Internal::Parameter &p, int d, Func f);
96 
97  Parameter param;
98  int d;
99  Func f;
100 };
101 
102 } // namespace Internal
103 } // namespace Halide
104 
105 #endif
Halide::Internal::Dimension::set_stride
Dimension set_stride(Expr stride)
Set the stride in a given dimension to equal the given value.
Halide::Internal::Dimension::min_estimate
Expr min_estimate() const
Parameter.h
Halide::Internal::Dimension::set_extent
Dimension set_extent(Expr extent)
Set the extent in a given dimension to equal the given expression.
Halide::Internal::Parameter
A reference-counted handle to a parameter to a halide pipeline.
Definition: Parameter.h:28
Halide::Internal::Dimension::extent_estimate
Expr extent_estimate() const
Halide::Internal::Dimension::set_estimate
Dimension set_estimate(Expr min, Expr extent)
Set the min and extent estimates in one call.
Halide::Internal::Dimension::stride
Expr stride() const
Get an expression representing the stride of this image in the given dimension.
Halide::Internal::Dimension::set_bounds
Dimension set_bounds(Expr min, Expr extent)
Set the min and extent in one call.
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition: AddAtomicMutex.h:21
Halide::LinkageType::Internal
@ Internal
Not visible externally, similar to 'static' linkage in C.
Func.h
Halide::Internal::Dimension::max
Expr max() const
Get an expression representing the maximum coordinates of this image parameter in the given dimension...
HALIDE_ATTRIBUTE_DEPRECATED
#define HALIDE_ATTRIBUTE_DEPRECATED(x)
Definition: HalideRuntime.h:1544
Halide::Internal::Dimension::set_min
Dimension set_min(Expr min)
Set the min in a given dimension to equal the given expression.
Halide::Func
A halide function.
Definition: Func.h:667
Halide::Internal::Dimension
Definition: Dimension.h:16
Halide::Internal::Dimension::set_bounds_estimate
Dimension set_bounds_estimate(Expr min, Expr extent)
Definition: Dimension.h:76
Halide::Internal::Dimension::extent
Expr extent() const
Get an expression representing the extent of this image parameter in the given dimension.
Halide::Expr
A fragment of Halide syntax.
Definition: Expr.h:256
Halide::Internal::Dimension::dim
Dimension dim(int i)
Get a different dimension of the same buffer.
Halide::Internal::Dimension::min
Expr min() const
Get an expression representing the minimum coordinates of this image parameter in the given dimension...