Q.ANT Native Computing Toolkit 2.3.1
All you need for photonic computing
Loading...
Searching...
No Matches
qant_native_computing_toolkit_native.h File Reference
#include <stdint.h>
#include <dlpack/dlpack.h>
Include dependency graph for qant_native_computing_toolkit_native.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

DLManagedTensorVersioned * mul_npu (const uint32_t npu_id, DLManagedTensorVersioned const *us, DLManagedTensorVersioned const *vs)
 Multiplies two 1D Tensors element-wise.
DLManagedTensorVersioned * calc_scaled_periodic_nl_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features, DLManagedTensorVersioned const *weights)
 Calculates a scaled periodic nonlinearity pairwise for all elements of features $u$ and weights $v$.
DLManagedTensorVersioned * linear_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features, DLManagedTensorVersioned const *weights)
 Performs a linear forward propagation between input features and a weight matrix.
DLManagedTensorVersioned * mul_npu_f32 (const uint32_t npu_id, DLManagedTensorVersioned const *us, DLManagedTensorVersioned const *vs)
 Multiplies two 1D Tensors of float32 element-wise.
DLManagedTensorVersioned * mul_npu_i16 (const uint32_t npu_id, DLManagedTensorVersioned const *us, DLManagedTensorVersioned const *vs)
 Multiplies two 1D Tensors of int16 element-wise.

Function Documentation

◆ calc_scaled_periodic_nl_fprop()

DLManagedTensorVersioned * calc_scaled_periodic_nl_fprop ( const uint32_t npu_id,
DLManagedTensorVersioned const * features,
DLManagedTensorVersioned const * weights )

Calculates a scaled periodic nonlinearity pairwise for all elements of features $u$ and weights $v$.

The output for each input pair is $w(u,v) = \mathrm{tcos}(u) \cdot v$, where $\mathrm{tcos}()$ is a $2\pi$ - periodic function with values between $-1$ and $1$, similar to a cosine.

Parameters
npu_idThe identifier of the NPU on which to perform the operation.
featuresA 1D tensor with data type bfloat16.
weightsA 1D tensor with data type bfloat16, same length as features.
Returns
A 1D tensor containing the result, same shape as input features.

◆ linear_fprop()

DLManagedTensorVersioned * linear_fprop ( const uint32_t npu_id,
DLManagedTensorVersioned const * features,
DLManagedTensorVersioned const * weights )

Performs a linear forward propagation between input features and a weight matrix.

The operation computes output = features @ weights^T, i.e.:

\‍[  \mathrm{output}[i,\,j] = \sum_k \mathrm{features}[i,k]\cdot\mathrm{weights}[j,k]
\‍]

Note that this is not a plain features @ weights — the weight matrix is implicitly transposed, matching the convention where weights has shape (n_channels_out, n_channels_in).

Parameters
npu_idThe identifier of the NPU on which to perform the operation.
featuresA 2D tensor with data type bfloat16 and shape (n_batches, n_channels_in).
weightsA 2D tensor with data type bfloat16 and shape (n_channels_out, n_channels_in).
Returns
A 2D tensor containing the result of the forward propagation with shape (n_batches, n_channels_out).

◆ mul_npu()

DLManagedTensorVersioned * mul_npu ( const uint32_t npu_id,
DLManagedTensorVersioned const * us,
DLManagedTensorVersioned const * vs )

Multiplies two 1D Tensors element-wise.

Parameters
npu_idThe identifier of the NPU on which to perform the operation.
usThe first input tensor. Must be data type bfloat16, same length as vs.
vsThe second input tensor. Must be data type bfloat16, same length as us.
Returns
A 1D tensor containing the elementwise product, same length as input.

◆ mul_npu_f32()

DLManagedTensorVersioned * mul_npu_f32 ( const uint32_t npu_id,
DLManagedTensorVersioned const * us,
DLManagedTensorVersioned const * vs )

Multiplies two 1D Tensors of float32 element-wise.

Deprecated
Use mul_npu() with bfloat16 tensors instead.
Parameters
npu_idThe identifier of the NPU on which to perform the operation.
usThe first input tensor. Must be 1D with data type float32, same length as vs.
vsThe second input tensor. Must be 1D with data type float32, same length as us.
Returns
A 1D tensor containing the elementwise product, same length as input.

◆ mul_npu_i16()

DLManagedTensorVersioned * mul_npu_i16 ( const uint32_t npu_id,
DLManagedTensorVersioned const * us,
DLManagedTensorVersioned const * vs )

Multiplies two 1D Tensors of int16 element-wise.

Deprecated
Use mul_npu() with bfloat16 tensors instead.
Parameters
npu_idThe identifier of the NPU on which to perform the operation.
usThe first input tensor. Must be data type int16, same length as vs.
vsThe second input tensor. Must be data type int16, same length as us.
Returns
A 1D tensor containing the elementwise product, same length as input.