Varray library uses the varray class to
handle data to and from simulation objects. The varray
class represents data as an array and support data types that are compatible with AI Engine and HLS kernels.
To form a subsystem, two or more simulation objects can be chained
together using intermediate varray to pass data from
one to another.
| AIE data type | Supported in AIE | Supported in AIE-ML | Supported in AIE_MLv2 | MATLAB | Python Numpy | varray type |
|---|---|---|---|---|---|---|
| int8 | Yes | Yes | Yes | int8 | numpy.int8 | varray.int8 |
| uint8 | Yes | Yes | Yes | uint8 | numpy.uint8 | varray.uint8 |
| int16 | Yes | Yes | Yes | int16 | numpy.int16 | varray.int16 |
| uint16 | Yes | Yes | Yes | uint16 | numpy.uint16 | varray.uint16 |
| cint16 | Yes | Yes | Yes | complex int16 | N/A | varray.cint16 |
| int32 | Yes | Yes | Yes | int32 | numpy.int32 | varray.int32 |
| uint32 | Yes | Yes | Yes | uint32 | numpy.uint32 | varray.uint32 |
| cint32 | Yes | Yes | Yes | complex int32 | N/A | varray.cint32 |
| float8 | No | No | Yes | N/A | N/A | varray.float8 |
| float16 | No | No | Yes | N/A | numpy.float16 | varray.float16 |
| float | Yes | Yes | Yes | single | numpy.float32 | varray.float |
| cfloat | Yes | Yes | No | complex single | numpy.float64 | varray.cfloat |
| bfloat8 | No | No | Yes | N/A | N/A | varray.bfloat8 |
| bfloat16 | No | Yes | Yes | N/A | N/A | varray.bfloat16 |
| cbfloat16 | No | Yes | No | N/A | N/A | varray.cbfloat16 |
| mx9 | No | No | Yes | N/A | N/A | varray.mx9 |
| mx6 | No | No | Yes | N/A | N/A | varray.mx6 |
| mx4 | No | No | Yes | N/A | N/A | varray.mx4 |
| HLS data type | MATLAB | Python Numpy | varray type |
|---|---|---|---|
| int4 | N/A | N/A | varray.int4 |
| uint4 | N/A | N/A | varray.uint4 |
| char | int8 | numpy.int8 | varray.int8 |
| unsigned char | uint8 | numpy.uint8 | varray.uint8 |
| std::complex<char> | complex int8 | N/A | varray.cint8 |
| short | int16 | numpy.int16 | varray.int16 |
| unsigned short | uint16 | numpy.uint16 | varray.uint16 |
| std::complex<short> | complex int16 | N/A | varray.cint16 |
| int | int32 | numpy.int32 | varray.int32 |
| unsigned int | uint32 | numpy.uint32 | varray.uint32 |
| std::complex<int> | complex int32 | N/A | varray.cint32 |
| long long | int64 | numpy.int64 | varray.int64 |
| unsigned long long | uint64 | numpy.uint64 | varray.uint64 |
| float16 | N/A | numpy.float16 | varray.float16 |
| float | single | numpy.float32 | varray.float |
| std::complex<float> | complex single | numpy.complex64 | varray.cfloat |
| double | double | numpy.double | varray.double |
| std::complex<double> | complex double | numpy.complex128 | varray.cdouble |
| ap_fixed<W,I,Q,O,N> | N/A | N/A | varray.fi(1, W, W-I) |
| ap_ufixed<W,I,Q,O,N> | N/A | N/A | varray.fi(0, W, W-I) |
| ap_int<W> | N/A | N/A | varray.fi(1, W, 0) |
| ap_uint<W> | N/A | N/A | varray.fi(0, W, 0) |
varray.fi
types use rounding mode Nearest and overflow mode
Saturate.Operators, functions and casting on VARRAY objects
The varray objects support comparative operators and operations listed in the tables below. Any operation that perform value modification is required to cast the array to native data formats prior to performing math operations.
To casting from varray to language native data type use numpy.asarray(<vfs_array>, <dtype>) with
Python or cast(<vfs_array>) with MATLAB. If omitted, the data type is inferred for
Python. For MATLAB, the data type default to double
precision floating point. For details on Python NumPy and MATLAB
operations, refer to respective language API reference manuals.
| Python function | MATLAB methods | Notes |
|---|---|---|
| numpy.imag | imag() | Returns a varray with the imaginary part of the data type. |
| numpy.real | real() | Returns a varray with the real part of the data type. |
| numpy.concatenate | vertcat() / horzcat() | Concatenate arrays Note: All inputs must be varrays of the same data
type.
|
| numpy.transpose | transpose / .
|
Transpose the varray object. Note: For MATLAB, all types
except varray.fi types are supported.
|
| numpy.reshape | reshape() | Change the shape of the varray object. |
| numpy.array_equal | isequal() | Returns logical value, 1 (True)/0 (False) testing if dimensions and elements match. |
| numpy.isreal | isreal() | Test if varray object has real data type. |
| numpy.max() | max() | Return the max value as varray object. |
| numpy.min() | min() | Return the min value as varray object |
| numpy.all | all() | Test if all elements of varray object evaluates to True. |
| numpy.any | any() | Test if any element of varray object evaluates to True. |
| numpy.savetxt | N/A | Save the varray object as a text file. |