This source file includes following definitions.
- _halide_buffer_get_host
- _halide_buffer_get_device
- _halide_buffer_get_device_interface
- _halide_buffer_get_min
- _halide_buffer_get_max
- _halide_buffer_get_extent
- _halide_buffer_get_stride
- _halide_buffer_set_host_dirty
- _halide_buffer_set_device_dirty
- _halide_buffer_get_host_dirty
- _halide_buffer_get_device_dirty
- _halide_buffer_get_shape
- _halide_buffer_is_bounds_query
- _halide_buffer_get_type_code
- _halide_buffer_get_type_bits
- _halide_buffer_get_type_lanes
- _halide_buffer_init
- _halide_buffer_init_from_buffer
- _halide_buffer_crop
#ifdef COMPILING_HALIDE_RUNTIME
#include "HalideRuntime.h"
#define HALIDE_BUFFER_HELPER_ATTRS __attribute__((always_inline, weak))
#else
#define HALIDE_BUFFER_HELPER_ATTRS inline
#endif
extern "C" {
HALIDE_BUFFER_HELPER_ATTRS
uint8_t *_halide_buffer_get_host(const halide_buffer_t *buf) {
return buf->host;
}
HALIDE_BUFFER_HELPER_ATTRS
uint64_t _halide_buffer_get_device(const halide_buffer_t *buf) {
return buf->device;
}
HALIDE_BUFFER_HELPER_ATTRS
const struct halide_device_interface_t *_halide_buffer_get_device_interface(const halide_buffer_t *buf) {
return buf->device_interface;
}
HALIDE_BUFFER_HELPER_ATTRS
int _halide_buffer_get_min(const halide_buffer_t *buf, int d) {
return buf->dim[d].min;
}
HALIDE_BUFFER_HELPER_ATTRS
int _halide_buffer_get_max(const halide_buffer_t *buf, int d) {
return buf->dim[d].min + buf->dim[d].extent - 1;
}
HALIDE_BUFFER_HELPER_ATTRS
int _halide_buffer_get_extent(const halide_buffer_t *buf, int d) {
return buf->dim[d].extent;
}
HALIDE_BUFFER_HELPER_ATTRS
int _halide_buffer_get_stride(const halide_buffer_t *buf, int d) {
return buf->dim[d].stride;
}
HALIDE_BUFFER_HELPER_ATTRS
int _halide_buffer_set_host_dirty(halide_buffer_t *buf, bool val) {
buf->set_host_dirty(val);
return 0;
}
HALIDE_BUFFER_HELPER_ATTRS
int _halide_buffer_set_device_dirty(halide_buffer_t *buf, bool val) {
buf->set_device_dirty(val);
return 0;
}
HALIDE_BUFFER_HELPER_ATTRS
bool _halide_buffer_get_host_dirty(const halide_buffer_t *buf) {
return buf->host_dirty();
}
HALIDE_BUFFER_HELPER_ATTRS
bool _halide_buffer_get_device_dirty(const halide_buffer_t *buf) {
return buf->device_dirty();
}
HALIDE_BUFFER_HELPER_ATTRS
halide_dimension_t *_halide_buffer_get_shape(halide_buffer_t *buf) {
return buf->dim;
}
HALIDE_BUFFER_HELPER_ATTRS
bool _halide_buffer_is_bounds_query(const halide_buffer_t *buf) {
return buf->host == NULL && buf->device == 0;
}
HALIDE_BUFFER_HELPER_ATTRS
uint8_t _halide_buffer_get_type_code(const halide_buffer_t *buf) {
return buf->type.code;
}
HALIDE_BUFFER_HELPER_ATTRS
uint8_t _halide_buffer_get_type_bits(const halide_buffer_t *buf) {
return buf->type.bits;
}
HALIDE_BUFFER_HELPER_ATTRS
uint16_t _halide_buffer_get_type_lanes(const halide_buffer_t *buf) {
return buf->type.lanes;
}
HALIDE_BUFFER_HELPER_ATTRS
halide_buffer_t *_halide_buffer_init(halide_buffer_t *dst,
halide_dimension_t *dst_shape,
void *host,
uint64_t device, halide_device_interface_t *device_interface,
int type_code, int type_bits,
int dimensions,
halide_dimension_t *shape,
uint64_t flags) {
dst->host = (uint8_t *)host;
dst->device = device;
dst->device_interface = device_interface;
dst->type.code = (halide_type_code_t)type_code;
dst->type.bits = (uint8_t)type_bits;
dst->type.lanes = 1;
dst->dimensions = dimensions;
dst->dim = dst_shape;
if (shape != dst->dim) {
for (int i = 0; i < dimensions; i++) {
dst->dim[i] = shape[i];
}
}
dst->flags = flags;
return dst;
}
HALIDE_BUFFER_HELPER_ATTRS
halide_buffer_t *_halide_buffer_init_from_buffer(halide_buffer_t *dst,
halide_dimension_t *dst_shape,
const halide_buffer_t *src) {
dst->host = src->host;
dst->device = src->device;
dst->device_interface = src->device_interface;
dst->type = src->type;
dst->dimensions = src->dimensions;
dst->dim = dst_shape;
dst->flags = src->flags;
for (int i = 0; i < dst->dimensions; i++) {
dst->dim[i] = src->dim[i];
}
return dst;
}
HALIDE_BUFFER_HELPER_ATTRS
halide_buffer_t *_halide_buffer_crop(halide_buffer_t *dst,
halide_dimension_t *dst_shape,
const halide_buffer_t *src,
const int *min, const int *extent) {
*dst = *src;
dst->dim = dst_shape;
int64_t offset = 0;
for (int i = 0; i < dst->dimensions; i++) {
dst->dim[i] = src->dim[i];
dst->dim[i].min = min[i];
dst->dim[i].extent = extent[i];
offset += (min[i] - src->dim[i].min) * src->dim[i].stride;
}
dst->host += offset * src->type.bytes();
return dst;
}
}
#undef HALIDE_BUFFER_HELPER_ATTRS