Halide
12.0.1
Halide compiler and libraries
|
A templated Buffer class that wraps halide_buffer_t and adds functionality. More...
#include <HalideBuffer.h>
Classes | |
class | Dimension |
Read-only access to the shape. More... | |
Public Types | |
typedef T | ElemType |
Public Member Functions | |
bool | owns_host_memory () const |
Does this Buffer own the host memory it refers to? More... | |
HALIDE_ALWAYS_INLINE Dimension | dim (int i) const |
Access the shape of the buffer. More... | |
int | min (int i) const |
Access to the mins, strides, extents. More... | |
int | extent (int i) const |
int | stride (int i) const |
size_t | number_of_elements () const |
The total number of elements this buffer represents. More... | |
int | dimensions () const |
Get the dimensionality of the buffer. More... | |
halide_type_t | type () const |
Get the type of the elements. More... | |
T * | begin () const |
A pointer to the element with the lowest address. More... | |
T * | end () const |
A pointer to one beyond the element with the highest address. More... | |
size_t | size_in_bytes () const |
The total number of bytes spanned by the data in memory. More... | |
void | reset () |
Reset the Buffer to be equivalent to a default-constructed Buffer of the same static type (if any); Buffer<void> will have its runtime type reset to uint8. More... | |
Buffer () | |
Buffer (const halide_buffer_t &buf, BufferDeviceOwnership ownership=BufferDeviceOwnership::Unmanaged) | |
Make a Buffer from a halide_buffer_t. More... | |
Buffer (const Buffer< T, D > &other) | |
Copy constructor. More... | |
template<typename T2 , int D2> | |
Buffer (const Buffer< T2, D2 > &other) | |
Construct a Buffer from a Buffer of different dimensionality and type. More... | |
Buffer (Buffer< T, D > &&other) noexcept | |
Move constructor. More... | |
template<typename T2 , int D2> | |
Buffer (Buffer< T2, D2 > &&other) | |
Move-construct a Buffer from a Buffer of different dimensionality and type. More... | |
template<typename T2 , int D2> | |
Buffer< T, D > & | operator= (const Buffer< T2, D2 > &other) |
Assign from another Buffer of possibly-different dimensionality and type. More... | |
Buffer< T, D > & | operator= (const Buffer< T, D > &other) |
Standard assignment operator. More... | |
template<typename T2 , int D2> | |
Buffer< T, D > & | operator= (Buffer< T2, D2 > &&other) |
Move from another Buffer of possibly-different dimensionality and type. More... | |
Buffer< T, D > & | operator= (Buffer< T, D > &&other) noexcept |
Standard move-assignment operator. More... | |
void | check_overflow () |
Check the product of the extents fits in memory. More... | |
void | allocate (void *(*allocate_fn)(size_t)=nullptr, void(*deallocate_fn)(void *)=nullptr) |
Allocate memory for this Buffer. More... | |
void | deallocate () |
Drop reference to any owned host or device memory, possibly freeing it, if this buffer held the last reference to it. More... | |
void | device_deallocate () |
Drop reference to any owned device memory, possibly freeing it if this buffer held the last reference to it. More... | |
template<typename... Args, typename = typename std::enable_if<AllInts<Args...>::value>::type> | |
Buffer (halide_type_t t, int first, Args... rest) | |
Allocate a new image of the given size with a runtime type. More... | |
Buffer (int first) | |
Allocate a new image of the given size. More... | |
template<typename... Args, typename = typename std::enable_if<AllInts<Args...>::value>::type> | |
Buffer (int first, int second, Args... rest) | |
Buffer (halide_type_t t, const std::vector< int > &sizes) | |
Allocate a new image of unknown type using a vector of ints as the size. More... | |
Buffer (const std::vector< int > &sizes) | |
Allocate a new image of known type using a vector of ints as the size. More... | |
Buffer (halide_type_t t, const std::vector< int > &sizes, const std::vector< int > &storage_order) | |
Allocate a new image of unknown type using a vector of ints as the size and a vector of indices indicating the storage order for each dimension. More... | |
Buffer (const std::vector< int > &sizes, const std::vector< int > &storage_order) | |
template<typename Array , size_t N> | |
Buffer (Array(&vals)[N]) | |
Make an Buffer that refers to a statically sized array. More... | |
template<typename... Args, typename = typename std::enable_if<AllInts<Args...>::value>::type> | |
Buffer (halide_type_t t, add_const_if_T_is_const< void > *data, int first, Args &&...rest) | |
Initialize an Buffer of runtime type from a pointer and some sizes. More... | |
template<typename... Args, typename = typename std::enable_if<AllInts<Args...>::value>::type> | |
Buffer (T *data, int first, Args &&...rest) | |
Initialize an Buffer from a pointer and some sizes. More... | |
Buffer (T *data, const std::vector< int > &sizes) | |
Initialize an Buffer from a pointer and a vector of sizes. More... | |
Buffer (halide_type_t t, add_const_if_T_is_const< void > *data, const std::vector< int > &sizes) | |
Initialize an Buffer of runtime type from a pointer and a vector of sizes. More... | |
Buffer (halide_type_t t, add_const_if_T_is_const< void > *data, int d, const halide_dimension_t *shape) | |
Initialize an Buffer from a pointer to the min coordinate and an array describing the shape. More... | |
Buffer (halide_type_t t, add_const_if_T_is_const< void > *data, const std::vector< halide_dimension_t > &shape) | |
Initialize a Buffer from a pointer to the min coordinate and a vector describing the shape. More... | |
Buffer (T *data, int d, const halide_dimension_t *shape) | |
Initialize an Buffer from a pointer to the min coordinate and an array describing the shape. More... | |
Buffer (T *data, const std::vector< halide_dimension_t > &shape) | |
Initialize a Buffer from a pointer to the min coordinate and a vector describing the shape. More... | |
~Buffer () | |
Destructor. More... | |
halide_buffer_t * | raw_buffer () |
Get a pointer to the raw halide_buffer_t this wraps. More... | |
const halide_buffer_t * | raw_buffer () const |
operator halide_buffer_t * () | |
Provide a cast operator to halide_buffer_t *, so that instances can be passed directly to Halide filters. More... | |
template<typename T2 > | |
HALIDE_ALWAYS_INLINE Buffer< T2, D > & | as () & |
Return a typed reference to this Buffer. More... | |
template<typename T2 > | |
HALIDE_ALWAYS_INLINE const Buffer< T2, D > & | as () const & |
Return a const typed reference to this Buffer. More... | |
template<typename T2 > | |
HALIDE_ALWAYS_INLINE Buffer< T2, D > | as () && |
Returns this rval Buffer with a different type attached. More... | |
HALIDE_ALWAYS_INLINE Buffer< typename std::add_const< T >::type, D > & | as_const () & |
as_const() is syntactic sugar for .as<const T>(), to avoid the need to recapitulate the type argument. More... | |
HALIDE_ALWAYS_INLINE const Buffer< typename std::add_const< T >::type, D > & | as_const () const & |
HALIDE_ALWAYS_INLINE Buffer< typename std::add_const< T >::type, D > | as_const () && |
int | width () const |
Conventional names for the first three dimensions. More... | |
int | height () const |
int | channels () const |
int | left () const |
Conventional names for the min and max value of each dimension. More... | |
int | right () const |
int | top () const |
int | bottom () const |
Buffer< not_const_T, D > | copy (void *(*allocate_fn)(size_t)=nullptr, void(*deallocate_fn)(void *)=nullptr) const |
Make a new image which is a deep copy of this image. More... | |
Buffer< not_const_T, D > | copy_to_interleaved (void *(*allocate_fn)(size_t)=nullptr, void(*deallocate_fn)(void *)=nullptr) const |
Like copy(), but the copy is created in interleaved memory layout (vs. More... | |
Buffer< not_const_T, D > | copy_to_planar (void *(*allocate_fn)(size_t)=nullptr, void(*deallocate_fn)(void *)=nullptr) const |
Like copy(), but the copy is created in planar memory layout (vs. More... | |
Buffer< T, D > | alias () const |
Make a copy of the Buffer which shares the underlying host and/or device allocations as the existing Buffer. More... | |
template<typename T2 , int D2> | |
void | copy_from (Buffer< T2, D2 > src) |
Fill a Buffer with the values at the same coordinates in another Buffer. More... | |
Buffer< T, D > | cropped (int d, int min, int extent) const |
Make an image that refers to a sub-range of this image along the given dimension. More... | |
void | crop (int d, int min, int extent) |
Crop an image in-place along the given dimension. More... | |
Buffer< T, D > | cropped (const std::vector< std::pair< int, int >> &rect) const |
Make an image that refers to a sub-rectangle of this image along the first N dimensions. More... | |
void | crop (const std::vector< std::pair< int, int >> &rect) |
Crop an image in-place along the first N dimensions. More... | |
Buffer< T, D > | translated (int d, int dx) const |
Make an image which refers to the same data with using translated coordinates in the given dimension. More... | |
void | translate (int d, int delta) |
Translate an image in-place along one dimension by changing how it is indexed. More... | |
Buffer< T, D > | translated (const std::vector< int > &delta) const |
Make an image which refers to the same data translated along the first N dimensions. More... | |
void | translate (const std::vector< int > &delta) |
Translate an image along the first N dimensions by changing how it is indexed. More... | |
void | set_min (const std::vector< int > &mins) |
Set the min coordinate of an image in the first N dimensions. More... | |
template<typename... Args> | |
void | set_min (Args... args) |
bool | contains (const std::vector< int > &coords) const |
Test if a given coordinate is within the bounds of an image. More... | |
template<typename... Args> | |
bool | contains (Args... args) const |
Buffer< T, D > | transposed (int d1, int d2) const |
Make a buffer which refers to the same data in the same layout using a swapped indexing order for the dimensions given. More... | |
void | transpose (int d1, int d2) |
Transpose a buffer in-place by changing how it is indexed. More... | |
void | transpose (const std::vector< int > &order) |
A generalized transpose: instead of swapping two dimensions, pass a vector that lists each dimension index exactly once, in the desired order. More... | |
Buffer< T, D > | transposed (const std::vector< int > &order) const |
Make a buffer which refers to the same data in the same layout using a different ordering of the dimensions. More... | |
Buffer< T, D > | sliced (int d, int pos) const |
Make a lower-dimensional buffer that refers to one slice of this buffer. More... | |
Buffer< T, D > | sliced (int d) const |
Make a lower-dimensional buffer that refers to one slice of this buffer at the dimension's minimum. More... | |
void | slice (int d, int pos) |
Rewrite the buffer to refer to a single lower-dimensional slice of itself along the given dimension at the given coordinate. More... | |
void | slice (int d) |
Slice a buffer in-place at the dimension's minimum. More... | |
Buffer< T, D > | embedded (int d, int pos=0) const |
Make a new buffer that views this buffer as a single slice in a higher-dimensional space. More... | |
void | embed (int d, int pos=0) |
Embed a buffer in-place, increasing the dimensionality. More... | |
void | add_dimension () |
Add a new dimension with a min of zero and an extent of one. More... | |
void | add_dimension_with_stride (int s) |
Add a new dimension with a min of zero, an extent of one, and the specified stride. More... | |
HALIDE_ALWAYS_INLINE void | set_host_dirty (bool v=true) |
Methods for managing any GPU allocation. More... | |
HALIDE_ALWAYS_INLINE bool | device_dirty () const |
bool | host_dirty () const |
void | set_device_dirty (bool v=true) |
int | copy_to_host (void *ctx=nullptr) |
int | copy_to_device (const struct halide_device_interface_t *device_interface, void *ctx=nullptr) |
int | device_malloc (const struct halide_device_interface_t *device_interface, void *ctx=nullptr) |
int | device_free (void *ctx=nullptr) |
int | device_wrap_native (const struct halide_device_interface_t *device_interface, uint64_t handle, void *ctx=nullptr) |
int | device_detach_native (void *ctx=nullptr) |
int | device_and_host_malloc (const struct halide_device_interface_t *device_interface, void *ctx=nullptr) |
int | device_and_host_free (const struct halide_device_interface_t *device_interface, void *ctx=nullptr) |
int | device_sync (void *ctx=nullptr) |
bool | has_device_allocation () const |
BufferDeviceOwnership | device_ownership () const |
Return the method by which the device field is managed. More... | |
T * | data () const |
Get a pointer to the address of the min coordinate. More... | |
template<typename... Args, typename = typename std::enable_if<AllInts<Args...>::value>::type> | |
HALIDE_ALWAYS_INLINE const not_void_T & | operator() (int first, Args... rest) const |
Access elements. More... | |
HALIDE_ALWAYS_INLINE const not_void_T & | operator() () const |
HALIDE_ALWAYS_INLINE const not_void_T & | operator() (const int *pos) const |
template<typename... Args, typename = typename std::enable_if<AllInts<Args...>::value>::type> | |
HALIDE_ALWAYS_INLINE not_void_T & | operator() (int first, Args... rest) |
HALIDE_ALWAYS_INLINE not_void_T & | operator() () |
HALIDE_ALWAYS_INLINE not_void_T & | operator() (const int *pos) |
bool | all_equal (not_void_T val) const |
Tests that all values in this buffer are equal to val. More... | |
Buffer< T, D > & | fill (not_void_T val) |
template<typename Fn , typename... Args, int N = sizeof...(Args) + 1> | |
HALIDE_ALWAYS_INLINE const Buffer< T, D > & | for_each_value (Fn &&f, Args &&...other_buffers) const |
Call a function on every value in the buffer, and the corresponding values in some number of other buffers of the same size. More... | |
template<typename Fn , typename... Args, int N = sizeof...(Args) + 1> | |
HALIDE_ALWAYS_INLINE Buffer< T, D > & | for_each_value (Fn &&f, Args &&...other_buffers) |
template<typename Fn > | |
HALIDE_ALWAYS_INLINE const Buffer< T, D > & | for_each_element (Fn &&f) const |
Call a function at each site in a buffer. More... | |
template<typename Fn > | |
HALIDE_ALWAYS_INLINE Buffer< T, D > & | for_each_element (Fn &&f) |
template<typename Fn , typename = typename std::enable_if<!std::is_arithmetic<typename std::decay<Fn>::type>::value>::type> | |
Buffer< T, D > & | fill (Fn &&f) |
Fill a buffer by evaluating a callable at every site. More... | |
bool | is_bounds_query () const |
Check if an input buffer passed extern stage is a querying bounds. More... | |
void | msan_check_mem_is_initialized (bool entire=false) const |
Convenient check to verify that all of the interesting bytes in the Buffer are initialized under MSAN. More... | |
Static Public Member Functions | |
static halide_type_t | static_halide_type () |
Get the Halide type of T. More... | |
template<typename T2 , int D2> | |
static bool | can_convert_from (const Buffer< T2, D2 > &other) |
Determine if if an Buffer<T, D> can be constructed from some other Buffer type. More... | |
template<typename T2 , int D2> | |
static void | assert_can_convert_from (const Buffer< T2, D2 > &other) |
Fail an assertion at runtime or compile-time if an Buffer<T, D> cannot be constructed from some other Buffer type. More... | |
static Buffer< void, D > | make_interleaved (halide_type_t t, int width, int height, int channels) |
If you use the (x, y, c) indexing convention, then Halide Buffers are stored planar by default. More... | |
static Buffer< T, D > | make_interleaved (int width, int height, int channels) |
If you use the (x, y, c) indexing convention, then Halide Buffers are stored planar by default. More... | |
static Buffer< add_const_if_T_is_const< void >, D > | make_interleaved (halide_type_t t, T *data, int width, int height, int channels) |
Wrap an existing interleaved image. More... | |
static Buffer< T, D > | make_interleaved (T *data, int width, int height, int channels) |
Wrap an existing interleaved image. More... | |
static Buffer< add_const_if_T_is_const< void >, D > | make_scalar (halide_type_t t) |
Make a zero-dimensional Buffer. More... | |
static Buffer< T, D > | make_scalar () |
Make a zero-dimensional Buffer. More... | |
static Buffer< T, D > | make_scalar (T *data) |
Make a zero-dimensional Buffer that points to non-owned, existing data. More... | |
template<typename T2 , int D2> | |
static Buffer< T, D > | make_with_shape_of (Buffer< T2, D2 > src, void *(*allocate_fn)(size_t)=nullptr, void(*deallocate_fn)(void *)=nullptr) |
Make a buffer with the same shape and memory nesting order as another buffer. More... | |
Static Public Attributes | |
static constexpr bool | has_static_halide_type = !T_is_void |
True if the Halide type is not void (or const void). More... | |
A templated Buffer class that wraps halide_buffer_t and adds functionality.
When using Halide from C++, this is the preferred way to create input and output buffers. The overhead of using this class relative to a naked halide_buffer_t is minimal - it uses another ~16 bytes on the stack, and does no dynamic allocations when using it to represent existing memory of a known maximum dimensionality.
The template parameter T is the element type. For buffers where the element type is unknown, or may vary, use void or const void.
D is the maximum number of dimensions that can be represented using space inside the class itself. Set it to the maximum dimensionality you expect this buffer to be. If the actual dimensionality exceeds this, heap storage is allocated to track the shape of the buffer. D defaults to 4, which should cover nearly all usage.
The class optionally allocates and owns memory for the image using a shared pointer allocated with the provided allocator. If they are null, malloc and free are used. Any device-side allocation is considered as owned if and only if the host-side allocation is owned.
Definition at line 131 of file HalideBuffer.h.
typedef T Halide::Runtime::Buffer< T, D >::ElemType |
Definition at line 435 of file HalideBuffer.h.
|
inline |
Definition at line 554 of file HalideBuffer.h.
References buf, and Halide::Runtime::Buffer< T, D >::static_halide_type().
|
inlineexplicit |
Make a Buffer from a halide_buffer_t.
Definition at line 561 of file HalideBuffer.h.
References buf, and Halide::Runtime::Buffer< T, D >::static_halide_type().
|
inline |
|
inline |
Construct a Buffer from a Buffer of different dimensionality and type.
Asserts that the type matches (at runtime, if one of the types is void). Note that this constructor is implicit. This, for example, lets you pass things like Buffer<T> or Buffer<const void> to functions expected Buffer<const T>.
Definition at line 622 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::assert_can_convert_from().
|
inlinenoexcept |
Move constructor.
Definition at line 632 of file HalideBuffer.h.
|
inline |
Move-construct a Buffer from a Buffer of different dimensionality and type.
Asserts that the types match (at runtime if one of the types is void).
Definition at line 646 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::assert_can_convert_from().
|
inline |
Allocate a new image of the given size with a runtime type.
Only used when you do know what size you want but you don't know statically what type the elements are. Pass zeroes to make a buffer suitable for bounds query calls.
Definition at line 784 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::allocate(), Halide::Runtime::Internal::any_zero(), buf, Halide::Runtime::Buffer< T, D >::check_overflow(), and Halide::Runtime::Buffer< T, D >::static_halide_type().
|
inlineexplicit |
Allocate a new image of the given size.
Pass zeroes to make a buffer suitable for bounds query calls.
Definition at line 805 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::allocate(), buf, Halide::Runtime::Buffer< T, D >::check_overflow(), and Halide::Runtime::Buffer< T, D >::static_halide_type().
|
inline |
Definition at line 821 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::allocate(), Halide::Runtime::Internal::any_zero(), buf, Halide::Runtime::Buffer< T, D >::check_overflow(), and Halide::Runtime::Buffer< T, D >::static_halide_type().
|
inline |
Allocate a new image of unknown type using a vector of ints as the size.
Definition at line 837 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::allocate(), Halide::Runtime::Internal::any_zero(), buf, Halide::Runtime::Buffer< T, D >::check_overflow(), and Halide::Runtime::Buffer< T, D >::static_halide_type().
|
inlineexplicit |
Allocate a new image of known type using a vector of ints as the size.
Definition at line 851 of file HalideBuffer.h.
|
inline |
Allocate a new image of unknown type using a vector of ints as the size and a vector of indices indicating the storage order for each dimension.
The length of the sizes vector and the storage-order vector must match. For instance, to allocate an interleaved RGB buffer, you would pass {2, 0, 1} for storage_order.
Definition at line 871 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::transpose().
|
inline |
Definition at line 876 of file HalideBuffer.h.
|
inlineexplicit |
Make an Buffer that refers to a statically sized array.
Does not take ownership of the data, and does not set the host_dirty flag.
Definition at line 883 of file HalideBuffer.h.
References buf.
|
inlineexplicit |
Initialize an Buffer of runtime type from a pointer and some sizes.
Assumes dense row-major packing and a min coordinate of zero. Does not take ownership of the data and does not set the host_dirty flag.
Definition at line 897 of file HalideBuffer.h.
References buf, Halide::Runtime::Buffer< T, D >::data(), and Halide::Runtime::Buffer< T, D >::static_halide_type().
|
inlineexplicit |
Initialize an Buffer from a pointer and some sizes.
Assumes dense row-major packing and a min coordinate of zero. Does not take ownership of the data and does not set the host_dirty flag.
Definition at line 914 of file HalideBuffer.h.
References buf, Halide::Runtime::Buffer< T, D >::data(), and Halide::Runtime::Buffer< T, D >::static_halide_type().
|
inlineexplicit |
Initialize an Buffer from a pointer and a vector of sizes.
Assumes dense row-major packing and a min coordinate of zero. Does not take ownership of the data and does not set the host_dirty flag.
Definition at line 927 of file HalideBuffer.h.
References buf, Halide::Runtime::Buffer< T, D >::data(), and Halide::Runtime::Buffer< T, D >::static_halide_type().
|
inlineexplicit |
Initialize an Buffer of runtime type from a pointer and a vector of sizes.
Assumes dense row-major packing and a min coordinate of zero. Does not take ownership of the data and does not set the host_dirty flag.
Definition at line 938 of file HalideBuffer.h.
References buf, Halide::Runtime::Buffer< T, D >::data(), and Halide::Runtime::Buffer< T, D >::static_halide_type().
|
inlineexplicit |
Initialize an Buffer from a pointer to the min coordinate and an array describing the shape.
Does not take ownership of the data, and does not set the host_dirty flag.
Definition at line 951 of file HalideBuffer.h.
References buf, Halide::Runtime::Buffer< T, D >::data(), and Halide::Runtime::Buffer< T, D >::static_halide_type().
|
inlineexplicit |
Initialize a Buffer from a pointer to the min coordinate and a vector describing the shape.
Does not take ownership of the data, and does not set the host_dirty flag.
Definition at line 966 of file HalideBuffer.h.
|
inlineexplicit |
Initialize an Buffer from a pointer to the min coordinate and an array describing the shape.
Does not take ownership of the data and does not set the host_dirty flag.
Definition at line 974 of file HalideBuffer.h.
References buf, Halide::Runtime::Buffer< T, D >::data(), and Halide::Runtime::Buffer< T, D >::static_halide_type().
|
inlineexplicit |
Initialize a Buffer from a pointer to the min coordinate and a vector describing the shape.
Does not take ownership of the data, and does not set the host_dirty flag.
Definition at line 986 of file HalideBuffer.h.
|
inline |
Destructor.
Will release any underlying owned allocation if this is the last reference to it. Will assert fail if there are weak references to this Buffer outstanding.
Definition at line 993 of file HalideBuffer.h.
|
inlinestatic |
Get the Halide type of T.
Callers should not use the result if has_static_halide_type is false.
Definition at line 174 of file HalideBuffer.h.
Referenced by Halide::Runtime::Buffer< T, D >::Buffer(), Halide::Runtime::Buffer< T, D >::can_convert_from(), Halide::Runtime::Buffer< T, D >::make_interleaved(), and Halide::Buffer< T >::static_halide_type().
|
inline |
Does this Buffer own the host memory it refers to?
Definition at line 179 of file HalideBuffer.h.
|
inline |
Access the shape of the buffer.
Definition at line 495 of file HalideBuffer.h.
References buf, and Halide::Runtime::Buffer< T, D >::dimensions().
Referenced by Halide::Runtime::Buffer< T, D >::bottom(), Halide::Runtime::Buffer< T, D >::channels(), Halide::Runtime::Buffer< T, D >::check_overflow(), Halide::Runtime::Buffer< T, D >::contains(), Halide::Runtime::Buffer< T, D >::copy_from(), Halide::Runtime::Buffer< T, D >::copy_to_planar(), Halide::Runtime::Buffer< T, D >::extent(), Halide::Runtime::Buffer< T, D >::height(), Halide::Runtime::Buffer< T, D >::left(), Halide::Runtime::Buffer< T, D >::min(), Halide::Runtime::Buffer< T, D >::right(), Halide::Runtime::Buffer< T, D >::slice(), Halide::Runtime::Buffer< T, D >::sliced(), Halide::Runtime::Buffer< T, D >::stride(), Halide::Runtime::Buffer< T, D >::top(), and Halide::Runtime::Buffer< T, D >::width().
|
inline |
Access to the mins, strides, extents.
Will be deprecated. Do not use.
Definition at line 502 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), and Halide::Runtime::Buffer< T, D >::Dimension::min().
Referenced by Halide::Runtime::Buffer< T, D >::contains(), Halide::Runtime::Buffer< T, D >::copy_to_interleaved(), Halide::Runtime::Buffer< T, D >::copy_to_planar(), Halide::Runtime::Buffer< T, D >::crop(), Halide::Runtime::Buffer< T, D >::cropped(), Halide::Runtime::Buffer< T, D >::slice(), and Halide::Runtime::Buffer< T, D >::sliced().
|
inline |
Definition at line 505 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), and Halide::Runtime::Buffer< T, D >::Dimension::extent().
Referenced by Halide::Runtime::Buffer< T, D >::copy_to_planar(), Halide::Runtime::Buffer< T, D >::crop(), and Halide::Runtime::Buffer< T, D >::cropped().
|
inline |
Definition at line 508 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), and Halide::Runtime::Buffer< T, D >::Dimension::stride().
|
inline |
The total number of elements this buffer represents.
Equal to the product of the extents
Definition at line 515 of file HalideBuffer.h.
References buf.
|
inline |
Get the dimensionality of the buffer.
Definition at line 520 of file HalideBuffer.h.
References buf.
Referenced by Halide::Runtime::Buffer< T, D >::channels(), Halide::Runtime::Buffer< T, D >::check_overflow(), Halide::Runtime::Buffer< T, D >::contains(), Halide::Runtime::Buffer< T, D >::copy_from(), Halide::Runtime::Buffer< T, D >::copy_to_interleaved(), Halide::Runtime::Buffer< T, D >::copy_to_planar(), Halide::Runtime::Buffer< T, D >::dim(), Halide::Runtime::Buffer< T, D >::embed(), Halide::Runtime::Buffer< T, D >::height(), Halide::Runtime::Buffer< T, D >::make_with_shape_of(), Halide::Runtime::Buffer< T, D >::set_min(), Halide::Runtime::Buffer< T, D >::translate(), Halide::Runtime::Buffer< T, D >::transpose(), and Halide::Runtime::Buffer< T, D >::width().
|
inline |
Get the type of the elements.
Definition at line 525 of file HalideBuffer.h.
References buf.
Referenced by Halide::Runtime::Buffer< T, D >::can_convert_from(), Halide::Runtime::Buffer< T, D >::check_overflow(), Halide::Runtime::Buffer< T, D >::copy_from(), and Halide::Runtime::Buffer< T, D >::make_with_shape_of().
|
inline |
A pointer to the element with the lowest address.
If all strides are positive, equal to the host pointer.
Definition at line 531 of file HalideBuffer.h.
References buf.
|
inline |
A pointer to one beyond the element with the highest address.
Definition at line 537 of file HalideBuffer.h.
References buf.
|
inline |
The total number of bytes spanned by the data in memory.
Definition at line 543 of file HalideBuffer.h.
References buf.
Referenced by Halide::Runtime::Buffer< T, D >::allocate(), and Halide::Runtime::Buffer< T, D >::msan_check_mem_is_initialized().
|
inline |
Reset the Buffer to be equivalent to a default-constructed Buffer of the same static type (if any); Buffer<void> will have its runtime type reset to uint8.
Definition at line 550 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::Buffer.
|
inlinestatic |
Determine if if an Buffer<T, D> can be constructed from some other Buffer type.
If this can be determined at compile time, fail with a static assert; otherwise return a boolean based on runtime typing.
Definition at line 587 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::static_halide_type(), and Halide::Runtime::Buffer< T, D >::type().
Referenced by Halide::Runtime::Buffer< T, D >::assert_can_convert_from(), and Halide::Buffer< T >::can_convert_from().
|
inlinestatic |
Fail an assertion at runtime or compile-time if an Buffer<T, D> cannot be constructed from some other Buffer type.
Definition at line 598 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::can_convert_from().
Referenced by Halide::Runtime::Buffer< T, D >::as(), Halide::Runtime::Buffer< T, D >::Buffer(), and Halide::Runtime::Buffer< T, D >::operator=().
|
inline |
Assign from another Buffer of possibly-different dimensionality and type.
Asserts that the types match (at runtime if one of the types is void).
Definition at line 661 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::assert_can_convert_from(), and buf.
|
inline |
|
inline |
Move from another Buffer of possibly-different dimensionality and type.
Asserts that the types match (at runtime if one of the types is void).
Definition at line 696 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::assert_can_convert_from(), and buf.
|
inlinenoexcept |
|
inline |
Check the product of the extents fits in memory.
Definition at line 725 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), Halide::Runtime::Buffer< T, D >::dimensions(), Halide::Runtime::Buffer< T, D >::Dimension::extent(), and Halide::Runtime::Buffer< T, D >::type().
Referenced by Halide::Runtime::Buffer< T, D >::Buffer().
|
inline |
Allocate memory for this Buffer.
Drops the reference to any owned memory.
Definition at line 740 of file HalideBuffer.h.
References buf, Halide::Runtime::Buffer< T, D >::deallocate(), free(), malloc(), and Halide::Runtime::Buffer< T, D >::size_in_bytes().
Referenced by Halide::Runtime::Buffer< T, D >::Buffer().
|
inline |
Drop reference to any owned host or device memory, possibly freeing it, if this buffer held the last reference to it.
Retains the shape of the buffer. Does nothing if this buffer did not allocate its own memory.
Definition at line 767 of file HalideBuffer.h.
Referenced by Halide::Runtime::Buffer< T, D >::allocate().
|
inline |
Drop reference to any owned device memory, possibly freeing it if this buffer held the last reference to it.
Asserts that device_dirty is false.
Definition at line 774 of file HalideBuffer.h.
Referenced by Halide::Runtime::Buffer< T, D >::cropped(), Halide::Runtime::Buffer< T, D >::set_min(), Halide::Runtime::Buffer< T, D >::sliced(), and Halide::Runtime::Buffer< T, D >::translate().
|
inline |
Get a pointer to the raw halide_buffer_t this wraps.
Definition at line 1000 of file HalideBuffer.h.
References buf.
|
inline |
Definition at line 1004 of file HalideBuffer.h.
References buf.
|
inline |
Provide a cast operator to halide_buffer_t *, so that instances can be passed directly to Halide filters.
Definition at line 1011 of file HalideBuffer.h.
References buf.
|
inline |
Return a typed reference to this Buffer.
Useful for converting a reference to a Buffer<void> to a reference to, for example, a Buffer<const uint8_t>, or converting a Buffer<T>& to Buffer<const T>&. Does a runtime assert if the source buffer type is void.
Definition at line 1020 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::assert_can_convert_from().
|
inline |
Return a const typed reference to this Buffer.
Useful for converting a conference reference to one Buffer type to a const reference to another Buffer type. Does a runtime assert if the source buffer type is void.
Definition at line 1030 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::assert_can_convert_from().
|
inline |
Returns this rval Buffer with a different type attached.
Does a dynamic type check if the source type is void.
Definition at line 1038 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::assert_can_convert_from().
|
inline |
as_const() is syntactic sugar for .as<const T>(), to avoid the need to recapitulate the type argument.
Definition at line 1047 of file HalideBuffer.h.
|
inline |
Definition at line 1054 of file HalideBuffer.h.
|
inline |
Definition at line 1059 of file HalideBuffer.h.
|
inline |
Conventional names for the first three dimensions.
Definition at line 1066 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), Halide::Runtime::Buffer< T, D >::dimensions(), and Halide::Runtime::Buffer< T, D >::Dimension::extent().
Referenced by Halide::Runtime::Buffer< T, D >::copy_to_interleaved(), and Halide::Runtime::Buffer< T, D >::make_interleaved().
|
inline |
Definition at line 1069 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), Halide::Runtime::Buffer< T, D >::dimensions(), and Halide::Runtime::Buffer< T, D >::Dimension::extent().
Referenced by Halide::Runtime::Buffer< T, D >::copy_to_interleaved(), and Halide::Runtime::Buffer< T, D >::make_interleaved().
|
inline |
Definition at line 1072 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), Halide::Runtime::Buffer< T, D >::dimensions(), and Halide::Runtime::Buffer< T, D >::Dimension::extent().
Referenced by Halide::Runtime::Buffer< T, D >::copy_to_interleaved(), and Halide::Runtime::Buffer< T, D >::make_interleaved().
|
inline |
Conventional names for the min and max value of each dimension.
Definition at line 1079 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), and Halide::Runtime::Buffer< T, D >::Dimension::min().
|
inline |
Definition at line 1083 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), and Halide::Runtime::Buffer< T, D >::Dimension::max().
|
inline |
Definition at line 1087 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), and Halide::Runtime::Buffer< T, D >::Dimension::min().
|
inline |
Definition at line 1091 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), and Halide::Runtime::Buffer< T, D >::Dimension::max().
|
inline |
Make a new image which is a deep copy of this image.
Use crop or slice followed by copy to make a copy of only a portion of the image. The new image uses the same memory layout as the original, with holes compacted away. Note that the returned Buffer is always of a non-const type T (ie:
Buffer<const T>.copy() -> Buffer<T> rather than Buffer<const T>
which is always safe, since we are making a deep copy. (The caller can easily cast it back to Buffer<const T> if desired, which is always safe and free.)
Definition at line 1108 of file HalideBuffer.h.
References dst, and Halide::Runtime::Buffer< T, D >::make_with_shape_of().
|
inline |
Like copy(), but the copy is created in interleaved memory layout (vs.
keeping the same memory layout as the original). Requires that 'this' has exactly 3 dimensions.
Definition at line 1119 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::channels(), Halide::Runtime::Buffer< T, D >::dimensions(), dst, Halide::Runtime::Buffer< T, D >::height(), Halide::Runtime::Buffer< T, D >::make_interleaved(), Halide::Runtime::Buffer< T, D >::min(), and Halide::Runtime::Buffer< T, D >::width().
|
inline |
Like copy(), but the copy is created in planar memory layout (vs.
keeping the same memory layout as the original).
Definition at line 1132 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), Halide::Runtime::Buffer< T, D >::dimensions(), dst, Halide::Runtime::Buffer< T, D >::extent(), and Halide::Runtime::Buffer< T, D >::min().
|
inline |
Make a copy of the Buffer which shares the underlying host and/or device allocations as the existing Buffer.
This is purely syntactic sugar for cases where you have a const reference to a Buffer but need a temporary non-const copy (e.g. to make a call into AOT-generated Halide code), and want a terse inline way to create a temporary.
Definition at line 1158 of file HalideBuffer.h.
|
inline |
Fill a Buffer with the values at the same coordinates in another Buffer.
Restricts itself to coordinates contained within the intersection of the two buffers. If the two Buffers are not in the same coordinate system, you will need to translate the argument Buffer first. E.g. if you're blitting a sprite onto a framebuffer, you'll want to translate the sprite to the correct location first like so:
Definition at line 1172 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::crop(), Halide::Runtime::Buffer< T, D >::device_dirty(), Halide::Runtime::Buffer< T, D >::dim(), Halide::Runtime::Buffer< T, D >::dimensions(), dst, Halide::Runtime::Buffer< T, D >::for_each_value(), Halide::Runtime::Buffer< T, D >::Dimension::max(), Halide::max(), Halide::Runtime::Buffer< T, D >::Dimension::min(), Halide::min(), Halide::Runtime::Buffer< T, D >::set_host_dirty(), and Halide::Runtime::Buffer< T, D >::type().
|
inline |
Make an image that refers to a sub-range of this image along the given dimension.
Asserts that the crop region is within the existing bounds: you cannot "crop outwards", even if you know there is valid Buffer storage (e.g. because you already cropped inwards).
Definition at line 1227 of file HalideBuffer.h.
References buf, Halide::Runtime::Buffer< T, D >::device_deallocate(), Halide::Runtime::Buffer< T, D >::extent(), and Halide::Runtime::Buffer< T, D >::min().
Referenced by Halide::Runtime::Buffer< T, D >::crop().
|
inline |
Crop an image in-place along the given dimension.
This does not move any data around in memory - it just changes the min and extent of the given dimension.
Definition at line 1247 of file HalideBuffer.h.
References buf, Halide::Runtime::Buffer< T, D >::cropped(), Halide::Runtime::Buffer< T, D >::extent(), and Halide::Runtime::Buffer< T, D >::min().
Referenced by Halide::Runtime::Buffer< T, D >::copy_from().
|
inline |
Make an image that refers to a sub-rectangle of this image along the first N dimensions.
Asserts that the crop region is within the existing bounds. The cropped image may drop any device handle if the device_interface cannot accomplish the crop in-place.
Definition at line 1263 of file HalideBuffer.h.
References buf, and Halide::Runtime::Buffer< T, D >::device_deallocate().
|
inline |
Crop an image in-place along the first N dimensions.
This does not move any data around in memory, nor does it free memory. It just rewrites the min/extent of each dimension to refer to a subregion of the same allocation.
Definition at line 1284 of file HalideBuffer.h.
References buf, and Halide::Runtime::Buffer< T, D >::cropped().
|
inline |
Make an image which refers to the same data with using translated coordinates in the given dimension.
Positive values move the image data to the right or down relative to the coordinate system. Drops any device handle.
Definition at line 1300 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::translate().
|
inline |
Translate an image in-place along one dimension by changing how it is indexed.
Does not move any data around in memory.
Definition at line 1308 of file HalideBuffer.h.
References buf, Halide::Runtime::Buffer< T, D >::device_deallocate(), and Halide::Runtime::Buffer< T, D >::dimensions().
Referenced by Halide::Runtime::Buffer< T, D >::embed(), Halide::Runtime::Buffer< T, D >::translate(), and Halide::Runtime::Buffer< T, D >::translated().
|
inline |
Make an image which refers to the same data translated along the first N dimensions.
Definition at line 1316 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::translate().
|
inline |
Translate an image along the first N dimensions by changing how it is indexed.
Does not move any data around in memory.
Definition at line 1324 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::device_deallocate(), Halide::Runtime::Buffer< T, D >::dimensions(), Halide::max(), and Halide::Runtime::Buffer< T, D >::translate().
|
inline |
Set the min coordinate of an image in the first N dimensions.
Definition at line 1336 of file HalideBuffer.h.
References buf, Halide::Runtime::Buffer< T, D >::device_deallocate(), and Halide::Runtime::Buffer< T, D >::dimensions().
Referenced by Halide::Runtime::Buffer< T, D >::set_min().
|
inline |
Definition at line 1345 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::set_min().
|
inline |
Test if a given coordinate is within the bounds of an image.
Definition at line 1352 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), Halide::Runtime::Buffer< T, D >::dimensions(), Halide::max(), and Halide::Runtime::Buffer< T, D >::min().
Referenced by Halide::Runtime::Buffer< T, D >::contains().
|
inline |
Definition at line 1363 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::contains().
|
inline |
Make a buffer which refers to the same data in the same layout using a swapped indexing order for the dimensions given.
So A = B.transposed(0, 1) means that A(i, j) == B(j, i), and more strongly that A.address_of(i, j) == B.address_of(j, i).
Definition at line 1372 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::transpose().
|
inline |
Transpose a buffer in-place by changing how it is indexed.
For example, transpose(0, 1) on a two-dimensional buffer means that the value referred to by coordinates (i, j) is now reached at the coordinates (j, i), and vice versa. This is done by reordering the per-dimension metadata rather than by moving data around in memory, so other views of the same memory will not see the data as having been transposed.
Definition at line 1385 of file HalideBuffer.h.
References buf, and Halide::Runtime::Buffer< T, D >::dimensions().
Referenced by Halide::Runtime::Buffer< T, D >::Buffer(), Halide::Runtime::Buffer< T, D >::embed(), Halide::Runtime::Buffer< T, D >::make_interleaved(), Halide::Runtime::Buffer< T, D >::transpose(), and Halide::Runtime::Buffer< T, D >::transposed().
|
inline |
A generalized transpose: instead of swapping two dimensions, pass a vector that lists each dimension index exactly once, in the desired order.
This does not move any data around in memory
Definition at line 1395 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dimensions(), and Halide::Runtime::Buffer< T, D >::transpose().
|
inline |
Make a buffer which refers to the same data in the same layout using a different ordering of the dimensions.
Definition at line 1413 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::transpose().
|
inline |
Make a lower-dimensional buffer that refers to one slice of this buffer.
Definition at line 1421 of file HalideBuffer.h.
References buf, and Halide::Runtime::Buffer< T, D >::device_deallocate().
Referenced by Halide::Runtime::Buffer< T, D >::slice(), and Halide::Runtime::Buffer< T, D >::sliced().
|
inline |
Make a lower-dimensional buffer that refers to one slice of this buffer at the dimension's minimum.
Definition at line 1438 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), Halide::Runtime::Buffer< T, D >::min(), and Halide::Runtime::Buffer< T, D >::sliced().
|
inline |
Rewrite the buffer to refer to a single lower-dimensional slice of itself along the given dimension at the given coordinate.
Does not move any data around or free the original memory, so other views of the same data are unaffected.
Definition at line 1446 of file HalideBuffer.h.
References buf, and Halide::Runtime::Buffer< T, D >::sliced().
Referenced by Halide::Runtime::Buffer< T, D >::slice().
|
inline |
Slice a buffer in-place at the dimension's minimum.
Definition at line 1459 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::dim(), Halide::Runtime::Buffer< T, D >::min(), and Halide::Runtime::Buffer< T, D >::slice().
|
inline |
Make a new buffer that views this buffer as a single slice in a higher-dimensional space.
The new dimension has extent one and the given min. This operation is the opposite of slice. As an example, the following condition is true:
Definition at line 1473 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::embed().
|
inline |
Embed a buffer in-place, increasing the dimensionality.
Definition at line 1481 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::add_dimension(), Halide::Runtime::Buffer< T, D >::dimensions(), Halide::Runtime::Buffer< T, D >::translate(), and Halide::Runtime::Buffer< T, D >::transpose().
Referenced by Halide::Runtime::Buffer< T, D >::embedded().
|
inline |
Add a new dimension with a min of zero and an extent of one.
The stride is the extent of the outermost dimension times its stride. The new dimension is the last dimension. This is a special case of embed.
Definition at line 1494 of file HalideBuffer.h.
References buf.
Referenced by Halide::Runtime::Buffer< T, D >::add_dimension_with_stride(), and Halide::Runtime::Buffer< T, D >::embed().
|
inline |
Add a new dimension with a min of zero, an extent of one, and the specified stride.
The new dimension is the last dimension. This is a special case of embed.
Definition at line 1525 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::add_dimension(), and buf.
|
inline |
Methods for managing any GPU allocation.
Definition at line 1535 of file HalideBuffer.h.
References buf, and Halide::Runtime::Buffer< T, D >::device_dirty().
Referenced by Halide::Runtime::Buffer< T, D >::copy_from(), Halide::Runtime::Buffer< T, D >::fill(), and Halide::Runtime::Buffer< T, D >::operator()().
|
inline |
Definition at line 1544 of file HalideBuffer.h.
References buf.
Referenced by Halide::Runtime::Buffer< T, D >::copy_from(), Halide::Runtime::Buffer< T, D >::copy_to_host(), Halide::Runtime::Buffer< T, D >::operator()(), and Halide::Runtime::Buffer< T, D >::set_host_dirty().
|
inline |
Definition at line 1548 of file HalideBuffer.h.
References buf.
Referenced by Halide::Runtime::Buffer< T, D >::copy_to_device(), and Halide::Runtime::Buffer< T, D >::set_device_dirty().
|
inline |
Definition at line 1552 of file HalideBuffer.h.
References buf, and Halide::Runtime::Buffer< T, D >::host_dirty().
|
inline |
Definition at line 1557 of file HalideBuffer.h.
References buf, and Halide::Runtime::Buffer< T, D >::device_dirty().
|
inline |
Definition at line 1564 of file HalideBuffer.h.
References buf, halide_device_interface_t::copy_to_device, and Halide::Runtime::Buffer< T, D >::host_dirty().
|
inline |
Definition at line 1571 of file HalideBuffer.h.
References buf, and halide_device_interface_t::device_malloc.
|
inline |
Definition at line 1575 of file HalideBuffer.h.
References Halide::Runtime::Allocated, buf, Halide::Runtime::DeviceRefCount::count, and Halide::Runtime::DeviceRefCount::ownership.
|
inline |
Definition at line 1598 of file HalideBuffer.h.
References buf, Halide::Runtime::DeviceRefCount::ownership, halide_device_interface_t::wrap_native, and Halide::Runtime::WrappedNative.
|
inline |
Definition at line 1606 of file HalideBuffer.h.
References buf, Halide::Runtime::DeviceRefCount::count, Halide::Runtime::DeviceRefCount::ownership, and Halide::Runtime::WrappedNative.
|
inline |
Definition at line 1628 of file HalideBuffer.h.
References buf, and halide_device_interface_t::device_and_host_malloc.
|
inline |
Definition at line 1632 of file HalideBuffer.h.
References Halide::Runtime::AllocatedDeviceAndHost, buf, Halide::Runtime::DeviceRefCount::count, and Halide::Runtime::DeviceRefCount::ownership.
|
inline |
Definition at line 1655 of file HalideBuffer.h.
References buf.
|
inline |
Definition at line 1659 of file HalideBuffer.h.
References buf.
|
inline |
Return the method by which the device field is managed.
Definition at line 1664 of file HalideBuffer.h.
References Halide::Runtime::Allocated, and Halide::Runtime::DeviceRefCount::ownership.
|
inlinestatic |
If you use the (x, y, c) indexing convention, then Halide Buffers are stored planar by default.
This function constructs an interleaved RGB or RGBA image that can still be indexed using (x, y, c). Passing it to a generator requires that the generator has been compiled with support for interleaved (also known as packed or chunky) memory layouts.
Definition at line 1678 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::channels(), Halide::Runtime::Buffer< T, D >::height(), Halide::Runtime::Buffer< T, D >::transpose(), and Halide::Runtime::Buffer< T, D >::width().
Referenced by Halide::Runtime::Buffer< T, D >::copy_to_interleaved(), and Halide::Runtime::Buffer< T, D >::make_interleaved().
|
inlinestatic |
If you use the (x, y, c) indexing convention, then Halide Buffers are stored planar by default.
This function constructs an interleaved RGB or RGBA image that can still be indexed using (x, y, c). Passing it to a generator requires that the generator has been compiled with support for interleaved (also known as packed or chunky) memory layouts.
Definition at line 1693 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::channels(), Halide::Runtime::Buffer< T, D >::height(), Halide::Runtime::Buffer< T, D >::make_interleaved(), Halide::Runtime::Buffer< T, D >::static_halide_type(), and Halide::Runtime::Buffer< T, D >::width().
|
inlinestatic |
Wrap an existing interleaved image.
Definition at line 1699 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::channels(), Halide::Runtime::Buffer< T, D >::data(), Halide::Runtime::Buffer< T, D >::height(), Halide::Runtime::Buffer< T, D >::transpose(), and Halide::Runtime::Buffer< T, D >::width().
|
inlinestatic |
Wrap an existing interleaved image.
Definition at line 1707 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::channels(), Halide::Runtime::Buffer< T, D >::data(), Halide::Runtime::Buffer< T, D >::height(), Halide::Runtime::Buffer< T, D >::make_interleaved(), Halide::Runtime::Buffer< T, D >::static_halide_type(), and Halide::Runtime::Buffer< T, D >::width().
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Make a zero-dimensional Buffer that points to non-owned, existing data.
Definition at line 1726 of file HalideBuffer.h.
References buf, and Halide::Runtime::Buffer< T, D >::data().
|
inlinestatic |
Make a buffer with the same shape and memory nesting order as another buffer.
It may have a different type.
Definition at line 1735 of file HalideBuffer.h.
References halide_buffer_t::dim, Halide::Runtime::Buffer< T, D >::dimensions(), and Halide::Runtime::Buffer< T, D >::type().
Referenced by Halide::Runtime::Buffer< T, D >::copy().
|
inline |
Get a pointer to the address of the min coordinate.
Definition at line 1829 of file HalideBuffer.h.
References halide_buffer_t::host.
Referenced by Halide::Runtime::Buffer< T, D >::Buffer(), Halide::Runtime::Buffer< T, D >::make_interleaved(), Halide::Runtime::Buffer< T, D >::make_scalar(), Halide::Runtime::Buffer< T, D >::msan_check_mem_is_initialized(), and Halide::Runtime::Buffer< T, D >::operator()().
|
inline |
Access elements.
Use im(...) to get a reference to an element, and use &im(...) to get the address of an element. If you pass fewer arguments than the buffer has dimensions, the rest are treated as their min coordinate. The non-const versions set the host_dirty flag to true.
Definition at line 1842 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::device_dirty().
|
inline |
Definition at line 1851 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::data(), and Halide::Runtime::Buffer< T, D >::device_dirty().
|
inline |
Definition at line 1860 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::device_dirty().
|
inline |
Definition at line 1871 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::set_host_dirty().
|
inline |
Definition at line 1880 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::data(), and Halide::Runtime::Buffer< T, D >::set_host_dirty().
|
inline |
Definition at line 1889 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::set_host_dirty().
|
inline |
Tests that all values in this buffer are equal to val.
Definition at line 1898 of file HalideBuffer.h.
|
inline |
Definition at line 1904 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::for_each_value(), and Halide::Runtime::Buffer< T, D >::set_host_dirty().
|
inline |
Call a function on every value in the buffer, and the corresponding values in some number of other buffers of the same size.
The function should take a reference, const reference, or value of the correct type for each buffer. This effectively lifts a function of scalars to an element-wise function of buffers. This produces code that the compiler can autovectorize. This is slightly cheaper than for_each_element, because it does not need to track the coordinates.
Note that constness of Buffers is preserved: a const Buffer<T> (for either 'this' or the other-buffers arguments) will allow mutation of the buffer contents, while a Buffer<const T> will not. Attempting to specify a mutable reference for the lambda argument of a Buffer<const T> will result in a compilation error.
Definition at line 2058 of file HalideBuffer.h.
Referenced by Halide::Runtime::Buffer< T, D >::copy_from(), Halide::Runtime::Buffer< T, D >::fill(), and Halide::Runtime::Buffer< T, D >::msan_check_mem_is_initialized().
|
inline |
Definition at line 2066 of file HalideBuffer.h.
|
inline |
Call a function at each site in a buffer.
This is likely to be much slower than using Halide code to populate a buffer, but is convenient for tests. If the function has more arguments than the buffer has dimensions, the remaining arguments will be zero. If it has fewer arguments than the buffer has dimensions then the last few dimensions of the buffer are not iterated over. For example, the following code exploits this to set a floating point RGB image to red:
The compiled code is equivalent to writing the a nested for loop, and compilers are capable of optimizing it in the same way.
If the callable can be called with an int * as the sole argument, that version is called instead. Each location in the buffer is passed to it in a coordinate array. This version is higher-overhead than the variadic version, but is useful for writing generic code that accepts buffers of arbitrary dimensionality. For example, the following sets the value at all sites in an arbitrary-dimensional buffer to their first coordinate:
It is also possible to use for_each_element to iterate over entire rows or columns by cropping the buffer to a single column or row respectively and iterating over elements of the result. For example, to set the diagonal of the image to 1 by iterating over the columns:
Or, assuming the memory layout is known to be dense per row, one can memset each row of an image like so:
Definition at line 2257 of file HalideBuffer.h.
|
inline |
Definition at line 2265 of file HalideBuffer.h.
|
inline |
Fill a buffer by evaluating a callable at every site.
The callable should look much like a callable passed to for_each_element, but it should return the value that should be stored to the coordinate corresponding to the arguments.
Definition at line 2295 of file HalideBuffer.h.
|
inline |
Check if an input buffer passed extern stage is a querying bounds.
Compared to doing the host pointer check directly, this both adds clarity to code and will facilitate moving to another representation for bounds query arguments.
Definition at line 2305 of file HalideBuffer.h.
References buf.
|
inline |
Convenient check to verify that all of the interesting bytes in the Buffer are initialized under MSAN.
Note that by default, we use for_each_value() here so that we skip any unused padding that isn't part of the Buffer; this isn't efficient, but in MSAN mode, it doesn't matter. (Pass true for the flag to force check the entire Buffer storage.)
Definition at line 2314 of file HalideBuffer.h.
References Halide::Runtime::Buffer< T, D >::data(), Halide::Runtime::Buffer< T, D >::for_each_value(), and Halide::Runtime::Buffer< T, D >::size_in_bytes().
|
staticconstexpr |
True if the Halide type is not void (or const void).
Definition at line 170 of file HalideBuffer.h.