![]() |
Q.ANT Native Computing Toolkit 2.3.1
All you need for photonic computing
|
#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <dlpack/dlpack.h>

Go to the source code of this file.
Functions | |
| DLManagedTensorVersioned * | add_bias_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features, DLManagedTensorVersioned const *bias) |
| Element-wise addition. Supports batched input. | |
| DLManagedTensorVersioned * | add_bias_for_conv2d_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features, DLManagedTensorVersioned const *bias) |
| Element-wise addition. Specifically used for conv2d. | |
| DLManagedTensorVersioned * | relu_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features) |
| Performs a forward pass through a ReLU layer. | |
| DLManagedTensorVersioned * | sigmoid_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features) |
| Performs a forward pass through a Sigmoid layer. | |
| DLManagedTensorVersioned * | softmax_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features) |
| Performs a forward pass through a Softmax layer. | |
| DLManagedTensorVersioned * | conv_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features, DLManagedTensorVersioned const *kernels, size_t const padding, size_t const stride, size_t const dilation) |
| Performs a forward pass through a convolution layer. | |
| DLManagedTensorVersioned * | conv_transpose_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features, DLManagedTensorVersioned const *kernels, size_t const padding, size_t const stride, size_t const dilation, size_t const output_padding) |
| Performs a forward pass through a transposed convolution layer. | |
| DLManagedTensorVersioned * | batchnorm2d_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features, DLManagedTensorVersioned const *means, DLManagedTensorVersioned const *variances, DLManagedTensorVersioned const *weights, DLManagedTensorVersioned const *bias, float const eps) |
| Performs a forward pass through a batchnorm2d layer. | |
| DLManagedTensorVersioned * | maxpool2d_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features, size_t const kernel_height, size_t const kernel_width, size_t const padding, size_t const stride) |
| Performs a forward pass through a maxpooling2d layer. | |
| DLManagedTensorVersioned * | avgpool2d_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features, size_t const kernel_height, size_t const kernel_width, size_t const padding, size_t const stride, bool const count_include_pad) |
| Performs a forward pass through a avgpooling2d layer. | |
| DLManagedTensorVersioned * | adaptive_maxpool2d_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features, size_t const output_height, size_t const output_width) |
| Performs a forward pass through an adaptive maxpooling2d layer. | |
| DLManagedTensorVersioned * | adaptive_avgpool2d_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features, size_t const output_height, size_t const output_width) |
| Performs a forward pass through an adaptive avgpooling2d layer. | |
| DLManagedTensorVersioned * | calc_kan_layer_fprop (const uint32_t npu_id, DLManagedTensorVersioned const *features, DLManagedTensorVersioned const *phis, DLManagedTensorVersioned const *ampls, DLManagedTensorVersioned const *ks) |
| Calculates a Q.ANT version of a KAN layer (https://arxiv.org/abs/2404.19756) based on scaled_periodic_nl. | |
| DLManagedTensorVersioned * adaptive_avgpool2d_fprop | ( | const uint32_t | npu_id, |
| DLManagedTensorVersioned const * | features, | ||
| size_t const | output_height, | ||
| size_t const | output_width ) |
Performs a forward pass through an adaptive avgpooling2d layer.
Only works for symmetric input and output sizes. Input size has to be integer multiple of output size.
| npu_id | The identifier of the NPU on which to perform the operation. |
| features | A 4D tensor with data type bfloat16 and shape (n_batches, n_channels, height, width) |
| output_height | Height of the output. |
| output_width | Width of the output. |
| DLManagedTensorVersioned * adaptive_maxpool2d_fprop | ( | const uint32_t | npu_id, |
| DLManagedTensorVersioned const * | features, | ||
| size_t const | output_height, | ||
| size_t const | output_width ) |
Performs a forward pass through an adaptive maxpooling2d layer.
Only works for symmetric input and output sizes. Input size has to be integer multiple of output size.
| npu_id | The identifier of the NPU on which to perform the operation. |
| features | A 4D tensor with data type bfloat16 and shape (n_batches, n_channels, height, width) |
| output_height | Height of the output. |
| output_width | Width of the output. |
| DLManagedTensorVersioned * add_bias_for_conv2d_fprop | ( | const uint32_t | npu_id, |
| DLManagedTensorVersioned const * | features, | ||
| DLManagedTensorVersioned const * | bias ) |
Element-wise addition. Specifically used for conv2d.
| npu_id | The identifier of the NPU on which to perform the operation. |
| features | A 4D tensor with data type bfloat16 and shape (n_batches, n_channels, height, width) |
| bias | A 1D tensor with data type bfloat16 and shape (n_channels) |
| DLManagedTensorVersioned * add_bias_fprop | ( | const uint32_t | npu_id, |
| DLManagedTensorVersioned const * | features, | ||
| DLManagedTensorVersioned const * | bias ) |
Element-wise addition. Supports batched input.
| npu_id | The identifier of the NPU on which to perform the operation. |
| features | A 2D tensor with data type bfloat16 and shape (n_batches, n_channels). |
| bias | A 1D tensor with data type bfloat16 and shape (n_channels) |
| DLManagedTensorVersioned * avgpool2d_fprop | ( | const uint32_t | npu_id, |
| DLManagedTensorVersioned const * | features, | ||
| size_t const | kernel_height, | ||
| size_t const | kernel_width, | ||
| size_t const | padding, | ||
| size_t const | stride, | ||
| bool const | count_include_pad ) |
Performs a forward pass through a avgpooling2d layer.
For a mathematical definition, see https://en.wikipedia.org/wiki/Pooling_layer
| npu_id | The identifier of the NPU on which to perform the operation. |
| features | A 4D tensor with data type bfloat16 and shape (n_batches, n_channels, height, width) |
| kernel_height | Height of the pooling kernel. |
| kernel_width | Width of the pooling kernel. |
| padding | Amount of padding added to the input features. |
| stride | Step size for moving the filter window over the input features. |
| count_include_pad | When True, will include the zero-padding in the averaging calculation. |
| DLManagedTensorVersioned * batchnorm2d_fprop | ( | const uint32_t | npu_id, |
| DLManagedTensorVersioned const * | features, | ||
| DLManagedTensorVersioned const * | means, | ||
| DLManagedTensorVersioned const * | variances, | ||
| DLManagedTensorVersioned const * | weights, | ||
| DLManagedTensorVersioned const * | bias, | ||
| float const | eps ) |
Performs a forward pass through a batchnorm2d layer.
For a mathematical definition, see https://en.wikipedia.org/wiki/Batch_normalization
| npu_id | The identifier of the NPU on which to perform the operation. |
| features | A 4D tensor with data type bfloat16 and shape (n_batches, n_channels, height, width) |
| means | A 1D tensor containing the mean values for each feature, with data type bfloat16 and length n_channels |
| variances | A 1D tensor containing the variance values for each feature, with data type bfloat16 and length n_channels |
| weights | A 1D tensor containing the parameter for each feature, with data type bfloat16 and length n_channels |
| bias | A 1D tensor containing the bias value for each feature, with data type bfloat16 and length n_channels |
| eps | A small value added to the variance for numerical stability. |
| DLManagedTensorVersioned * calc_kan_layer_fprop | ( | const uint32_t | npu_id, |
| DLManagedTensorVersioned const * | features, | ||
| DLManagedTensorVersioned const * | phis, | ||
| DLManagedTensorVersioned const * | ampls, | ||
| DLManagedTensorVersioned const * | ks ) |
Calculates a Q.ANT version of a KAN layer (https://arxiv.org/abs/2404.19756) based on scaled_periodic_nl.
The mathematical function is
where
is the input (vector),
is the frequency components,
the phase offsets (tensor) and
the amplitude (tensor) and
output (vector).
denotes the cosine-related shape of the periodic optical nonlinearity.
| npu_id | The identifier of the NPU on which to perform the operation. |
| features | A 2D input tensor with shape (n_batches, n_channels_in), with data type bfloat16. |
| phis | A 3D tensor of phase offsets, shape (n_channels_out, n_channels_in, n_ks), with data type bfloat16. |
| ampls | A 3D array of amplitudes, same shape as phis, with data type bfloat16. |
| ks | A 1D tensor of frequency components, shape (n_ks), with data type bfloat16. |
| DLManagedTensorVersioned * conv_fprop | ( | const uint32_t | npu_id, |
| DLManagedTensorVersioned const * | features, | ||
| DLManagedTensorVersioned const * | kernels, | ||
| size_t const | padding, | ||
| size_t const | stride, | ||
| size_t const | dilation ) |
Performs a forward pass through a convolution layer.
| npu_id | The identifier of the NPU on which to perform the operation. |
| features | A 4D tensor with data type bfloat16 and shape (n_batches, n_channels_in, height, width) |
| kernels | A 4D tensor with data type bfloat16 and shape (n_channels_out, n_channels_in, height, width) |
| padding | Amount of padding added to the input features. |
| stride | Step size for moving the filter window over the input features. |
| dilation | Dilation ("zoom out") of the filter window. |
| DLManagedTensorVersioned * conv_transpose_fprop | ( | const uint32_t | npu_id, |
| DLManagedTensorVersioned const * | features, | ||
| DLManagedTensorVersioned const * | kernels, | ||
| size_t const | padding, | ||
| size_t const | stride, | ||
| size_t const | dilation, | ||
| size_t const | output_padding ) |
Performs a forward pass through a transposed convolution layer.
| npu_id | The identifier of the NPU on which to perform the operation. |
| features | A 4D tensor with data type bfloat16 and shape (n_batches, n_channels_in, height, width) |
| kernels | A 4D tensor with data type bfloat16 and shape (n_channels_in, n_channels_out, height, width) |
| padding | Amount of padding added to the input features. |
| stride | Step size for moving the filter window over the input features. |
| dilation | Dilation ("zoom out") of the filter window. |
| output_padding | Padding for the returned features. |
| DLManagedTensorVersioned * maxpool2d_fprop | ( | const uint32_t | npu_id, |
| DLManagedTensorVersioned const * | features, | ||
| size_t const | kernel_height, | ||
| size_t const | kernel_width, | ||
| size_t const | padding, | ||
| size_t const | stride ) |
Performs a forward pass through a maxpooling2d layer.
For a mathematical definition, see https://en.wikipedia.org/wiki/Pooling_layer
| npu_id | The identifier of the NPU on which to perform the operation. |
| features | A 4D tensor with data type bfloat16 and shape (n_batches, n_channels, height, width) |
| kernel_height | Height of the pooling kernel. |
| kernel_width | Width of the pooling kernel. |
| padding | Amount of padding added to the input features. |
| stride | Step size for moving the filter window over the input features. |
| DLManagedTensorVersioned * relu_fprop | ( | const uint32_t | npu_id, |
| DLManagedTensorVersioned const * | features ) |
Performs a forward pass through a ReLU layer.
For a mathematical definition, see https://en.wikipedia.org/wiki/Rectifier_(neural_networks)
| npu_id | The identifier of the NPU on which to perform the operation. |
| features | A 1D tensor with data type bfloat16. |
| DLManagedTensorVersioned * sigmoid_fprop | ( | const uint32_t | npu_id, |
| DLManagedTensorVersioned const * | features ) |
Performs a forward pass through a Sigmoid layer.
For a mathematical definition, see https://en.wikipedia.org/wiki/Sigmoid_function
| npu_id | The identifier of the NPU on which to perform the operation. |
| features | A 1D tensor with data type bfloat16. |
| DLManagedTensorVersioned * softmax_fprop | ( | const uint32_t | npu_id, |
| DLManagedTensorVersioned const * | features ) |
Performs a forward pass through a Softmax layer.
For a mathematical definition, see https://en.wikipedia.org/wiki/Softmax_function
| npu_id | The identifier of the NPU on which to perform the operation. |
| features | A 2D tensor with data type bfloat16 and shape (1, N). |