Tensor Tiling Library
 
Loading...
Searching...
No Matches
TTL_tensor< TENSORTYPE > Struct Template Reference

A poor mans base class for an a tensor in the passed address space. More...

#include <TTL_tensors.h>

Collaboration diagram for TTL_tensor< TENSORTYPE >:

Public Member Functions

 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)
 
 TTL_tensor ()
 Create an empty location tensor. Empty means it has all dimensions set to zero.
 
 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 (TENSORTYPE *const base, const TTL_shape &shape, const TTL_layout &layout)
 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)
 TTL_tensor(TTL_create_, const_1, location, type, sub, )
 
 operator TTL_tensor< const TENSORTYPE > () const
 Cast a TTL_tensor(<em>, const_1, location, type, , ) to a TTL_tensor(TTL, const_1, location, type, , _t)
 
const TENSORTYPE & read (const unsigned int x, const unsigned int y=0, const unsigned int z=0) const
 Read a value from a 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 tensor.
 
bool empty ()
 A Tensor is empty if its shape is empty.
 

Data Fields

TENSORTYPE * base
 
TTL_dim elem_size
 
TTL_layout layout
 
TTL_shape shape
 

Detailed Description

template<typename TENSORTYPE>
struct TTL_tensor< TENSORTYPE >

A poor mans base class for an a tensor in the passed address space.

TTL_tensor contains both the logical dimensions of a tile as well as its physical mapping to memory.

Parameters
TTL_scopeThe scope of the creation can be TTL_global or TTL_local
const_1The const name to place after the prefix - should be empty or const_
locationThe location of the tensor - should be ext or int
typeThe type of the tensor - should be any valid c type
const_2The const type to create - should be empty or const

Definition at line 102 of file TTL_cpp/TTL_tensors.h.

Constructor & Destructor Documentation

◆ TTL_tensor() [1/6]

template<typename TENSORTYPE>
TTL_tensor< TENSORTYPE >::TTL_tensor ( TENSORTYPE * base,
const TTL_shape & shape,
const TTL_layout & layout,
const TTL_offset & offset,
const TTL_dim elem_size )
inline

TTL_tensor(TTL_create_, const_2, location, type, sub, _5_params)

Parameters
baseThe ## TTL_scope ## base address of the tensor in ## location ## memory
shapeDescription of the shape of the tensor that base points
layoutThe layout of the ## location ## tensor
offsetThe offset of the tensor from the base.
See also
TTL_offset
Parameters
elem_sizeThe size of a single element in the
Returns
return a TTL_tensor(TTL_, const_1, location, type, sub, _t)

Definition at line 114 of file TTL_cpp/TTL_tensors.h.

◆ TTL_tensor() [2/6]

template<typename TENSORTYPE>
TTL_tensor< TENSORTYPE >::TTL_tensor ( )
inline

Create an empty location tensor. Empty means it has all dimensions set to zero.

Most operations on an empty tensor should turn into no-ops and so an empty tensor is the safest default state.

Definition at line 125 of file TTL_cpp/TTL_tensors.h.

◆ TTL_tensor() [3/6]

template<typename TENSORTYPE>
TTL_tensor< TENSORTYPE >::TTL_tensor ( TENSORTYPE *const base,
const TTL_shape & shape,
const TTL_layout & layout,
const TTL_dim elem_size )
inline

Create an empty location tensor. Empty means it has all dimensions set to zero.

Most operations on an empty tensor should turn into no-ops and so an empty tensor is the safest default state.

TTL_tensor(TTL_create_, const_1, location, type, sub, )

Parameters
baseThe ## TTL_scope ## base address of the tensor in ## location ## memory
shapeDescription of the shape of the tensor that base points
layoutThe layout of the ## location ## tensor
elem_sizeThe size of a single element in the tensor

The layout of the created tensor will have an offset of (0, 0, 0)

Returns
return a TTL_tensor(TTL_, const_1, location, type, sub, _t)

Definition at line 150 of file TTL_cpp/TTL_tensors.h.

◆ TTL_tensor() [4/6]

template<typename TENSORTYPE>
TTL_tensor< TENSORTYPE >::TTL_tensor ( TENSORTYPE *const base,
const TTL_shape & shape,
const TTL_layout & layout )
inline

TTL_tensor(TTL_create_, const_1, location, type, sub, )

Parameters
baseA pointer to a global address
shapeDescription of the shape of the tensor that base points
layoutThe layout of the ## location ## tensor

The layout of the created tensor will have an offset of (0, 0, 0)
The element size is inferred from the base_address pointer type.

Returns
return a TTL_tensor(TTL_, const_1, location, type, sub, _t)

Definition at line 166 of file TTL_cpp/TTL_tensors.h.

◆ TTL_tensor() [5/6]

template<typename TENSORTYPE>
TTL_tensor< TENSORTYPE >::TTL_tensor ( TENSORTYPE *const base,
const TTL_shape & shape,
const TTL_dim elem_size )
inline

TTL_tensor(TTL_create_, const_1, location, type, sub, )

Parameters
baseA pointer to a global address
shapeDescription of the shape of the tensor that base points to
elem_sizeThe size of a single element in the tensor

Layout is inferred from the shape. Offset is taken to be zero.

Returns
return a TTL_tensor(TTL_, const_1, location, type, sub, _t)

Definition at line 182 of file TTL_cpp/TTL_tensors.h.

◆ TTL_tensor() [6/6]

template<typename TENSORTYPE>
TTL_tensor< TENSORTYPE >::TTL_tensor ( TENSORTYPE *const base,
const TTL_shape & shape )
inline

TTL_tensor(TTL_create_, const_1, location, type, sub, )

Parameters
baseA pointer to a global address
shapeDescription of the shape of the tensor that base points to

Element size is inferred from the base_address pointer type. Layout is inferred from the shape. Offset is taken to be zero.

Returns
return a TTL_tensor(TTL_, const_1, location, type, sub, _t)

Definition at line 198 of file TTL_cpp/TTL_tensors.h.

Member Function Documentation

◆ empty()

template<typename TENSORTYPE>
bool TTL_tensor< TENSORTYPE >::empty ( )
inline

A Tensor is empty if its shape is empty.

See also
TTL_shape_empty
Parameters
tensorThe tensor to test for emptiness
Returns
true is the tensor is empty
false is the tensor is not empty

Definition at line 252 of file TTL_cpp/TTL_tensors.h.

◆ operator TTL_tensor< const TENSORTYPE >()

template<typename TENSORTYPE>
TTL_tensor< TENSORTYPE >::operator TTL_tensor< const TENSORTYPE > ( ) const
inline

Cast a TTL_tensor(<em>, const_1, location, type, , ) to a TTL_tensor(TTL, const_1, location, type, , _t)

This is a safe cast, and implimented as a function with helper macro for type safety

Parameters
tensorThe TTL_tensor(TTL_, , location, type, , <em>t) to be cast to a TTL_tensor(TTL, const_1, location, type, , _t)
Returns
A TTL_tensor(TTL_, const_1, location, type, , _t) version of the input tensor

Definition at line 212 of file TTL_cpp/TTL_tensors.h.

◆ read()

template<typename TENSORTYPE>
const TENSORTYPE & TTL_tensor< TENSORTYPE >::read ( const unsigned int x,
const unsigned int y = 0,
const unsigned int z = 0 ) const
inline

Read a value from a tensor.

Parameters
xThe offset in the x dimension
yThe offset in the y dimension
zThe offset in the z dimension

No bounds checking is performed.

Returns
The value read

Definition at line 227 of file TTL_cpp/TTL_tensors.h.

◆ write()

template<typename TENSORTYPE>
TENSORTYPE TTL_tensor< TENSORTYPE >::write ( const TENSORTYPE value,
const unsigned int x,
const unsigned int y = 0,
const unsigned int z = 0 )
inline

Write a value to a tensor.

Parameters
valueThe value to write
xThe offset in the x dimension
yThe offset in the y dimension
zThe offset in the z dimension

Definition at line 239 of file TTL_cpp/TTL_tensors.h.

Field Documentation

◆ base

template<typename TENSORTYPE>
TENSORTYPE* TTL_tensor< TENSORTYPE >::base

The base address of the tensor in the local address space

Definition at line 256 of file TTL_cpp/TTL_tensors.h.

◆ elem_size

template<typename TENSORTYPE>
TTL_dim TTL_tensor< TENSORTYPE >::elem_size

The sizeof the elements in the tensor

Definition at line 257 of file TTL_cpp/TTL_tensors.h.

◆ layout

template<typename TENSORTYPE>
TTL_layout TTL_tensor< TENSORTYPE >::layout

The layout of the tensor,

See also
TTL_layout

Definition at line 258 of file TTL_cpp/TTL_tensors.h.

◆ shape

template<typename TENSORTYPE>
TTL_shape TTL_tensor< TENSORTYPE >::shape

The shape of the tensor in 3 dimensions

Definition at line 259 of file TTL_cpp/TTL_tensors.h.


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