Arithmetic and Math operations (Not Supported) - Arithmetic and Math operations (Not Supported) - 2026.1 English - UG1864

Vitis Functional Simulation User Guide (UG1864)

Document_ID
UG1864
Release_Date
2026-06-23
Version
2026.1 English

varray does not implement arithmetic or math ufuncs. +, -, *, /, //, %, **, bitwise operators, and NumPy math functions (np.sin, np.sqrt, np.exp, np.sum, np.mean, np.fft.*, and so on) all raise TypeError. Only element-wise comparisons are implemented natively (refer to NumPy Interoperability for more information).

To do math, round-trip through NumPy:

a = va.array([1, 2, 3, 4], dtype=va.int32)

a + 1                           # TypeError: operation "add" is not supported
np.sin(a)                       # TypeError: operation "sin" is not supported

# Convert, compute, then wrap the result back if needed:
result_np = np.asarray(a) + 1                    # numpy int32 array
result_va = va.array(result_np, dtype=va.int32)  # back to varray

This is intentional. varray stores hardware-accurate byte image (quantized fi, block-scaled mx, bfloat16, half, and so on), and re-quantization after every operation hides bugs. Do the math in NumPy, then re-wrap explicitly with the varray dtype you want the hardware to see.