36#define TTL_SIZEOF(type) sizeof(type)
101template <
typename TENSORTYPE>
227 const TENSORTYPE &
read(
const unsigned int x,
const unsigned int y = 0,
const unsigned int z = 0)
const {
239 TENSORTYPE
write(
const TENSORTYPE value,
const unsigned int x,
const unsigned int y = 0,
const unsigned int z = 0) {
253 return shape.empty();
274template <
typename TENSORTYPE>
291 :
tensor(base, shape, layout, offset, elem_size),
origin(origin_shape, origin_offset) {}
344 :
TTL_sub_tensor(origin_tensor.base, origin_tensor.shape, origin_tensor.layout, origin_tensor.elem_size,
367 const TENSORTYPE &
read(
const unsigned int x,
const unsigned int y = 0,
const unsigned int z = 0)
const {
368 return tensor.read(x, y, z);
379 TENSORTYPE
write(
const TENSORTYPE value,
const unsigned int x,
const unsigned int y = 0,
const unsigned int z = 0) {
380 return tensor.write(value, x, y, z);
#define TTL_SIZEOF(type)
opencl doesn't like sizeof(void) so for it to be 1 like normal c
static TTL_offset_dim TTL_linearize(const TTL_offset &offset, const TTL_layout &layout)
Calculate the absolute linear offset in elements, based on a given tensor offset and layout.
uint32_t TTL_dim
The type used to hold the size of an object along any dimension.
int32_t TTL_offset_dim
The type used to hold offsets and origins.
Description of a Tensor layout in memory.
TTL_dim plane_spacing
The distance between the start of consequtive planes in units of elements.
TTL_dim row_spacing
The distance between the start of consequtive rows in units of elements.
TTL_layout(const TTL_dim row_spacing=0, const TTL_dim plane_spacing=0)
Create a 3D Description of a Tensor layout in memory.
Description of the 3D offset of an object.
TTL_offset_dim z
Offset in dimension z.
TTL_offset_dim y
Offset in dimension y.
TTL_offset_dim x
Offset in dimension x.
Origin(TTL_shape shape, TTL_offset sub_offset)
TTL_offset sub_offset
The offset of the sub tensor from the origin sensor.
TTL_shape shape
The shape of the origin tensor in 3 dimensions.
TTL_sub_tensor(const TTL_tensor< TENSORTYPE > &origin_tensor)
TTL_sub_tensor(TTL_create_, const_1, location, type, sub, _1_param)
TTL_sub_tensor()
Create an empty tiled internal tensor. Empty means it has all dimensions set to zero.
TTL_sub_tensor(TENSORTYPE const base, const TTL_tensor< TENSORTYPE > &origin_tensor)
TTL_sub_tensor(TTL_create_, const_1, location, type, sub, _2_params)
TTL_tensor< TENSORTYPE > tensor
TTL_sub_tensor(TENSORTYPE *const base, const TTL_shape &shape, const TTL_layout &layout, const TTL_tensor< TENSORTYPE > &origin_tensor, const TTL_offset &sub_offset)
TTL_sub_tensor(TTL_create_, const_1, location, type, sub, _5_params)
const TENSORTYPE & read(const unsigned int x, const unsigned int y=0, const unsigned int z=0) const
Read a value from a sub_tensor.
TENSORTYPE write(const TENSORTYPE value, const unsigned int x, const unsigned int y=0, const unsigned int z=0)
Write a value to a sub_tensor.
bool empty()
A Tensor is empty if its shape is empty.
TTL_sub_tensor(TENSORTYPE *base, const TTL_shape &shape, const TTL_layout &layout, const TTL_dim elem_size, const TTL_offset offset, const TTL_shape origin_shape, TTL_offset origin_offset)
TTL_sub_tensor(TTL_create_, const_1, location, type, sub, _7_params)
A poor mans base class for an a tensor in the passed address space.
bool empty()
A Tensor is empty if its shape is empty.
TENSORTYPE write(const TENSORTYPE value, const unsigned int x, const unsigned int y=0, const unsigned int z=0)
Write a value to a tensor.
TTL_tensor(TENSORTYPE *const base, const TTL_shape &shape, const TTL_layout &layout, const TTL_dim elem_size)
Create an empty location tensor. Empty means it has all dimensions set to zero.
TTL_tensor()
Create an empty location tensor. Empty means it has all dimensions set to zero.
const TENSORTYPE & read(const unsigned int x, const unsigned int y=0, const unsigned int z=0) const
Read a value from a tensor.
TTL_tensor(TENSORTYPE *const base, const TTL_shape &shape)
TTL_tensor(TTL_create_, const_1, location, type, sub, )
TTL_tensor(TENSORTYPE *const base, const TTL_shape &shape, const TTL_dim elem_size)
TTL_tensor(TTL_create_, const_1, location, type, sub, )
TTL_tensor(TENSORTYPE *const base, const TTL_shape &shape, const TTL_layout &layout)
TTL_tensor(TTL_create_, const_1, location, type, sub, )
TTL_tensor(TENSORTYPE *base, const TTL_shape &shape, const TTL_layout &layout, const TTL_offset &offset, const TTL_dim elem_size)
TTL_tensor(TTL_create_, const_2, location, type, sub, _5_params)