Halide 22.0.0 Halide compiler and libraries

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. */
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. */
60 Dimension set_extent(const Expr &extent);
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. */
66 Dimension set_stride(const Expr &stride);
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
75 Expr min_estimate() const;
76 Expr extent_estimate() const;
77
78 /** Get a different dimension of the same buffer */
79 // @{
80 Dimension dim(int i) const;
81 // @}
82
83 private:
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
Func.h
Defines Func - the front-end handle on a halide function, and related classes.
Parameter.h
Defines the internal representation of parameters to halide piplines.
Halide::Func
A halide function.
Definition: Func.h:706
Halide::Internal::Dimension
Definition: Dimension.h:16
Halide::Internal::Dimension::set_stride
Dimension set_stride(const Expr &stride)
Set the stride in a given dimension to equal the given value.
Halide::Internal::Dimension::dim
Dimension dim(int i) const
Get a different dimension of the same buffer.
Halide::Internal::Dimension::min_estimate
Expr min_estimate() const
Halide::Internal::Dimension::stride
Expr stride() const
Get an expression representing the stride of this image in the given dimension.
Halide::Internal::Dimension::max
Expr max() const
Get an expression representing the maximum coordinates of this image parameter in the given dimension...
Halide::Internal::Dimension::extent_estimate
Expr extent_estimate() const
Halide::Internal::Dimension::set_min
Dimension set_min(const Expr &min)
Set the min in a given dimension to equal the given expression.
Halide::Internal::Dimension::min
Expr min() const
Get an expression representing the minimum coordinates of this image parameter in the given dimension...
Halide::Internal::Dimension::extent
Expr extent() const
Get an expression representing the extent of this image parameter in the given dimension.
Halide::Internal::Dimension::set_bounds
Dimension set_bounds(const Expr &min, const Expr &extent)
Set the min and extent in one call.
Halide::Internal::Dimension::set_estimate
Dimension set_estimate(const Expr &min, const Expr &extent)
Set the min and extent estimates in one call.
Halide::Internal::Dimension::set_extent
Dimension set_extent(const Expr &extent)
Set the extent in a given dimension to equal the given expression.
Halide::Parameter
A reference-counted handle to a parameter to a halide pipeline.
Definition: Parameter.h:40
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition: AbstractGenerator.h:19
Halide::LinkageType::Internal
@ Internal
Not visible externally, similar to 'static' linkage in C.
Halide::Expr
A fragment of Halide syntax.
Definition: Expr.h:258