Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
Halide::Runtime::Buffer< T, Dims, InClassDimStorage > Class Template Reference

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?
 
HALIDE_ALWAYS_INLINE Dimension dim (int i) const
 Access the shape of the buffer.
 
int min (int i) const
 Access to the mins, strides, extents.
 
int extent (int i) const
 
int stride (int i) const
 
size_t number_of_elements () const
 The total number of elements this buffer represents.
 
int dimensions () const
 Get the dimensionality of the buffer.
 
halide_type_t type () const
 Get the type of the elements.
 
T * begin () const
 A pointer to the element with the lowest address.
 
T * end () const
 A pointer to one beyond the element with the highest address.
 
size_t size_in_bytes () const
 The total number of bytes spanned by the data in memory.
 
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.
 
 Buffer ()
 
 Buffer (const halide_buffer_t &buf, BufferDeviceOwnership ownership=BufferDeviceOwnership::Unmanaged)
 Make a Buffer from a halide_buffer_t.
 
 Buffer (const Buffer< T, Dims, InClassDimStorage > &other)
 Copy constructor.
 
template<typename T2 , int D2, int S2>
 Buffer (const Buffer< T2, D2, S2 > &other)
 Construct a Buffer from a Buffer of different dimensionality and type.
 
 Buffer (Buffer< T, Dims, InClassDimStorage > &&other) noexcept
 Move constructor.
 
template<typename T2 , int D2, int S2>
 Buffer (Buffer< T2, D2, S2 > &&other)
 Move-construct a Buffer from a Buffer of different dimensionality and type.
 
template<typename T2 , int D2, int S2>
Buffer< T, Dims, InClassDimStorage > & operator= (const Buffer< T2, D2, S2 > &other)
 Assign from another Buffer of possibly-different dimensionality and type.
 
Buffer< T, Dims, InClassDimStorage > & operator= (const Buffer< T, Dims, InClassDimStorage > &other)
 Standard assignment operator.
 
template<typename T2 , int D2, int S2>
Buffer< T, Dims, InClassDimStorage > & operator= (Buffer< T2, D2, S2 > &&other)
 Move from another Buffer of possibly-different dimensionality and type.
 
Buffer< T, Dims, InClassDimStorage > & operator= (Buffer< T, Dims, InClassDimStorage > &&other) noexcept
 Standard move-assignment operator.
 
void check_overflow ()
 Check the product of the extents fits in memory.
 
void allocate (void *(*allocate_fn)(size_t)=nullptr, void(*deallocate_fn)(void *)=nullptr)
 Allocate memory for this Buffer.
 
void deallocate ()
 Drop reference to any owned host or device memory, possibly freeing it, if this buffer held the last reference to it.
 
void device_deallocate ()
 Drop reference to any owned device memory, possibly freeing it if this buffer held the last reference to it.
 
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.
 
 Buffer (int first)
 Allocate a new image of the given size.
 
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.
 
 Buffer (const std::vector< int > &sizes)
 Allocate a new image of known type using a vector of ints as the size.
 
 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.
 
 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.
 
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.
 
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.
 
 Buffer (T *data, const std::vector< int > &sizes)
 Initialize an Buffer from a pointer and a vector of sizes.
 
 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.
 
 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.
 
 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.
 
 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.
 
 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.
 
 ~Buffer ()
 Destructor.
 
halide_buffer_traw_buffer ()
 Get a pointer to the raw halide_buffer_t this wraps.
 
const halide_buffer_traw_buffer () const
 
 operator halide_buffer_t * ()
 Provide a cast operator to halide_buffer_t *, so that instances can be passed directly to Halide filters.
 
template<typename T2 , int D2 = Dims>
HALIDE_ALWAYS_INLINE Buffer< T2, D2, InClassDimStorage > & as () &
 Return a typed reference to this Buffer.
 
template<typename T2 , int D2 = Dims>
HALIDE_ALWAYS_INLINE const Buffer< T2, D2, InClassDimStorage > & as () const &
 Return a const typed reference to this Buffer.
 
template<typename T2 , int D2 = Dims>
HALIDE_ALWAYS_INLINE Buffer< T2, D2, InClassDimStorage > as () &&
 Return an rval reference to this Buffer.
 
HALIDE_ALWAYS_INLINE Buffer< typename std::add_const< T >::type, Dims, InClassDimStorage > & as_const () &
 as_const() is syntactic sugar for .as<const T>(), to avoid the need to recapitulate the type argument.
 
HALIDE_ALWAYS_INLINE const Buffer< typename std::add_const< T >::type, Dims, InClassDimStorage > & as_const () const &
 
HALIDE_ALWAYS_INLINE Buffer< typename std::add_const< T >::type, Dims, InClassDimStorage > as_const () &&
 
template<typename T2 = T, typename = typename std::enable_if<!std::is_const<T2>::value>::type>
 operator Buffer< typename std::add_const< T2 >::type, Dims, InClassDimStorage > & () &
 Add some syntactic sugar to allow autoconversion from Buffer<T> to Buffer<const T>& when passing arguments.
 
template<typename TVoid , typename T2 = T, typename = typename std::enable_if<std::is_same<TVoid, void>::value && !std::is_void<T2>::value && !std::is_const<T2>::value>::type>
 operator Buffer< TVoid, Dims, InClassDimStorage > & () &
 Add some syntactic sugar to allow autoconversion from Buffer<T> to Buffer<void>& when passing arguments.
 
template<typename TVoid , typename T2 = T, typename = typename std::enable_if<std::is_same<TVoid, void>::value && !std::is_void<T2>::value && std::is_const<T2>::value>::type>
 operator Buffer< const TVoid, Dims, InClassDimStorage > & () &
 Add some syntactic sugar to allow autoconversion from Buffer<const T> to Buffer<const void>& when passing arguments.
 
int width () const
 Conventional names for the first three dimensions.
 
int height () const
 
int channels () const
 
int left () const
 Conventional names for the min and max value of each dimension.
 
int right () const
 
int top () const
 
int bottom () const
 
Buffer< not_const_T, Dims, InClassDimStorage > 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.
 
Buffer< not_const_T, Dims, InClassDimStorage > 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.
 
Buffer< not_const_T, Dims, InClassDimStorage > 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.
 
Buffer< T, Dims, InClassDimStorage > alias () const
 Make a copy of the Buffer which shares the underlying host and/or device allocations as the existing Buffer.
 
template<typename T2 , int D2, int S2>
void copy_from (Buffer< T2, D2, S2 > src)
 Fill a Buffer with the values at the same coordinates in another Buffer.
 
Buffer< T, Dims, InClassDimStorage > cropped (int d, int min, int extent) const
 Make an image that refers to a sub-range of this image along the given dimension.
 
void crop (int d, int min, int extent)
 Crop an image in-place along the given dimension.
 
Buffer< T, Dims, InClassDimStorage > 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.
 
void crop (const std::vector< std::pair< int, int > > &rect)
 Crop an image in-place along the first N dimensions.
 
Buffer< T, Dims, InClassDimStorage > translated (int d, int dx) const
 Make an image which refers to the same data with using translated coordinates in the given dimension.
 
void translate (int d, int delta)
 Translate an image in-place along one dimension by changing how it is indexed.
 
Buffer< T, Dims, InClassDimStorage > translated (const std::vector< int > &delta) const
 Make an image which refers to the same data translated along the first N dimensions.
 
void translate (const std::vector< int > &delta)
 Translate an image along the first N dimensions by changing how it is indexed.
 
void set_min (const std::vector< int > &mins)
 Set the min coordinate of an image in the first N dimensions.
 
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.
 
template<typename... Args>
bool contains (Args... args) const
 
Buffer< T, Dims, InClassDimStorage > 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.
 
void transpose (int d1, int d2)
 Transpose a buffer in-place by changing how it is indexed.
 
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.
 
Buffer< T, Dims, InClassDimStorage > 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.
 
Buffer< T,(Dims==AnyDims ? AnyDims :Dims - 1)> sliced (int d, int pos) const
 Make a lower-dimensional buffer that refers to one slice of this buffer.
 
Buffer< T,(Dims==AnyDims ? AnyDims :Dims - 1)> sliced (int d) const
 Make a lower-dimensional buffer that refers to one slice of this buffer at the dimension's minimum.
 
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.
 
void slice (int d)
 Slice a buffer in-place at the dimension's minimum.
 
Buffer< T,(Dims==AnyDims ? AnyDims :Dims+1)> embedded (int d, int pos=0) const
 Make a new buffer that views this buffer as a single slice in a higher-dimensional space.
 
void embed (int d, int pos=0)
 Embed a buffer in-place, increasing the dimensionality.
 
void add_dimension ()
 Add a new dimension with a min of zero and an extent of one.
 
void add_dimension_with_stride (int s)
 Add a new dimension with a min of zero, an extent of one, and the specified stride.
 
HALIDE_ALWAYS_INLINE void set_host_dirty (bool v=true)
 Methods for managing any GPU allocation.
 
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.
 
T * data () const
 Get a pointer to the address of the min coordinate.
 
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.
 
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.
 
Buffer< T, Dims, InClassDimStorage > & fill (not_void_T val)
 
template<typename Fn , typename... Args, int N = sizeof...(Args) + 1>
HALIDE_ALWAYS_INLINE const Buffer< T, Dims, InClassDimStorage > & 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.
 
template<typename Fn , typename... Args, int N = sizeof...(Args) + 1>
HALIDE_ALWAYS_INLINE Buffer< T, Dims, InClassDimStorage > & for_each_value (Fn &&f, Args &&...other_buffers)
 
template<typename Fn >
HALIDE_ALWAYS_INLINE const Buffer< T, Dims, InClassDimStorage > & for_each_element (Fn &&f) const
 Call a function at each site in a buffer.
 
template<typename Fn >
HALIDE_ALWAYS_INLINE Buffer< T, Dims, InClassDimStorage > & 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, Dims, InClassDimStorage > & fill (Fn &&f)
 Fill a buffer by evaluating a callable at every site.
 
bool is_bounds_query () const
 Check if an input buffer passed extern stage is a querying bounds.
 
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.
 

Static Public Member Functions

static constexpr halide_type_t static_halide_type ()
 Get the Halide type of T.
 
static constexpr int static_dimensions ()
 Callers should not use the result if has_static_dimensions is false.
 
static void set_default_allocate_fn (void *(*allocate_fn)(size_t))
 
static void set_default_deallocate_fn (void(*deallocate_fn)(void *))
 
template<typename T2 , int D2, int S2>
static bool can_convert_from (const Buffer< T2, D2, S2 > &other)
 Determine if a Buffer<T, Dims, InClassDimStorage> can be constructed from some other Buffer type.
 
template<typename T2 , int D2, int S2>
static void assert_can_convert_from (const Buffer< T2, D2, S2 > &other)
 Fail an assertion at runtime or compile-time if an Buffer<T, Dims, InClassDimStorage> cannot be constructed from some other Buffer type.
 
static Buffer< void, Dims, InClassDimStorage > 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.
 
static Buffer< T, Dims, InClassDimStorage > 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.
 
static Buffer< add_const_if_T_is_const< void >, Dims, InClassDimStorage > make_interleaved (halide_type_t t, T *data, int width, int height, int channels)
 Wrap an existing interleaved image.
 
static Buffer< T, Dims, InClassDimStorage > make_interleaved (T *data, int width, int height, int channels)
 Wrap an existing interleaved image.
 
static Buffer< add_const_if_T_is_const< void >, Dims, InClassDimStorage > make_scalar (halide_type_t t)
 Make a zero-dimensional Buffer.
 
static Buffer< T, Dims, InClassDimStorage > make_scalar ()
 Make a zero-dimensional Buffer.
 
static Buffer< T, Dims, InClassDimStorage > make_scalar (T *data)
 Make a zero-dimensional Buffer that points to non-owned, existing data.
 
template<typename T2 , int D2, int S2>
static Buffer< T, Dims, InClassDimStorage > make_with_shape_of (Buffer< T2, D2, S2 > 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.
 

Static Public Attributes

static constexpr bool has_static_halide_type = !T_is_void
 True if the Halide type is not void (or const void).
 
static constexpr bool has_static_dimensions = (Dims != AnyDims)
 

Detailed Description

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
class Halide::Runtime::Buffer< T, Dims, InClassDimStorage >

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.

The template parameter Dims is the number of dimensions. For buffers where the dimensionality type is unknown at, or may vary, use AnyDims.

InClassDimStorage 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. InClassDimStorage 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.

Examples
tutorial/lesson_10_aot_compilation_run.cpp.

Definition at line 221 of file HalideBuffer.h.

Member Typedef Documentation

◆ ElemType

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
T Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::ElemType

Definition at line 570 of file HalideBuffer.h.

Constructor & Destructor Documentation

◆ Buffer() [1/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( )
inline

◆ Buffer() [2/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( const halide_buffer_t & buf,
BufferDeviceOwnership ownership = BufferDeviceOwnership::Unmanaged )
inlineexplicit

◆ Buffer() [3/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( const Buffer< T, Dims, InClassDimStorage > & other)
inline

Copy constructor.

Does not copy underlying data.

Definition at line 765 of file HalideBuffer.h.

◆ Buffer() [4/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename T2 , int D2, int S2>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( const Buffer< T2, D2, S2 > & other)
inline

Construct a Buffer from a Buffer of different dimensionality and type.

Asserts that the type and dimensionality 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 780 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::assert_can_convert_from().

◆ Buffer() [5/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( Buffer< T, Dims, InClassDimStorage > && other)
inlinenoexcept

Move constructor.

Definition at line 790 of file HalideBuffer.h.

◆ Buffer() [6/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename T2 , int D2, int S2>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( Buffer< T2, D2, S2 > && other)
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 803 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::assert_can_convert_from().

◆ Buffer() [7/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename... Args, typename = typename std::enable_if<AllInts<Args...>::value>::type>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( halide_type_t t,
int first,
Args... rest )
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 975 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::allocate(), Halide::Runtime::Internal::any_zero(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::check_overflow(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::static_halide_type(), and halide_buffer_t::type.

◆ Buffer() [8/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( int first)
inlineexplicit

◆ Buffer() [9/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename... Args, typename = typename std::enable_if<AllInts<Args...>::value>::type>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( int first,
int second,
Args... rest )
inline

◆ Buffer() [10/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( halide_type_t t,
const std::vector< int > & sizes )
inline

◆ Buffer() [11/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( const std::vector< int > & sizes)
inlineexplicit

Allocate a new image of known type using a vector of ints as the size.

Definition at line 1043 of file HalideBuffer.h.

◆ Buffer() [12/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( halide_type_t t,
const std::vector< int > & sizes,
const std::vector< int > & storage_order )
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 1063 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transpose().

◆ Buffer() [13/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( const std::vector< int > & sizes,
const std::vector< int > & storage_order )
inline

Definition at line 1068 of file HalideBuffer.h.

◆ Buffer() [14/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename Array , size_t N>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( Array(&) vals[N])
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 1075 of file HalideBuffer.h.

References halide_buffer_t::dimensions, halide_buffer_t::host, and halide_buffer_t::type.

◆ Buffer() [15/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename... Args, typename = typename std::enable_if<AllInts<Args...>::value>::type>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( halide_type_t t,
add_const_if_T_is_const< void > * data,
int first,
Args &&... rest )
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 1089 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::data(), halide_buffer_t::host, Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::static_halide_type(), and halide_buffer_t::type.

◆ Buffer() [16/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename... Args, typename = typename std::enable_if<AllInts<Args...>::value>::type>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( T * data,
int first,
Args &&... rest )
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 1106 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::data(), halide_buffer_t::host, Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::static_halide_type(), and halide_buffer_t::type.

◆ Buffer() [17/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( T * data,
const std::vector< int > & sizes )
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 1119 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::data(), halide_buffer_t::host, Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::static_halide_type(), and halide_buffer_t::type.

◆ Buffer() [18/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( halide_type_t t,
add_const_if_T_is_const< void > * data,
const std::vector< int > & sizes )
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 1130 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::data(), halide_buffer_t::host, Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::static_halide_type(), and halide_buffer_t::type.

◆ Buffer() [19/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( halide_type_t t,
add_const_if_T_is_const< void > * data,
int d,
const halide_dimension_t * shape )
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 1143 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::data(), halide_buffer_t::dim, halide_buffer_t::host, Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::static_halide_type(), and halide_buffer_t::type.

◆ Buffer() [20/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( halide_type_t t,
add_const_if_T_is_const< void > * data,
const std::vector< halide_dimension_t > & shape )
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 1158 of file HalideBuffer.h.

◆ Buffer() [21/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( T * data,
int d,
const halide_dimension_t * shape )
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 1166 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::data(), halide_buffer_t::dim, halide_buffer_t::host, Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::static_halide_type(), and halide_buffer_t::type.

◆ Buffer() [22/22]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer ( T * data,
const std::vector< halide_dimension_t > & shape )
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 1178 of file HalideBuffer.h.

◆ ~Buffer()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::~Buffer ( )
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 1185 of file HalideBuffer.h.

Member Function Documentation

◆ static_halide_type()

◆ owns_host_memory()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
bool Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::owns_host_memory ( ) const
inline

Does this Buffer own the host memory it refers to?

Definition at line 269 of file HalideBuffer.h.

◆ static_dimensions()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
static constexpr int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::static_dimensions ( )
inlinestaticconstexpr

Callers should not use the result if has_static_dimensions is false.

Definition at line 277 of file HalideBuffer.h.

Referenced by Halide::Buffer< T, Dims >::static_dimensions().

◆ dim()

◆ min()

◆ extent()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::extent ( int i) const
inline

◆ stride()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::stride ( int i) const
inline

◆ number_of_elements()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
size_t Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::number_of_elements ( ) const
inline

The total number of elements this buffer represents.

Equal to the product of the extents

Definition at line 650 of file HalideBuffer.h.

◆ dimensions()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::dimensions ( ) const
inline

Get the dimensionality of the buffer.

Definition at line 655 of file HalideBuffer.h.

References halide_buffer_t::dimensions, and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::has_static_dimensions.

Referenced by Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::can_convert_from(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::channels(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::check_overflow(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::contains(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_from(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_to_interleaved(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_to_planar(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::dim(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::embed(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::height(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_with_shape_of(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::set_min(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::slice(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::sliced(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::sliced(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::translate(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::translate(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transpose(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transpose(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::width().

◆ type()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
halide_type_t Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::type ( ) const
inline

◆ begin()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
T * Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::begin ( ) const
inline

A pointer to the element with the lowest address.

If all strides are positive, equal to the host pointer.

Definition at line 670 of file HalideBuffer.h.

References halide_buffer_t::host.

◆ end()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
T * Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::end ( ) const
inline

A pointer to one beyond the element with the highest address.

Definition at line 676 of file HalideBuffer.h.

References halide_buffer_t::host.

◆ size_in_bytes()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
size_t Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::size_in_bytes ( ) const
inline

◆ reset()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::reset ( )
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 689 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer.

◆ set_default_allocate_fn()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
static void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::set_default_allocate_fn ( void *(* allocate_fn )(size_t))
inlinestatic

◆ set_default_deallocate_fn()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
static void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::set_default_deallocate_fn ( void(* deallocate_fn )(void *))
inlinestatic

◆ can_convert_from()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename T2 , int D2, int S2>
static bool Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::can_convert_from ( const Buffer< T2, D2, S2 > & other)
inlinestatic

◆ assert_can_convert_from()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename T2 , int D2, int S2>
static void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::assert_can_convert_from ( const Buffer< T2, D2, S2 > & other)
inlinestatic

◆ operator=() [1/4]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename T2 , int D2, int S2>
Buffer< T, Dims, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator= ( const Buffer< T2, D2, S2 > & other)
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 817 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::assert_can_convert_from().

◆ operator=() [2/4]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< T, Dims, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator= ( const Buffer< T, Dims, InClassDimStorage > & other)
inline

Standard assignment operator.

Definition at line 833 of file HalideBuffer.h.

◆ operator=() [3/4]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename T2 , int D2, int S2>
Buffer< T, Dims, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator= ( Buffer< T2, D2, S2 > && other)
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 852 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::assert_can_convert_from().

◆ operator=() [4/4]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< T, Dims, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator= ( Buffer< T, Dims, InClassDimStorage > && other)
inlinenoexcept

Standard move-assignment operator.

Definition at line 866 of file HalideBuffer.h.

◆ check_overflow()

◆ allocate()

◆ deallocate()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::deallocate ( )
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 958 of file HalideBuffer.h.

Referenced by Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::allocate().

◆ device_deallocate()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::device_deallocate ( )
inline

◆ raw_buffer() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
halide_buffer_t * Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::raw_buffer ( )
inline

Get a pointer to the raw halide_buffer_t this wraps.

Definition at line 1192 of file HalideBuffer.h.

◆ raw_buffer() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
const halide_buffer_t * Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::raw_buffer ( ) const
inline

Definition at line 1196 of file HalideBuffer.h.

◆ operator halide_buffer_t *()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator halide_buffer_t * ( )
inline

Provide a cast operator to halide_buffer_t *, so that instances can be passed directly to Halide filters.

Definition at line 1203 of file HalideBuffer.h.

◆ as() [1/3]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename T2 , int D2 = Dims>
HALIDE_ALWAYS_INLINE Buffer< T2, D2, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::as ( ) &
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>&. You can also optionally sspecify a new value for Dims; this is useful mainly for removing the dimensionality constraint on a Buffer with explicit dimensionality. Does a runtime assert if the source buffer type is void or the new dimensionality is incompatible.

Definition at line 1215 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::assert_can_convert_from().

Referenced by Halide::Runtime::Buffer< float >::operator Buffer< const TVoid, AnyDims,(AnyDims==AnyDims ? 4 :std::max(AnyDims, 1)) > &(), and Halide::Runtime::Buffer< float >::operator Buffer< TVoid, AnyDims,(AnyDims==AnyDims ? 4 :std::max(AnyDims, 1)) > &().

◆ as() [2/3]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename T2 , int D2 = Dims>
HALIDE_ALWAYS_INLINE const Buffer< T2, D2, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::as ( ) const &
inline

Return a const 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>&. You can also optionally sspecify a new value for Dims; this is useful mainly for removing the dimensionality constraint on a Buffer with explicit dimensionality. Does a runtime assert if the source buffer type is void or the new dimensionality is incompatible.

Definition at line 1228 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::assert_can_convert_from().

◆ as() [3/3]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename T2 , int D2 = Dims>
HALIDE_ALWAYS_INLINE Buffer< T2, D2, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::as ( ) &&
inline

Return an rval 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>&. You can also optionally sspecify a new value for Dims; this is useful mainly for removing the dimensionality constraint on a Buffer with explicit dimensionality. Does a runtime assert if the source buffer type is void or the new dimensionality is incompatible.

Definition at line 1241 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::assert_can_convert_from().

◆ as_const() [1/3]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
HALIDE_ALWAYS_INLINE Buffer< typename std::add_const< T >::type, Dims, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::as_const ( ) &
inline

as_const() is syntactic sugar for .as<const T>(), to avoid the need to recapitulate the type argument.

Definition at line 1250 of file HalideBuffer.h.

Referenced by Halide::Runtime::Buffer< float >::operator Buffer< typename std::add_const< T2 >::type, AnyDims,(AnyDims==AnyDims ? 4 :std::max(AnyDims, 1)) > &().

◆ as_const() [2/3]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
HALIDE_ALWAYS_INLINE const Buffer< typename std::add_const< T >::type, Dims, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::as_const ( ) const &
inline

Definition at line 1257 of file HalideBuffer.h.

◆ as_const() [3/3]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
HALIDE_ALWAYS_INLINE Buffer< typename std::add_const< T >::type, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::as_const ( ) &&
inline

Definition at line 1262 of file HalideBuffer.h.

◆ operator Buffer< typename std::add_const< T2 >::type, Dims, InClassDimStorage > &()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename T2 = T, typename = typename std::enable_if<!std::is_const<T2>::value>::type>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator Buffer< typename std::add_const< T2 >::type, Dims, InClassDimStorage > & ( ) &
inline

Add some syntactic sugar to allow autoconversion from Buffer<T> to Buffer<const T>& when passing arguments.

Definition at line 1270 of file HalideBuffer.h.

◆ operator Buffer< TVoid, Dims, InClassDimStorage > &()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename TVoid , typename T2 = T, typename = typename std::enable_if<std::is_same<TVoid, void>::value && !std::is_void<T2>::value && !std::is_const<T2>::value>::type>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator Buffer< TVoid, Dims, InClassDimStorage > & ( ) &
inline

Add some syntactic sugar to allow autoconversion from Buffer<T> to Buffer<void>& when passing arguments.

Definition at line 1281 of file HalideBuffer.h.

◆ operator Buffer< const TVoid, Dims, InClassDimStorage > &()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename TVoid , typename T2 = T, typename = typename std::enable_if<std::is_same<TVoid, void>::value && !std::is_void<T2>::value && std::is_const<T2>::value>::type>
Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator Buffer< const TVoid, Dims, InClassDimStorage > & ( ) &
inline

Add some syntactic sugar to allow autoconversion from Buffer<const T> to Buffer<const void>& when passing arguments.

Definition at line 1292 of file HalideBuffer.h.

◆ width()

◆ height()

◆ channels()

◆ left()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::left ( ) const
inline

Conventional names for the min and max value of each dimension.

Definition at line 1311 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::dim(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Dimension::min().

◆ right()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::right ( ) const
inline

◆ top()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::top ( ) const
inline

◆ bottom()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::bottom ( ) const
inline

◆ copy()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< not_const_T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy ( void *(* allocate_fn )(size_t) = nullptr,
void(* deallocate_fn )(void *) = nullptr ) const
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 1340 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_from(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_with_shape_of().

◆ copy_to_interleaved()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< not_const_T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_to_interleaved ( void *(* allocate_fn )(size_t) = nullptr,
void(* deallocate_fn )(void *) = nullptr ) const
inline

◆ copy_to_planar()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< not_const_T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_to_planar ( void *(* allocate_fn )(size_t) = nullptr,
void(* deallocate_fn )(void *) = nullptr ) const
inline

◆ alias()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::alias ( ) const
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.

void call_my_func(const Buffer<const uint8_t>& input) {
my_func(input.alias(), output);
}
A templated Buffer class that wraps halide_buffer_t and adds functionality.
Buffer< T, Dims, InClassDimStorage > alias() const
Make a copy of the Buffer which shares the underlying host and/or device allocations as the existing ...

Definition at line 1391 of file HalideBuffer.h.

◆ copy_from()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename T2 , int D2, int S2>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_from ( Buffer< T2, D2, S2 > src)
inline

◆ cropped() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::cropped ( int d,
int min,
int extent ) const
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 1462 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::device_deallocate(), halide_buffer_t::device_interface, and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::extent().

Referenced by Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::crop(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::crop().

◆ crop() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::crop ( int d,
int min,
int extent )
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 1482 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::cropped(), halide_buffer_t::device_interface, and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::extent().

Referenced by Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_from().

◆ cropped() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::cropped ( const std::vector< std::pair< int, int > > & rect) const
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 1498 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::device_deallocate(), and halide_buffer_t::device_interface.

◆ crop() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::crop ( const std::vector< std::pair< int, int > > & rect)
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 1519 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::cropped(), and halide_buffer_t::device_interface.

◆ translated() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::translated ( int d,
int dx ) const
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 1535 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::translate().

◆ translate() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::translate ( int d,
int delta )
inline

◆ translated() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::translated ( const std::vector< int > & delta) const
inline

Make an image which refers to the same data translated along the first N dimensions.

Definition at line 1551 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::translate().

◆ translate() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::translate ( const std::vector< int > & delta)
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 1559 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::device_deallocate(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::dimensions(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::translate().

◆ set_min() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::set_min ( const std::vector< int > & mins)
inline

◆ set_min() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename... Args>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::set_min ( Args... args)
inline

◆ contains() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
bool Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::contains ( const std::vector< int > & coords) const
inline

◆ contains() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename... Args>
bool Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::contains ( Args... args) const
inline

◆ transposed() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transposed ( int d1,
int d2 ) const
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 1607 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transpose().

◆ transpose() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transpose ( int d1,
int d2 )
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 1620 of file HalideBuffer.h.

References halide_buffer_t::dim, and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::dimensions().

Referenced by Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Buffer(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::embed(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_interleaved(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_interleaved(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transpose(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transposed(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transposed().

◆ transpose() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transpose ( const std::vector< int > & order)
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

  • it just permutes how it is indexed.

Definition at line 1630 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::dimensions(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transpose().

◆ transposed() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transposed ( const std::vector< int > & order) const
inline

Make a buffer which refers to the same data in the same layout using a different ordering of the dimensions.

Definition at line 1648 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transpose().

◆ sliced() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< T,(Dims==AnyDims ? AnyDims :Dims - 1)> Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::sliced ( int d,
int pos ) const
inline

◆ sliced() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< T,(Dims==AnyDims ? AnyDims :Dims - 1)> Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::sliced ( int d) const
inline

◆ slice() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::slice ( int d,
int pos )
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. Can only be called on a Buffer with dynamic dimensionality.

Definition at line 1690 of file HalideBuffer.h.

References Halide::Runtime::AnyDims, halide_buffer_t::device_interface, Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::dimensions(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::sliced().

Referenced by Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_scalar(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_scalar(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_scalar(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::slice().

◆ slice() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::slice ( int d)
inline

◆ embedded()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< T,(Dims==AnyDims ? AnyDims :Dims+1)> Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::embedded ( int d,
int pos = 0 ) const
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:

im2 = im.embedded(1, 17);
&im(x, y, c) == &im2(x, 17, y, c);

Definition at line 1721 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::embed().

◆ embed()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::embed ( int d,
int pos = 0 )
inline

◆ add_dimension()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::add_dimension ( )
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 1743 of file HalideBuffer.h.

References Halide::Runtime::AnyDims, halide_buffer_t::dim, halide_buffer_t::dimensions, halide_dimension_t::extent, and halide_dimension_t::stride.

Referenced by Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::add_dimension_with_stride(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::embed().

◆ add_dimension_with_stride()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::add_dimension_with_stride ( int s)
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 1775 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::add_dimension(), halide_buffer_t::dim, halide_buffer_t::dimensions, and halide_dimension_t::stride.

◆ set_host_dirty()

◆ device_dirty()

◆ host_dirty()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
bool Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::host_dirty ( ) const
inline

◆ set_device_dirty()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::set_device_dirty ( bool v = true)
inline

◆ copy_to_host()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_to_host ( void * ctx = nullptr)
inline

◆ copy_to_device()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_to_device ( const struct halide_device_interface_t * device_interface,
void * ctx = nullptr )
inline

◆ device_malloc()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::device_malloc ( const struct halide_device_interface_t * device_interface,
void * ctx = nullptr )
inline

Definition at line 1821 of file HalideBuffer.h.

References halide_device_interface_t::device_malloc.

◆ device_free()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::device_free ( void * ctx = nullptr)
inline

◆ device_wrap_native()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::device_wrap_native ( const struct halide_device_interface_t * device_interface,
uint64_t handle,
void * ctx = nullptr )
inline

◆ device_detach_native()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::device_detach_native ( void * ctx = nullptr)
inline

◆ device_and_host_malloc()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::device_and_host_malloc ( const struct halide_device_interface_t * device_interface,
void * ctx = nullptr )
inline

◆ device_and_host_free()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::device_and_host_free ( const struct halide_device_interface_t * device_interface,
void * ctx = nullptr )
inline

◆ device_sync()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
int Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::device_sync ( void * ctx = nullptr)
inline

Definition at line 1905 of file HalideBuffer.h.

◆ has_device_allocation()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
bool Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::has_device_allocation ( ) const
inline

Definition at line 1909 of file HalideBuffer.h.

References halide_buffer_t::device.

◆ device_ownership()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
BufferDeviceOwnership Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::device_ownership ( ) const
inline

Return the method by which the device field is managed.

Definition at line 1914 of file HalideBuffer.h.

References Halide::Runtime::Allocated, and Halide::Runtime::DeviceRefCount::ownership.

◆ make_interleaved() [1/4]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
static Buffer< void, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_interleaved ( halide_type_t t,
int width,
int height,
int channels )
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 1928 of file HalideBuffer.h.

References Halide::Runtime::AnyDims, Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::channels(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::height(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::transpose(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::width().

Referenced by Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_to_interleaved(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_interleaved(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_interleaved().

◆ make_interleaved() [2/4]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
static Buffer< T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_interleaved ( int width,
int height,
int channels )
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 1944 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::channels(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::height(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_interleaved(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::static_halide_type(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::width().

◆ make_interleaved() [3/4]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
static Buffer< add_const_if_T_is_const< void >, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_interleaved ( halide_type_t t,
T * data,
int width,
int height,
int channels )
inlinestatic

◆ make_interleaved() [4/4]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
static Buffer< T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_interleaved ( T * data,
int width,
int height,
int channels )
inlinestatic

◆ make_scalar() [1/3]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
static Buffer< add_const_if_T_is_const< void >, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_scalar ( halide_type_t t)
inlinestatic

Make a zero-dimensional Buffer.

Definition at line 1964 of file HalideBuffer.h.

References Halide::Runtime::AnyDims, and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::slice().

◆ make_scalar() [2/3]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
static Buffer< T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_scalar ( )
inlinestatic

◆ make_scalar() [3/3]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
static Buffer< T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_scalar ( T * data)
inlinestatic

Make a zero-dimensional Buffer that points to non-owned, existing data.

Definition at line 1980 of file HalideBuffer.h.

References Halide::Runtime::AnyDims, Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::data(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::slice().

◆ make_with_shape_of()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename T2 , int D2, int S2>
static Buffer< T, Dims, InClassDimStorage > Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::make_with_shape_of ( Buffer< T2, D2, S2 > src,
void *(* allocate_fn )(size_t) = nullptr,
void(* deallocate_fn )(void *) = nullptr )
inlinestatic

Make a buffer with the same shape and memory nesting order as another buffer.

It may have a different type.

Definition at line 1990 of file HalideBuffer.h.

References Halide::Runtime::AnyDims, halide_buffer_t::dim, Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::dimensions(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::type().

Referenced by Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy().

◆ data()

◆ operator()() [1/6]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename... Args, typename = typename std::enable_if<AllInts<Args...>::value>::type>
HALIDE_ALWAYS_INLINE const not_void_T & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator() ( int first,
Args... rest ) const
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 2105 of file HalideBuffer.h.

References Halide::Runtime::AnyDims, and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::device_dirty().

◆ operator()() [2/6]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
HALIDE_ALWAYS_INLINE const not_void_T & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator() ( ) const
inline

◆ operator()() [3/6]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
HALIDE_ALWAYS_INLINE const not_void_T & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator() ( const int * pos) const
inline

◆ operator()() [4/6]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename... Args, typename = typename std::enable_if<AllInts<Args...>::value>::type>
HALIDE_ALWAYS_INLINE not_void_T & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator() ( int first,
Args... rest )
inline

◆ operator()() [5/6]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
HALIDE_ALWAYS_INLINE not_void_T & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator() ( )
inline

◆ operator()() [6/6]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
HALIDE_ALWAYS_INLINE not_void_T & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::operator() ( const int * pos)
inline

◆ all_equal()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
bool Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::all_equal ( not_void_T val) const
inline

Tests that all values in this buffer are equal to val.

Definition at line 2169 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::all_equal().

Referenced by Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::all_equal().

◆ fill() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
Buffer< T, Dims, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::fill ( not_void_T val)
inline

◆ for_each_value() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename Fn , typename... Args, int N = sizeof...(Args) + 1>
HALIDE_ALWAYS_INLINE const Buffer< T, Dims, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::for_each_value ( Fn && f,
Args &&... other_buffers ) const
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 2336 of file HalideBuffer.h.

Referenced by Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_from(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::fill(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::msan_check_mem_is_initialized().

◆ for_each_value() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename Fn , typename... Args, int N = sizeof...(Args) + 1>
HALIDE_ALWAYS_INLINE Buffer< T, Dims, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::for_each_value ( Fn && f,
Args &&... other_buffers )
inline

Definition at line 2344 of file HalideBuffer.h.

◆ for_each_element() [1/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename Fn >
HALIDE_ALWAYS_INLINE const Buffer< T, Dims, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::for_each_element ( Fn && f) const
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:

Buffer<float, 3> im(100, 100, 3);
im.for_each_element([&](int x, int y) {
im(x, y, 0) = 1.0f;
im(x, y, 1) = 0.0f;
im(x, y, 2) = 0.0f:
});

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:

im.for_each_element([&](const int *pos) {im(pos) = pos[0];});

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:

Buffer<float, 3> im(100, 100, 3);
im.sliced(1, 0).for_each_element([&](int x, int c) {
im(x, x, c) = 1.0f;
});

Or, assuming the memory layout is known to be dense per row, one can memset each row of an image like so:

Buffer<float, 3> im(100, 100, 3);
im.sliced(0, 0).for_each_element([&](int y, int c) {
memset(&im(0, y, c), 0, sizeof(float) * im.width());
});
void * memset(void *s, int val, size_t n)

Definition at line 2539 of file HalideBuffer.h.

◆ for_each_element() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename Fn >
HALIDE_ALWAYS_INLINE Buffer< T, Dims, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::for_each_element ( Fn && f)
inline

Definition at line 2547 of file HalideBuffer.h.

◆ fill() [2/2]

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
template<typename Fn , typename = typename std::enable_if<!std::is_arithmetic<typename std::decay<Fn>::type>::value>::type>
Buffer< T, Dims, InClassDimStorage > & Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::fill ( Fn && f)
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 2577 of file HalideBuffer.h.

◆ is_bounds_query()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
bool Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::is_bounds_query ( ) const
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 2587 of file HalideBuffer.h.

◆ msan_check_mem_is_initialized()

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
void Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::msan_check_mem_is_initialized ( bool entire = false) const
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 2596 of file HalideBuffer.h.

References Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::data(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::for_each_value(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::size_in_bytes().

Member Data Documentation

◆ has_static_halide_type

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
bool Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::has_static_halide_type = !T_is_void
staticconstexpr

True if the Halide type is not void (or const void).

Definition at line 260 of file HalideBuffer.h.

◆ has_static_dimensions

template<typename T = void, int Dims = AnyDims, int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
bool Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::has_static_dimensions = (Dims != AnyDims)
staticconstexpr

The documentation for this class was generated from the following file: