Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
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
13namespace Halide {
14namespace Internal {
15
16class Dimension {
17public:
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. */
37 Dimension set_min(const Expr &min);
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. */
69 Dimension set_bounds(const Expr &min, const Expr &extent);
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/ */
73 Dimension set_estimate(const Expr &min, const Expr &extent);
74
77
78 /** Get a different dimension of the same buffer */
79 // @{
80 Dimension dim(int i) const;
81 // @}
82
83private:
84 friend class ::Halide::OutputImageParam;
85
86 /** Construct a Dimension representing dimension d of some
87 * Parameter p. Only friends may construct
88 * these. */
89 Dimension(const Parameter &p, int d, Func f);
90
91 Parameter param;
92 int d;
93 Func f;
94};
95
96} // namespace Internal
97} // namespace Halide
98
99#endif
Defines Func - the front-end handle on a halide function, and related classes.
Defines the internal representation of parameters to halide piplines.
A halide function.
Definition Func.h:700
Dimension set_stride(const Expr &stride)
Set the stride in a given dimension to equal the given value.
Dimension dim(int i) const
Get a different dimension of the same buffer.
Expr stride() const
Get an expression representing the stride of this image in the given dimension.
Expr max() const
Get an expression representing the maximum coordinates of this image parameter in the given dimension...
Dimension set_min(const Expr &min)
Set the min in a given dimension to equal the given expression.
Expr min() const
Get an expression representing the minimum coordinates of this image parameter in the given dimension...
Expr extent() const
Get an expression representing the extent of this image parameter in the given dimension.
Dimension set_bounds(const Expr &min, const Expr &extent)
Set the min and extent in one call.
Dimension set_estimate(const Expr &min, const Expr &extent)
Set the min and extent estimates in one call.
Dimension set_extent(const Expr &extent)
Set the extent in a given dimension to equal the given expression.
A reference-counted handle to a parameter to a halide pipeline.
Definition Parameter.h:40
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
A fragment of Halide syntax.
Definition Expr.h:258