Halide 13.0.2
Halide compiler and libraries
Realization.h
Go to the documentation of this file.
1#ifndef HALIDE_REALIZATION_H
2#define HALIDE_REALIZATION_H
3
4#include <cstdint>
5#include <vector>
6
7#include "Util.h" // for all_are_convertible
8
9/** \file
10 *
11 * Defines Realization - a vector of Buffer for use in pipelines with multiple outputs.
12 */
13
14namespace Halide {
15
16template<typename T>
17class Buffer;
18
19/** A Realization is a vector of references to existing Buffer objects.
20 * A pipeline with multiple outputs realize to a Realization. */
22private:
23 std::vector<Buffer<void>> images;
24
25public:
26 /** The number of images in the Realization. */
27 size_t size() const;
28
29 /** Get a const reference to one of the images. */
30 const Buffer<void> &operator[](size_t x) const;
31
32 /** Get a reference to one of the images. */
34
35 /** Single-element realizations are implicitly castable to Buffers. */
36 template<typename T>
37 operator Buffer<T>() const {
38 return images[0];
39 }
40
41 /** Construct a Realization that acts as a reference to some
42 * existing Buffers. The element type of the Buffers may not be
43 * const. */
44 template<typename T,
45 typename... Args,
46 typename = typename std::enable_if<Internal::all_are_convertible<Buffer<void>, Args...>::value>::type>
47 Realization(Buffer<T> &a, Args &&...args) {
48 images = std::vector<Buffer<void>>({a, args...});
49 }
50
51 /** Construct a Realization that refers to the buffers in an
52 * existing vector of Buffer<> */
53 explicit Realization(std::vector<Buffer<void>> &e);
54
55 /** Call device_sync() for all Buffers in the Realization.
56 * If one of the calls returns an error, subsequent Buffers won't have
57 * device_sync called; thus callers should consider a nonzero return
58 * code to mean that potentially all of the Buffers are in an indeterminate
59 * state of sync.
60 * Calling this explicitly should rarely be necessary, except for profiling. */
61 int device_sync(void *ctx = nullptr);
62};
63
64} // namespace Halide
65
66#endif
Various utility functions used internally Halide.
A Halide::Buffer is a named shared reference to a Halide::Runtime::Buffer.
Definition: Buffer.h:115
A Realization is a vector of references to existing Buffer objects.
Definition: Realization.h:21
size_t size() const
The number of images in the Realization.
int device_sync(void *ctx=nullptr)
Call device_sync() for all Buffers in the Realization.
Buffer< void > & operator[](size_t x)
Get a reference to one of the images.
const Buffer< void > & operator[](size_t x) const
Get a const reference to one of the images.
Realization(std::vector< Buffer< void > > &e)
Construct a Realization that refers to the buffers in an existing vector of Buffer<>
Realization(Buffer< T > &a, Args &&...args)
Construct a Realization that acts as a reference to some existing Buffers.
Definition: Realization.h:47
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...