vaccel π
Python API for vAccel.
Arg π
Bases: CType
Wrapper for the vaccel_arg
C struct.
Manages the creation and initialization of a C struct vaccel_arg
object and provides access to it through Python properties.
Inherits
CType: Abstract base class for defining C data types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| Any | The input data to be passed to the C struct. | required |
Source code in vaccel/arg.py
buf property
π
buf: Any
Returns the buffer value from the underlying C struct.
Retrieves the buffer (buf
) stored in the struct vaccel_arg
C object. If the original data type is a Python built-in type, the buffer is converted back to that type.
Returns:
Type | Description |
---|---|
Any | The buffer value from the C |
value property
π
Returns the value of the underlying C struct.
Returns:
Type | Description |
---|---|
CData | The dereferenced 'struct vaccel_arg` |
Resource π
Bases: CType
Wrapper for the struct vaccel_resource
C object.
Manages the creation and initialization of a C struct vaccel_resource
and provides access to it through Python properties.
Inherits
CType: Abstract base class for defining C data types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| str | Path | The path to the file that will be represented by the resource. | required |
| ResourceType | The type of the resource. | required |
Source code in vaccel/resource.py
value property
π
Returns the value of the underlying C struct.
Returns:
Type | Description |
---|---|
CData | The dereferenced 'struct vaccel_resource` |
is_registered π
is_registered(session: BaseSession) -> bool
Checks if the resource is registered with the session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| BaseSession | The session to check for registration. | required |
Returns:
Type | Description |
---|---|
bool | True if the resource is registered with the session. |
Source code in vaccel/resource.py
register π
register(session: BaseSession) -> None
Register the resource with a session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| BaseSession | The session to register the resource with. | required |
Source code in vaccel/resource.py
unregister π
unregister(session: BaseSession) -> None
Unregister the resource from a session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| BaseSession | The session to unregister the resource from. | required |
Source code in vaccel/resource.py
Session π
Bases: BaseSession
, NoopMixin
, GenopMixin
, ExecMixin
, ImageMixin
, BlasMixin
, FpgaMixin
, MinmaxMixin
, TFMixin
, TFLiteMixin
, TorchMixin
Extended session with operations' functionalities.
Inherits from BaseSession
and the operation mixins, adding support for the operation functions.
Inherits
BaseSession: Core session management. NoopMixin: Debug operation. GenopMixin: Generic operation. ExecMixin: Exec operations. ImageMixin: Image-related operations. BlasMixin: BLAS operations. FpgaMixin: FPGA operations. MinmaxMixin: Minmax operations. TensorflowMixin: TensorFlow operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| int | The flags to configure the session creation. Defaults to 0. | 0 |
Source code in vaccel/session.py
value property
π
Returns the value of the underlying C struct.
Returns:
Type | Description |
---|---|
CData | The dereferenced 'struct vaccel_session` |
classify π
Performs the image classification operation.
Wraps the vaccel_image_classification()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| bytes | The image data as a | required |
Returns:
Type | Description |
---|---|
(str, str) | A tuple containing: - The classification tag. - The resulting image filename. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/image.py
depth π
Performs the image depth estimation operation.
Wraps the vaccel_image_depth()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| bytes | The image data as a | required |
Returns:
Type | Description |
---|---|
str | The resulting image filename. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/image.py
detect π
Performs the image detection operation.
Wraps the vaccel_image_detection()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| bytes | The image data as a | required |
Returns:
Type | Description |
---|---|
str | The resulting image filename. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/image.py
exec π
Performs the Exec operation.
Wraps the vaccel_exec()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| str | Path | The path to the shared object containing the function that will be called. | required |
| str | The name of the function contained in the above shared object. | required |
| list[Any] | The input arguments that will be passed to the called function. | required |
| list[Any] | The output arguments that will be passed to the called function. | required |
Returns:
Type | Description |
---|---|
list[Any] | The resulting outputs. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/exec.py
exec_with_resource π
exec_with_resource(
resource: Resource, symbol: str, arg_read: list[Any], arg_write: list[Any]
) -> list[Any]
Performs the Exec with resource operation.
Wraps the vaccel_exec_with_resource()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| Resource | The resource of the shared object containing the function that will be called. | required |
| str | The name of the function contained in the above shared object. | required |
| list[Any] | The input arguments that will be passed to the called function. | required |
| list[Any] | The output arguments that will be passed to the called function. | required |
Returns:
Type | Description |
---|---|
list[Any] | The resulting outputs. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/exec.py
fpga_arraycopy π
Performs the matrix copying operation.
Wraps the vaccel_fpga_arraycopy()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| list[int] | The matrix A to be copied. | required |
Returns:
Type | Description |
---|---|
list[int] | A copy of the matrix A. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/fpga.py
fpga_mmult π
Performs the matrix multiplication operation.
Wraps the vaccel_fpga_mmult()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| list[float] | A matrix A. | required |
| list[float] | A matrix B. | required |
Returns:
Type | Description |
---|---|
list[float] | The multiplication result of matrices A and B. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/fpga.py
fpga_parallel π
Performs the parallel matrix addition and multiplication operation.
Wraps the vaccel_fpga_parallel()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| list[float] | A matrix A. | required |
| list[float] | A matrix B. | required |
Returns:
Type | Description |
---|---|
(list[float], list[float]) | A tuple containing: - The result of the addition of matrices A and B. - The result of the multiplication of matrices A and B. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/fpga.py
fpga_vadd π
Performs the matrix addition operation.
Wraps the vaccel_fpga_vadd()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| list[float] | A matrix A. | required |
| list[float] | A matrix B. | required |
Returns:
Type | Description |
---|---|
list[float] | The addition result of matrices A and B. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/fpga.py
genop π
Performs the Generic operation.
Wraps the vaccel_genop()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| list[Arg] | The input arguments of the operation. | required |
| list[Arg] | The output arguments of the operation. Modified in place. | required |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/genop.py
has_resource π
Check if a resource is registered with the session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| Resource | The resource to check for registration. | required |
Returns:
Type | Description |
---|---|
bool | True if the resource is registered. |
Source code in vaccel/session.py
minmax π
minmax(
indata: bytes, ndata: int, low_threshold: int, high_threshold: int
) -> (bytes, float, float)
Performs the minmax operation.
Wraps the vaccel_minmax()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| bytes | The input data as a | required |
| int | The number of data to be read provided data object. | required |
| int | The threshold for the min value. | required |
| int | The threshold for the max value. | required |
Returns:
Type | Description |
---|---|
(bytes, float, float) | A tuple containing: - The resulting output data. - The detected min value of the data. - The detected max value of the data. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/minmax.py
noop π
Performs the NoOp operation.
Wraps the vaccel_noop()
C operation.
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/noop.py
pose π
Performs the image pose estimation operation.
Wraps the vaccel_image_pose()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| bytes | The image data as a | required |
Returns:
Type | Description |
---|---|
str | The resulting image filename. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/image.py
segment π
Performs the image segmentation operations.
Wraps the vaccel_image_segmentation()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| bytes | The image data as a | required |
Returns:
Type | Description |
---|---|
str | The resulting image filename. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/image.py
sgemm π
sgemm(
m: int,
n: int,
k: int,
alpha: float,
a: list[float],
lda: int,
b: list[float],
ldb: int,
beta: float,
ldc: int,
) -> list[float]
Performs the SGEMM operation.
Wraps the vaccel_sgemm()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| int | The number of rows in matrix A and matrix C. | required |
| int | The number of columns in matrix B and matrix C. | required |
| int | The number of columns in matrix A and rows in matrix B. | required |
| float | Scalar multiplier for the matrix product A * B. | required |
| list[float] | The matrix A in row-major order with shape (m, k). | required |
| int | The leading dimension of matrix A (usually m). | required |
| list[float] | The matrix B in row-major order with shape (k, n). | required |
| int | The leading dimension of matrix B (usually k). | required |
| float | Scalar multiplier for matrix C. | required |
| int | The leading dimension of matrix C (usually m). | required |
Returns:
Type | Description |
---|---|
list[float] | The resulting matrix C in row-major order with shape (m, n). |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/blas.py
tf_model_delete π
Performs the Tensorflow model deletion operation.
Wraps the vaccel_tf_session_delete()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| Resource | A resource with the model to unload. | required |
Returns:
Type | Description |
---|---|
Status | The status of the operation execution. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/tf.py
tf_model_load π
Performs the Tensorflow model loading operation.
Wraps the vaccel_tf_session_load()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| Resource | A resource with the model to load. | required |
Returns:
Type | Description |
---|---|
Status | The status of the operation execution. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/tf.py
tf_model_run π
tf_model_run(
resource: Resource,
in_nodes: list[Node],
in_tensors: list[Tensor],
out_nodes: list[Node],
run_options: Buffer | None = None,
) -> (list[Tensor], Status)
Performs the Tensorflow model run operation.
Wraps the vaccel_tf_session_run()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| Resource | A resource with the model to run. | required |
| list[Node] | The input nodes for the inference. | required |
| list[Tensor] | The input tensors for the inference. | required |
| list[Node] | The output nodes for the inference. | required |
| Buffer | None | The inference options. | None |
Returns:
Type | Description |
---|---|
(list[Tensor], Status) | A tuple containing: - The output tensors - The status of the operation execution. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/tf.py
tflite_model_delete π
Performs the Tensorflow Lite model deletion operation.
Wraps the vaccel_tflite_session_delete()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| Resource | A resource with the model to unload. | required |
Returns:
Type | Description |
---|---|
None | The status of the operation execution. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/tflite.py
tflite_model_load π
Performs the Tensorflow Lite model loading operation.
Wraps the vaccel_tflite_session_load()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| Resource | A resource with the model to load. | required |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/tflite.py
tflite_model_run π
tflite_model_run(
resource: Resource, in_tensors: list[Tensor], nr_out_tensors: int = 1
) -> (list[Tensor], int)
Performs the Tensorflow Lite model run operation.
Wraps the vaccel_tflite_session_run()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| Resource | A resource with the model to run. | required |
| list[Tensor] | The input tensors for the inference. | required |
| int | The number of output tensors. Defaults to 1. | 1 |
Returns:
Type | Description |
---|---|
(list[Tensor], int) | A tuple containing: - The output tensors - The status of the operation execution. |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |
Source code in vaccel/ops/tflite.py
torch_jitload_forward π
torch_jitload_forward(
resource: Resource,
in_tensors: list[Tensor],
nr_out_tensors: int = 1,
run_options: Buffer | None = None,
) -> list[Tensor]
Performs the Torch jitload forward operation.
Wraps the vaccel_torch_jitload_forward()
C operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
| Resource | A resource with the model to run. | required |
| list[Tensor] | The input tensors for the inference. | required |
| int | The number of output tensors. Defaults to 1. | 1 |
| Buffer | None | The inference options. | None |
Returns:
Type | Description |
---|---|
list[Tensor] | The output tensors |
Raises:
Type | Description |
---|---|
RuntimeError | If the |
FFIError | If the C operation fails. |