# Types of Numeric Tables

## SYCL* Numeric Tables

SyclNumericTable

class is designed to allow user to hold processed
data on the device side and avoid extra data transfer between host and device.
If one tries to use traditional (i.e. no *in the name) numeric tables with GPU algorithm, the data transfer will occur every time the algorithm needs to get access to the data.*

SYCL*

Generally, a SYCL* numeric table is a wrapper around
regular SYCL* buffer acting as an adapter.
It enables the user to call GPU algorithms without
unnecessary data transfer.

SYCL* Homogeneous Numeric Table

For now, only

SyclHomogenNumericTable

is implemented for DPC++ interfaces. It has similar data layout as a traditional
HomogenNumericTable

and can be initialized, operated on and uninilialized like a traditional one.
Additional capabilities of SyclHomogenNumericTable

are described in the sections below.

Initialize

A SYCL* Homogeneous numeric table can be constructed in two ways:

- as a traditionalHomogenNumericTablefrom host’s CPU memory (see Homogeneous Numeric Tables),
- by a one-dimentionalcl::sycl::buffer, in which case, the numeric table will hold a reference to the obtained SYCL* buffer.

```
cl::sycl::buffer<float, 1> bf { data, cl::sycl::range<1>{ rows*cols } };
// data is float* array with rows*cols elements
// some operations...
auto tablePtr = SyclHomogenNumericTable::create(bf, cols, rows);
```

Operate

You can get underlying reference to SYCL* buffer from

SyclHomogenNumericTable

using getBlockOfRows()

and getBlockOfColumns()

methods.```
auto blockDescriptor = tablePtr->getBlockOfRows(0, rows, readWrite);
// blockDescriptor is an object of BlockDescriptor<float> class
auto readBuffer = blockDescriptor.getBuffer().toSycl();
// readBuffer is cl::sycl::buffer<float, 1>
// some operations with readBuffer ...
tablePtr->releaseBlockOfRows(blockDescriptor);
```

SyclHomogenNumericTable

does not own cl::sycl::buffer

it was created from.
Any changes of data into this buffer will affect the related numeric table. However, the buffer that you get
from numeric table using getBlockOfRows()

or getBlockOfColumns()

methods may be another one.
In this case, you should synchronize changes of data in buffer you got
to numeric table by releaseBlockOfRows()

method call.## Heterogeneous Numeric Tables

Heterogeneous numeric tables enable you to deal with data structures
that are of different data types by nature. oneDAL provides two
ways to represent non-homogeneous numeric tables: AOS and SOA.

AOS Numeric Table

AOS Numeric Table provides access to observations (feature vectors)
that are laid out in a contiguous memory block:

Examples

SOA Numeric Table

SOA Numeric Table provides access to data sets where observations
for each feature are laid out contiguously in memory:

Examples

## Homogeneous Numeric Tables

Use homogeneous numeric tables, that is, objects of the

HomogenNumericTable

class, and matrices, that is, objects of the
Matrix

, PackedTriangularMatrix

, and PackedSymmetricMatrix

classes,
when all the features are of the same basic data type. Values of the
features are laid out in memory as one contiguous block in the
row-major order, that is, *,*Observation 1

*, and so on. In oneDAL,*Observation 2

Matrix

is a homogeneous numeric table most suitable for
matrix algebra operations.For triangular and symmetric matrices with reduced memory footprint,
special classes are available:

PackedTriangularMatrix

and
PackedSymmetricMatrix

. Use the DataLayout enumeration to choose
between representations of triangular and symmetric matrices:- Lower packed:lowerPackedSymetricMatrixorlowerPackedTriangularMatrix
- Upper packed:upperPackedTriangularMatrixorupperPackedSymetricMatrix

## CSR Numeric Table

oneDAL offers the

CSRNumericTable

class for a special version
of a homogeneous numeric table that encodes sparse data, that is,
the data with a significant number of zero elements. The library
uses the Condensed Sparse Row (CSR) format for encoding:Three arrays describe the sparse matrix M as follows:

- The array values contains non-zero elements of the matrix row-by-row.
- The j-th element of the array columns encodes the column index in the matrix M for the j-th element of the array values.
- The i-th element of the array rowIndex encodes the index in the array values corresponding to the first non-zero element in rows indexed i or greater. The last element in the array rowIndex encodes the number of non-zero elements in the matrix M.

The library supports 1-based CSR encoding only. In C++ you can
specify it by providingoneBased value through the indexing parameter
of type

CSRIndexing

in the constructor of CSRNumericTable

.

Examples

## Merged Numeric Table

oneDAL offers the

MergedNumericTable

class for tables that
provides access to data sets comprising several logical components,
such as a set of feature vectors and corresponding labels. This type
of tables enables you to read those data components from one data
source. This special type of numeric tables can hold several numeric
tables of any type but CSRNumericTable

. In a merged numeric table,
arrays are joined by columns and therefore can have different numbers
of columns. In the case of different numbers of rows in input
matrices, the number of rows in a merged table equals
,
where
is the number of
rows in the i-th matrix,
.

Examples