rte_mldev.h(3)

๐Ÿ’– rte_mldev.h โ€” the ml dev girlie's bible (part 1) ๐Ÿ’–

okay bestie, sit down, hydrate, because we're reading the rte_mldev.h manual page โ€” that's the Library Functions Manual one, section 3, and yes it's a whole header file with a manual page, because DPDK said "documentation is self-care" and honestly? ate. ๐Ÿ’…

This is part 1 of 5, so don't you dare close the tab. ๐Ÿซถ


โœจ NAME โœจ

rte_mldev.h โ€” no cap, that's the whole name, it's giving "the file said who it is and left" ๐Ÿ‘‘


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

First things first, you gotta pull in your little include squad:

#include <rte_common.h>
#include <rte_log.h>
#include <rte_mempool.h>

๐ŸŽ€ Data Structures ๐ŸŽ€

these are the structs, the whole cast of characters, the main character energy roster:

  • struct rte_ml_dev_info
  • struct rte_ml_dev_config
  • struct rte_ml_dev_qp_conf
  • struct rte_ml_buff_seg
  • struct rte_ml_op
  • struct rte_ml_op_error
  • struct rte_ml_dev_stats
  • struct rte_ml_dev_xstats_map
  • struct rte_ml_model_params
  • struct rte_ml_io_info
  • struct rte_ml_model_info

๐Ÿฆ‹ Macros ๐Ÿฆ‹

one (1) macro, and she's iconic:

  • #define RTE_ML_STR_MAX 128 โ€” the max string length vibe, 128 and not a single character more ๐Ÿ’ฏ

๐Ÿ’œ Typedefs ๐Ÿ’œ

a callback for when the dev is stopping and needs to flush:

typedef void(* rte_ml_dev_stop_flush_t) (int16_t dev_id, uint16_t qp_id,
    struct rte_ml_op *op)

๐ŸŒธ Enumerations ๐ŸŒธ

look at all these lil enums, so organized, so demure:

  • enum rte_ml_op_status { RTE_ML_OP_STATUS_SUCCESS = 0, RTE_ML_OP_STATUS_NOT_PROCESSED, RTE_ML_OP_STATUS_ERROR } โ€” how an operation went: slay, not yet, or oh no ๐Ÿ˜ญ
  • enum rte_ml_dev_xstats_mode { RTE_ML_DEV_XSTATS_DEVICE, RTE_ML_DEV_XSTATS_MODEL } โ€” are we getting stats for the device or for a model? pick your fighter
  • enum rte_ml_io_type { RTE_ML_IO_TYPE_UNKNOWN = 0, RTE_ML_IO_TYPE_INT8, RTE_ML_IO_TYPE_UINT8, RTE_ML_IO_TYPE_INT16, RTE_ML_IO_TYPE_UINT16, RTE_ML_IO_TYPE_INT32, RTE_ML_IO_TYPE_UINT32, RTE_ML_IO_TYPE_INT64, RTE_ML_IO_TYPE_UINT64, RTE_ML_IO_TYPE_FP8, RTE_ML_IO_TYPE_FP16, RTE_ML_IO_TYPE_FP32, RTE_ML_IO_TYPE_BFLOAT16 } โ€” every data type you could possibly be, literally the whole zodiac of numbers ๐Ÿ”ข
  • enum rte_ml_io_layout { RTE_ML_IO_LAYOUT_PACKED, RTE_ML_IO_LAYOUT_SPLIT } โ€” packed or split, choose your layout destiny โœจ

๐Ÿ‘‘ Functions ๐Ÿ‘‘

okay this is the big one, the whole group chat of functions, every single one, no skipping:

  • __rte_experimental int rte_ml_dev_init (size_t dev_max) โ€” spin up the ml device subsystem, dev_max being how many devices you're willing to host
  • __rte_experimental uint16_t rte_ml_dev_count (void) โ€” how many ml devices are out here living their truth
  • __rte_experimental int rte_ml_dev_is_valid_dev (int16_t dev_id) โ€” vibe check: is this dev_id even real
  • __rte_experimental int rte_ml_dev_socket_id (int16_t dev_id) โ€” which socket is this device on
  • __rte_experimental int rte_ml_dev_info_get (int16_t dev_id, struct rte_ml_dev_info *dev_info) โ€” grab the device's info into dev_info
  • __rte_experimental int rte_ml_dev_configure (int16_t dev_id, const struct rte_ml_dev_config *config) โ€” set the device up with config
  • __rte_experimental uint16_t rte_ml_dev_queue_pair_count (int16_t dev_id) โ€” how many queue pairs this device got
  • __rte_experimental int rte_ml_dev_queue_pair_setup (int16_t dev_id, uint16_t queue_pair_id, const struct rte_ml_dev_qp_conf *qp_conf, int socket_id) โ€” set up a specific queue pair with its conf on a given socket
  • __rte_experimental int rte_ml_dev_start (int16_t dev_id) โ€” go go go, device online
  • __rte_experimental int rte_ml_dev_stop (int16_t dev_id) โ€” pause, bestie
  • __rte_experimental int rte_ml_dev_close (int16_t dev_id) โ€” shut it all the way down
  • __rte_experimental uint16_t rte_ml_enqueue_burst (int16_t dev_id, uint16_t qp_id, struct rte_ml_op **ops, uint16_t nb_ops) โ€” yeet a burst of operations onto a queue pair, returns how many you actually enqueued
  • __rte_experimental uint16_t rte_ml_dequeue_burst (int16_t dev_id, uint16_t qp_id, struct rte_ml_op **ops, uint16_t nb_ops) โ€” pull a burst of finished operations back out
  • __rte_experimental int rte_ml_op_error_get (int16_t dev_id, struct rte_ml_op *op, struct rte_ml_op_error *error) โ€” did an op flop? find out why into error
  • __rte_experimental int rte_ml_dev_stats_get (int16_t dev_id, struct rte_ml_dev_stats *stats) โ€” fetch the device stats
  • __rte_experimental void rte_ml_dev_stats_reset (int16_t dev_id) โ€” wipe those stats, fresh start ๐ŸŒฑ
  • __rte_experimental int rte_ml_dev_xstats_names_get (int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id, struct rte_ml_dev_xstats_map *xstats_map, uint32_t size) โ€” get the names of the extended stats, in whatever mode, for whatever model_id, into xstats_map of size
  • __rte_experimental int rte_ml_dev_xstats_by_name_get (int16_t dev_id, const char *name, uint16_t *stat_id, uint64_t *value) โ€” look up an extended stat by its name and get its stat_id and value
  • __rte_experimental int rte_ml_dev_xstats_get (int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id, const uint16_t stat_ids[], uint64_t values[], uint16_t nb_ids) โ€” grab the actual values for nb_ids stat ids
  • __rte_experimental int rte_ml_dev_xstats_reset (int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id, const uint16_t stat_ids[], uint16_t nb_ids) โ€” reset those extended stats, by id
  • __rte_experimental int rte_ml_dev_dump (int16_t dev_id, FILE *fd) โ€” dump all the device deets into fd
  • __rte_experimental int rte_ml_dev_selftest (int16_t dev_id) โ€” run the device's own little self-test, go king
  • __rte_experimental int rte_ml_model_load (int16_t dev_id, struct rte_ml_model_params *params, uint16_t *model_id) โ€” load a model from params, get its model_id back
  • __rte_experimental int rte_ml_model_unload (int16_t dev_id, uint16_t model_id) โ€” bye bye model
  • __rte_experimental int rte_ml_model_start (int16_t dev_id, uint16_t model_id) โ€” wake that model up
  • __rte_experimental int rte_ml_model_stop (int16_t dev_id, uint16_t model_id) โ€” put it to sleep, not goodbye
  • __rte_experimental int rte_ml_model_info_get (int16_t dev_id, uint16_t model_id, struct rte_ml_model_info *model_info) โ€” get the model's info into model_info
  • __rte_experimental int rte_ml_model_params_update (int16_t dev_id, uint16_t model_id, void *buffer) โ€” swap the model's params using buffer
  • __rte_experimental int rte_ml_io_float32_to_int8 (const void *fp32, void *i8, uint64_t nb_elements, float scale, int8_t zero_point) โ€” convert fp32 โ†’ i8, nb_elements at a time, with scale and zero_point
  • __rte_experimental int rte_ml_io_int8_to_float32 (const void *i8, void *fp32, uint64_t nb_elements, float scale, int8_t zero_point) โ€” the reverse trip: i8 โ†’ fp32
  • __rte_experimental int rte_ml_io_float32_to_uint8 (const void *fp32, void *ui8, uint64_t nb_elements, float scale, uint8_t zero_point) โ€” fp32 โ†’ ui8
  • __rte_experimental int rte_ml_io_uint8_to_float32 (const void *ui8, void *fp32, uint64_t nb_elements, float scale, uint8_t zero_point) โ€” ui8 โ†’ fp32
  • __rte_experimental int rte_ml_io_float32_to_int16 (const void *fp32, void *i16, uint64_t nb_elements, float scale, int16_t zero_point) โ€” fp32 โ†’ i16
  • __rte_experimental int rte_ml_io_int16_to_float32 (const void *i16, void *fp32, uint64_t nb_elements, float scale, int16_t zero_point) โ€” i16 โ†’ fp32
  • __rte_experimental int rte_ml_io_float32_to_uint16 (const void *fp32, void *ui16, uint64_t nb_elements, float scale, uint16_t zero_point) โ€” fp32 โ†’ ui16
  • __rte_experimental int rte_ml_io_uint16_to_float32 (const void *ui16, void *fp32, uint64_t nb_elements, float scale, uint16_t zero_point) โ€” ui16 โ†’ fp32
  • __rte_experimental int rte_ml_io_float32_to_int32 (const void *fp32, void *i32, uint64_t nb_elements, float scale, int32_t zero_point) โ€” fp32 โ†’ i32
  • __rte_experimental int rte_ml_io_int32_to_float32 (const void *i32, void *fp32, uint64_t nb_elements, float scale, int32_t zero_point) โ€” i32 โ†’ fp32
  • __rte_experimental int rte_ml_io_float32_to_uint32 (const void *fp32, void *ui32, uint64_t nb_elements, float scale, uint32_t zero_point) โ€” fp32 โ†’ ui32
  • __rte_experimental int rte_ml_io_uint32_to_float32 (const void *ui32, void *fp32, uint64_t nb_elements, float scale, uint32_t zero_point) โ€” ui32 โ†’ fp32
  • __rte_experimental int rte_ml_io_float32_to_int64 (const void *fp32, void *i64, uint64_t nb_elements, float scale, int64_t zero_point) โ€” fp32 โ†’ i64
  • __rte_experimental int rte_ml_io_int64_to_float32 (const void *i64, void *fp32, uint64_t nb_elements, float scale, int64_t zero_point) โ€” i64 โ†’ fp32
  • __rte_experimental int rte_ml_io_float32_to_uint64 (const void *fp32, void *ui64, uint64_t nb_elements, float scale, uint64_t zero_point) โ€” fp32 โ†’ ui64
  • __rte_experimental int rte_ml_io_uint64_to_float32 (const void *ui64, void *fp32, uint64_t nb_elements, float scale, uint64_t zero_point) โ€” ui64 โ†’ fp32
  • __rte_experimental int rte_ml_io_float32_to_float16 (const void *fp32, void *fp16, uint64_t nb_elements) โ€” fp32 โ†’ fp16, no scale or zero_point needed, she's just built different โœจ
  • __rte_experimental int rte_ml_io_float16_to_float32 (const void *fp16, void *fp32, uint64_t nb_elements) โ€” fp16 โ†’ fp32, same deal, no quant params
  • __rte_experimental int rte_ml_io_float32_to_bfloat16 (const void *fp32, void *bf16, uint64_t nb_elements) โ€” fp32 โ†’ bf16
  • __rte_experimental int rte_ml_io_bfloat16_to_float32 (const void *bf16, void *fp32, uint64_t nb_elements) โ€” bf16 โ†’ fp32
  • __rte_experimental int rte_ml_io_quantize (int16_t dev_id, uint16_t model_id, struct rte_ml_buff_seg **dbuffer, struct rte_ml_buff_seg **qbuffer) โ€” take that dequantized dbuffer and quantize it into qbuffer for the model
  • __rte_experimental int rte_ml_io_dequantize (int16_t dev_id, uint16_t model_id, struct rte_ml_buff_seg **qbuffer, struct rte_ml_buff_seg **dbuffer) โ€” unbaking the quantized qbuffer back into dbuffer
  • __rte_experimental struct rte_mempool * rte_ml_op_pool_create (const char *name, unsigned int nb_elts, unsigned int cache_size, uint16_t user_size, int socket_id) โ€” make a mempool for ml ops, with a name, nb_elts, cache_size, user_size, and socket_id โ€” returns the mempool โญ
  • __rte_experimental void rte_ml_op_pool_free (struct rte_mempool *mempool) โ€” free that op pool, thanks for your service ๐Ÿซก

and that's set-up + the whole function roster bestie. do not go anywhere โ€” part 2 is coming and there's so much more to unpack ๐Ÿ’€๐Ÿงš

๐Ÿ’… Detailed Description ๐Ÿ’…

Warning โš ๏ธ EXPERIMENTAL: Every single function in this file may be changed or removed without prior notice. Bestie, do not build your whole personality on this API. It's giving "situationship", not "married". ๐Ÿ’€

ML (Machine Learning) device API. Yes, the networking people also do machine learning now. We contain multitudes. โœจ

The ML framework is built on the following model:

+-----------------+               rte_ml_[en|de]queue_burst()
|                 |                          |
|     Machine     o------+     +--------+    |
|     Learning    |      |     | queue  |    |    +------+
|     Inference   o------+-----o        |<===o===>|Core 0|
|     Engine      |      |     | pair 0 |         +------+
|                 o----+ |     +--------+
|                 |    | |
+-----------------+    | |     +--------+
         ^             | |     | queue  |         +------+
         |             | +-----o        |<=======>|Core 1|
         |             |       | pair 1 |         +------+
         |             |       +--------+
+--------+--------+    |
| +-------------+ |    |       +--------+
| |   Model 0   | |    |       | queue  |         +------+
| +-------------+ |    +-------o        |<=======>|Core N|
| +-------------+ |            | pair N |         +------+
| |   Model 1   | |            +--------+
| +-------------+ |
| +-------------+ |<------> rte_ml_model_load()
| |   Model ..  | |-------> rte_ml_model_info_get()
| +-------------+ |<------- rte_ml_model_start()
| +-------------+ |<------- rte_ml_model_stop()
| |   Model N   | |<------- rte_ml_model_params_update()
| +-------------+ |<------- rte_ml_model_unload()
+-----------------+

ML Device: a hardware- or software-based implementation of the ML device API, there to run inferences with a pre-trained ML model. That's it, that's the whole thing. ๐Ÿซถ

ML Model: an ML model is an algorithm that got trained over a dataset. A model is made of the procedure/algorithm and the data/pattern you need to actually make predictions on live data. Once the model is created and trained outside of the DPDK scope (not our problem, not our vibe), the model can be loaded via rte_ml_model_load() and then started using the rte_ml_model_start() API. The rte_ml_model_params_update() can be used to update the model parameters โ€” think weight and bias โ€” without unloading the model with rte_ml_model_unload(). Iconic, honestly. ๐Ÿ’…

ML Inference: the process of feeding data into the model via rte_ml_enqueue_burst() and using rte_ml_dequeue_burst() to grab the calculated outputs/predictions back out of the started model. That's the whole loop. Slay. ๐Ÿ”ฅ

In all functions of the ML device API, the ML device is designated by an integer >= 0 named as device identifier dev_id.

The functions exported by the ML device API to set up a device (designated by its device identifier) must be invoked in this exact order, no skipping, no shuffling:

  • rte_ml_dev_configure()
  • rte_ml_dev_queue_pair_setup()
  • rte_ml_dev_start()

A model is required to run the inference operations with the user-specified inputs. The application needs to invoke the ML model API in this order before queueing inference jobs:

  • rte_ml_model_load()
  • rte_ml_model_start()

A model can be loaded on a device only after the device has been configured, and can be started or stopped only after the device has been started. Order matters, bestie. It always does. ๐ŸŽ€

The rte_ml_model_info_get() API exists to retrieve information related to the model. That info would include the shape and type of input and output required for the inference. Know before you go, iykyk. ๐Ÿ‘‘

Data quantization and dequantization is one of the main aspects in the ML domain. It involves converting input data from a higher precision to a lower precision data type, and vice-versa for the output. APIs are provided to enable quantization through rte_ml_io_quantize() and dequantization through rte_ml_io_dequantize(). These APIs have the capability to handle input and output buffers holding data for multiple batches. Multi-batch? We stay fed. ๐Ÿ“

Two utility APIs โ€” rte_ml_io_input_size_get() and rte_ml_io_output_size_get() โ€” can be used to get the size of quantized and de-quantized multi-batch input and output buffers.

The user can optionally update the model parameters with rte_ml_model_params_update() after invoking the rte_ml_model_stop() API on a given model ID. Optional. No pressure. โœจ

The application can invoke, in any order, the functions exported by the ML API to enqueue inference jobs and dequeue inference response.

If the application wants to change the device configuration (i.e., call rte_ml_dev_configure() or rte_ml_dev_queue_pair_setup()), then the application must stop the device using the rte_ml_dev_stop() API. Likewise, if model parameters need to be updated then the application must call rte_ml_model_stop() followed by the rte_ml_model_params_update() API for the given model. The application does not need to call rte_ml_dev_stop() API for any model re-configuration such as rte_ml_model_params_update(), rte_ml_model_unload(), etc. Chill, you don't have to nuke the whole device for that. ๐ŸŒˆ

Once the device is in the start state after invoking the rte_ml_dev_start() API, and the model is in the start state after invoking the rte_ml_model_start() API, then the application can call rte_ml_enqueue_burst() and rte_ml_dequeue_burst() API on the destined device and model ID.

Finally, an application can close an ML device by invoking the rte_ml_dev_close() function. Clean exit, we love to see it. ๐Ÿ‘‹

A typical application utilisation of the ML API will follow this programming flow:

  • rte_ml_dev_configure()
  • rte_ml_dev_queue_pair_setup()
  • rte_ml_model_load()
  • rte_ml_dev_start()
  • rte_ml_model_start()
  • rte_ml_model_info_get()
  • rte_ml_enqueue_burst()
  • rte_ml_dequeue_burst()
  • rte_ml_model_stop()
  • rte_ml_model_unload()
  • rte_ml_dev_stop()
  • rte_ml_dev_close()

Regarding multi-threading: by default, all the functions of the ML Device API exported by a PMD are lock-free functions, which assume they are not invoked in parallel on different logical cores on the same target object. For instance, the dequeue function of a poll mode driver cannot be invoked in parallel on two logical cores to operate on the same queue pair. Of course, this function can be invoked in parallel by different logical cores on different queue pairs. It is the responsibility of the user application to enforce this rule. Read that again, bestie โ€” you are the lock. There is no lock. ๐Ÿ’€

Definition in file rte_mldev.h.


โœจ Macro Definition Documentation โœจ

#define RTE_ML_STR_MAX 128

Maximum length of name string. That's it. 128 characters of name, max. Make 'em count. ๐ŸŽ€

Definition at line 152 of file rte_mldev.h.


๐Ÿ’– Typedef Documentation ๐Ÿ’–

typedef void(* rte_ml_dev_stop_flush_t) (int16_t dev_id, uint16_t qp_id, struct rte_ml_op *op)

Callback function called during rte_ml_dev_stop(), invoked once per flushed ML op. So when the device is stopping and it's sweeping up leftover ops, this little guy gets pinged for every single one. Don't say we didn't warn you. ๐Ÿซถ

Definition at line 302 of file rte_mldev.h.


๐Ÿ”ฎ Enumeration Type Documentation ๐Ÿ”ฎ

enum rte_ml_op_status

Status of ML operation. Because you deserve to know how it went. ๐Ÿ’…

Enumerator

  • RTE_ML_OP_STATUS_SUCCESS โ€” Operation completed successfully. Ate. No crumbs. โœจ
  • RTE_ML_OP_STATUS_NOT_PROCESSED โ€” Operation has not yet been processed by the device. It's giving "in my queue era". โณ
  • RTE_ML_OP_STATUS_ERROR โ€” Operation completed with error. The application can invoke rte_ml_op_error_get() to get the PMD-specific error code if needed. Not the vibe, but at least there's a lookup. ๐Ÿ˜ญ

Definition at line 404 of file rte_mldev.h.


enum rte_ml_dev_xstats_mode

Selects which component of the mldev to retrieve statistics from.

Enumerator

  • RTE_ML_DEV_XSTATS_DEVICE โ€” Device xstats ๐Ÿ‘‘
  • RTE_ML_DEV_XSTATS_MODEL โ€” Model xstats ๐Ÿฆ‹

Definition at line 632 of file rte_mldev.h.


enum rte_ml_io_type

Input and output data types. ML models can operate on reduced-precision datatypes to achieve better power efficiency, lower network latency and lower memory footprint. This enum is used to represent the lower-precision integer and floating point types used by ML models. Small numbers, huge main character energy. โญ

Enumerator

  • RTE_ML_IO_TYPE_UNKNOWN โ€” Invalid or unknown type ๐Ÿ™ˆ
  • RTE_ML_IO_TYPE_INT8 โ€” 8-bit integer
  • RTE_ML_IO_TYPE_UINT8 โ€” 8-bit unsigned integer
  • RTE_ML_IO_TYPE_INT16 โ€” 16-bit integer
  • RTE_ML_IO_TYPE_UINT16 โ€” 16-bit unsigned integer
  • RTE_ML_IO_TYPE_INT32 โ€” 32-bit integer
  • RTE_ML_IO_TYPE_UINT32 โ€” 32-bit unsigned integer
  • RTE_ML_IO_TYPE_INT64 โ€” 32-bit integer
  • RTE_ML_IO_TYPE_UINT64 โ€” 32-bit unsigned integer
  • RTE_ML_IO_TYPE_FP8 โ€” 8-bit floating point number
  • RTE_ML_IO_TYPE_FP16 โ€” IEEE 754 16-bit floating point number
  • RTE_ML_IO_TYPE_FP32 โ€” IEEE 754 32-bit floating point number
  • RTE_ML_IO_TYPE_BFLOAT16 โ€” 16-bit brain floating point number.

Definition at line 875 of file rte_mldev.h.

Okay bestie, not me noticing that RTE_ML_IO_TYPE_INT64 says "32-bit integer" and RTE_ML_IO_TYPE_UINT64 says "32-bit unsigned integer". That's what the file says, and we report exactly what the file says, so here it stays, character for character. Fr fr. ๐Ÿ’€

enum rte_ml_io_layout

ML I/O buffer layout. How do you want your data served? ๐Ÿ“

Enumerator

  • RTE_ML_IO_LAYOUT_PACKED โ€” All inputs for the model should be packed in a single buffer with no padding between individual inputs. The buffer is expected to be aligned to rte_ml_dev_info::align_size.

When I/O segmentation is supported by the device, the packed data can be split into multiple segments. In this case, each segment is expected to be aligned to rte_ml_dev_info::align_size.

Same applies to output.

See also: struct rte_ml_dev_info::max_segments

  • RTE_ML_IO_LAYOUT_SPLIT โ€” Each input for the model should be stored as separate buffers, and each input should be aligned to rte_ml_dev_info::align_size.

When I/O segmentation is supported, each input can be split into multiple segments. In this case, each segment is expected to be aligned to rte_ml_dev_info::align_size.

Same applies to output.

See also: struct rte_ml_dev_info::max_segments

Definition at line 905 of file rte_mldev.h.


๐Ÿ› ๏ธ Function Documentation ๐Ÿ› ๏ธ

__rte_experimental int rte_ml_dev_init (size_t dev_max)

Maximum number of devices if rte_ml_dev_init() is not called. Initialize the device array before probing devices. If it's not called, the first device probed would initialize the array to a size of RTE_MLDEV_DEFAULT_MAX. She's self-starting like that. ๐Ÿ’…

Parameters

  • dev_max โ€” Maximum number of devices.

Returns

  • 0 on success, -rte_errno otherwise:
    • ENOMEM if out of memory
    • EINVAL if 0 size
    • EBUSY if already initialized

__rte_experimental uint16_t rte_ml_dev_count (void )

Get the total number of ML devices that have been successfully initialised. Roll call. ๐Ÿ“ฃ

Returns

  • The total number of usable ML devices.

__rte_experimental int rte_ml_dev_is_valid_dev (int16_t dev_id)

Check if the device is in ready state.

Parameters

  • dev_id โ€” The identifier of the device.

Returns

  • 0 if device state is not in ready state.
  • 1 if device state is ready state.

Vibe check, but for a device. โœจ


__rte_experimental int rte_ml_dev_socket_id (int16_t dev_id)

Return the NUMA socket to which a device is connected. Where does this device live? Real estate question. ๐Ÿ 

Parameters

  • dev_id โ€” The identifier of the device.

Returns

  • The NUMA socket id to which the device is connected
  • 0 If the socket could not be determined.
  • -EINVAL: if the dev_id value is not valid.

rte_ml_dev_info_get() โ€” get the deets on your ML device ๐Ÿ’…

__rte_experimental int rte_ml_dev_info_get (int16_t dev_id, struct rte_ml_dev_info * dev_info)

Okay bestie, so this one is literally just here to retrieve the information of the device. It's giving you the whole rundown, like a little info dump. ๐Ÿ“‹โœจ

Parameters:

  • dev_id โ€” the identifier of the device. It's the device's little ID number, you know?
  • dev_info โ€” a pointer to a structure of type rte_ml_dev_info to be filled with the info of the device. So you pass in a pointer, and it gets filled with all the juicy details.

Returns:

  • 0: Success, driver updates the information of the ML device. Slay! ๐Ÿ’–
  • < 0: Error code returned by the driver info get function. Oops, something went wrong. ๐Ÿ˜ญ

rte_ml_dev_configure() โ€” set up your ML device, periodt ๐Ÿ’…

__rte_experimental int rte_ml_dev_configure (int16_t dev_id, const struct rte_ml_dev_config * config)

This function must be invoked first before any other function in the API. Like, it's the main character, the first step. No cap. ๐Ÿ”ฅ

ML Device can be re-configured, when in a stopped state. Device cannot be re-configured after rte_ml_dev_close() is called. So don't even try it after closing, okay? ๐Ÿ™…โ€โ™€๏ธ

The caller may use rte_ml_dev_info_get() to get the capability of each resources available for this ML device. So you can check what it can do first. ๐Ÿ’โ€โ™€๏ธ

Parameters:

  • dev_id โ€” the identifier of the device to configure.
  • config โ€” the ML device configuration structure.

Returns:

  • 0: Success, device configured. Yasss! โœจ
  • < 0: Error code returned by the driver configuration function. Big yikes. ๐Ÿ˜ญ

rte_ml_dev_queue_pair_count() โ€” how many queue pairs? ๐Ÿ”ข

__rte_experimental uint16_t rte_ml_dev_queue_pair_count (int16_t dev_id)

Get the number of queue pairs on a specific ML device. It's like asking "how many lanes we got?" ๐Ÿ›ฃ๏ธ

Parameters:

  • dev_id โ€” the identifier of the device.

Returns:

  • The number of configured queue pairs. Periodt. ๐Ÿ’…

rte_ml_dev_queue_pair_setup() โ€” set up a queue pair ๐Ÿ’…

__rte_experimental int rte_ml_dev_queue_pair_setup (int16_t dev_id, uint16_t queue_pair_id, const struct rte_ml_dev_qp_conf * qp_conf, int socket_id)

Set up a queue pair for a device. This should only be called when the device is stopped. So like, don't do it while it's running, okay? ๐Ÿ™ˆ

Parameters:

  • dev_id โ€” the identifier of the device.
  • queue_pair_id โ€” the index of the queue pairs to set up. The value must be in the range [0, nb_queue_pairs - 1] previously supplied to rte_ml_dev_configure().
  • qp_conf โ€” the pointer to the configuration data to be used for the queue pair.
  • socket_id โ€” the socket_id argument is the socket identifier in case of NUMA. The value can be SOCKET_ID_ANY if there is no NUMA constraint for the memory allocated for the queue pair.

Returns:

  • 0: Success, queue pair correctly set up. Slay! โœจ
  • < 0: Queue pair configuration failed. Sad. ๐Ÿ˜ญ

rte_ml_dev_start() โ€” start that device! ๐Ÿ”ฅ

__rte_experimental int rte_ml_dev_start (int16_t dev_id)

Start an ML device. The device start step consists of setting the configured features and enabling the ML device to accept inference jobs. So it's like, "go, go, go!" ๐Ÿ

Parameters:

  • dev_id โ€” the identifier of the device.

Returns:

  • 0: Success, device started. We love to see it. ๐Ÿ’–
  • <0: Error code of the driver device start function. Oops. ๐Ÿ˜ญ

rte_ml_dev_stop() โ€” stop, in the name of love โœ‹

__rte_experimental int rte_ml_dev_stop (int16_t dev_id)

Stop an ML device. A stopped device cannot accept inference jobs. The device can be restarted with a call to rte_ml_dev_start(). So it's like a pause, not a forever goodbye. โธ๏ธ

Parameters:

  • dev_id โ€” the identifier of the device.

Returns:

  • 0: Success, device stopped. Chill. ๐ŸงŠ
  • <0: Error code of the driver device stop function. Yikes. ๐Ÿ˜ญ

rte_ml_dev_close() โ€” close it, and it's over ๐Ÿ’€

__rte_experimental int rte_ml_dev_close (int16_t dev_id)

Close an ML device. The device cannot be restarted! So this is the final boss. No coming back. ๐Ÿšซ

Warning: The device cannot be restarted! Once you close it, it's done. No cap. ๐Ÿ’€

Parameters:

  • dev_id โ€” the identifier of the device.

Returns:

  • 0 on successfully closing device. Bye bestie. ๐Ÿ‘‹
  • <0 on failure to close device. ๐Ÿ˜ญ

rte_ml_enqueue_burst() โ€” enqueue a burst of inferences ๐Ÿš€

__rte_experimental uint16_t rte_ml_enqueue_burst (int16_t dev_id, uint16_t qp_id, struct rte_ml_op ** ops, uint16_t nb_ops)

Enqueue a burst of ML inferences for processing on an ML device. It's like sending a whole squad of jobs to the device. ๐Ÿ’…

The rte_ml_enqueue_burst() function is invoked to place ML inference operations on the queue qp_id of the device designated by its dev_id.

The nb_ops parameter is the number of inferences to process which are supplied in the ops array of rte_ml_op structures.

The rte_ml_enqueue_burst() function returns the number of inferences it actually enqueued for processing. A return value equal to nb_ops means that all inferences have been enqueued. So if it returns nb_ops, you're all good. If not, some got left out. ๐Ÿ˜ญ

Parameters:

  • dev_id โ€” the identifier of the device.
  • qp_id โ€” the index of the queue pair which inferences are to be enqueued for processing. The value must be in the range [0, nb_queue_pairs - 1] previously supplied to rte_ml_dev_configure.
  • ops โ€” the address of an array of nb_ops pointers to rte_ml_op structures which contain the ML inferences to be processed.
  • nb_ops โ€” the number of operations to process.

Returns:

The number of inference operations actually enqueued to the ML device. The return value can be less than the value of the nb_ops parameter when the ML device queue is full or if invalid parameters are specified in a rte_ml_op.


rte_ml_dequeue_burst() โ€” dequeue that burst! ๐Ÿ“ฅ

__rte_experimental uint16_t rte_ml_dequeue_burst (int16_t dev_id, uint16_t qp_id, struct rte_ml_op ** ops, uint16_t nb_ops)

Dequeue a burst of processed ML inferences operations from a queue on the ML device. The dequeued operations are stored in rte_ml_op structures whose pointers are supplied in the ops array. So it's like collecting the finished jobs. ๐ŸŽ‰

The rte_ml_dequeue_burst() function returns the number of inferences actually dequeued, which is the number of rte_ml_op data structures effectively supplied into the ops array.

A return value equal to nb_ops indicates that the queue contained at least nb_ops operations, and this is likely to signify that other processed operations remain in the devices output queue. Application implementing a "retrieve as many processed operations as possible" policy can check this specific case and keep invoking the rte_ml_dequeue_burst() function until a value less than nb_ops is returned. So keep going until you get less than nb_ops. ๐Ÿ”

The rte_ml_dequeue_burst() function does not provide any error notification to avoid the corresponding overhead. So no error messages, just vibes. ๐Ÿ™ˆ

Parameters:

  • dev_id โ€” the identifier of the device.
  • qp_id โ€” the index of the queue pair from which to retrieve processed inferences. The value must be in the range [0, nb_queue_pairs - 1] previously supplied to rte_ml_dev_configure().
  • ops โ€” the address of an array of pointers to rte_ml_op structures that must be large enough to store nb_ops pointers in it.
  • nb_ops โ€” the maximum number of inferences to dequeue.

Returns:

The number of operations actually dequeued, which is the number of pointers to rte_ml_op structures effectively supplied to the ops array.


rte_ml_op_error_get() โ€” get the error deets on an op ๐Ÿ˜ญ

__rte_experimental int rte_ml_op_error_get (int16_t dev_id, struct rte_ml_op * op, struct rte_ml_op_error * error)

Get PMD specific error information for an ML op. When an ML operation completed with RTE_ML_OP_STATUS_ERROR as status, This API allows to get PMD specific error details. So if your op failed, this tells you why. ๐Ÿ”

Parameters:

  • dev_id โ€” Device identifier
  • op โ€” Handle of ML operation
  • error โ€” Address of structure rte_ml_op_error to be filled

Returns:

  • Returns 0 on success. โœจ
  • Returns negative value on failure. ๐Ÿ˜ญ

rte_ml_dev_stats_get() โ€” get those stats! ๐Ÿ“Š

__rte_experimental int rte_ml_dev_stats_get (int16_t dev_id, struct rte_ml_dev_stats * stats)

Retrieve the general I/O statistics of a device. Like, how many things went in and out? ๐Ÿ“ˆ

Parameters:

  • dev_id โ€” the identifier of the device.
  • stats โ€” Pointer to structure to where statistics will be copied. On error, this location may or may not have been modified. So be careful, it might be messy. ๐Ÿ™ˆ

Returns:

  • 0 on success. ๐Ÿ’…
  • -EINVAL: If invalid parameter pointer is provided. Oops. ๐Ÿ˜ญ

rte_ml_dev_stats_reset() โ€” reset those stats ๐Ÿ”„

__rte_experimental void rte_ml_dev_stats_reset (int16_t dev_id)

Reset the statistics of a device. Like, clear the slate. ๐Ÿงผ

Parameters:

  • dev_id โ€” the identifier of the device.

rte_ml_dev_xstats_names_get() โ€” get the names of extended stats ๐Ÿ“

__rte_experimental int rte_ml_dev_xstats_names_get (int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id, struct rte_ml_dev_xstats_map * xstats_map, uint32_t size)

Retrieve names of extended statistics of an ML device. It's like getting the labels for all the extra stats. ๐Ÿท๏ธ

Parameters:

  • dev_id โ€” the identifier of the device.
  • mode โ€” Mode of statistics to retrieve. Choices include the device statistics and model statistics.
  • model_id โ€” Used to specify the model number in model mode, and is ignored in device mode.
  • xstats_map โ€” Block of memory to insert names and ids into. Must be at least size in capacity. If set to NULL, function returns required capacity. The id values returned can be passed to rte_ml_dev_xstats_get to select statistics.
  • size โ€” Capacity of xstats_names (number of xstats_map).

Returns:

  • Positive value lower or equal to size: success. The return value is the number of entries filled in the stats table. Yay! โœจ
  • Positive value higher than size: error, the given statistics table is too small. The return value corresponds to the size that should be given to succeed. The entries in the table are not valid and shall not be used by the caller. So if you get this, you need a bigger table. ๐Ÿ˜ญ
  • Negative value on error: -ENODEV for invalid dev_id. -EINVAL for invalid mode, model parameters. -ENOTSUP if the device doesn't support this function.

rte_ml_dev_xstats_by_name_get() โ€” get a single stat by name ๐Ÿ”

__rte_experimental int rte_ml_dev_xstats_by_name_get (int16_t dev_id, const char * name, uint16_t * stat_id, uint64_t * value)

Retrieve the value of a single stat by requesting it by name. Like, "hey, what's the value of this specific stat?" ๐Ÿ’…

Parameters:

  • dev_id โ€” the identifier of the device.
  • name โ€” Name of stat name to retrieve.
  • stat_id โ€” If non-NULL, the numerical id of the stat will be returned, so that further requests for the stat can be got using rte_ml_dev_xstats_get, which will be faster as it doesn't need to scan a list of names for the stat. If the stat cannot be found, the id returned will be (unsigned)-1.
  • value โ€” Value of the stat to be returned.

Returns:

  • Zero: No error. ๐Ÿ˜Œ
  • Negative value: -EINVAL if stat not found, -ENOTSUP if not supported. ๐Ÿ˜ญ

rte_ml_dev_xstats_get() โ€” get extended stats ๐Ÿ“Š

__rte_experimental int rte_ml_dev_xstats_get (int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id, const uint16_t stat_ids[], uint64_t values[], uint16_t nb_ids)

Retrieve extended statistics of an ML device. It's like getting the values for a bunch of stats by their IDs. ๐Ÿ”ข

Parameters:

  • dev_id โ€” the identifier of the device.
  • mode โ€” Mode of statistics to retrieve. Choices include the device statistics and model statistics.
  • model_id โ€” Used to specify the model id in model mode, and is ignored in device mode.
  • stat_ids โ€” ID numbers of the stats to get. The ids can be got from the stat position in the stat list from rte_ml_dev_xstats_names_get(), or by using rte_ml_dev_xstats_by_name_get().
  • values โ€” Values for each stats request by ID.
  • nb_ids โ€” Number of stats requested.

Returns:

  • Positive value: number of stat entries filled into the values array. Slay! ๐Ÿ’–
  • Negative value on error: -ENODEV for invalid dev_id. -EINVAL for invalid mode, model id or stat id parameters. -ENOTSUP if the device doesn't support this function. ๐Ÿ˜ญ

rte_ml_dev_xstats_reset() โ€” reset those xstats ๐Ÿ”„

__rte_experimental int rte_ml_dev_xstats_reset (int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id, const uint16_t stat_ids[], uint16_t nb_ids)

Reset the values of the xstats of the selected component in the device.

  • dev_id โ€” bestie, this is just the identifier of the device. that's it. that's the whole vibe. ๐ŸŽ€
  • mode โ€” what kind of stats you're nuking. pick from device or model. choose wisely, we're not taking it back.
  • model_id โ€” which model's stats are getting reset. 0 and any positive value = go get that specific model, while -1 = every single model, no survivors ๐Ÿ’€
  • stat_ids โ€” if you only want some specific stats gone, point this at them. when it's NULL, everything selected by mode gets reset. if it's not NULL, it has to point to an array of at least nb_ids in size. no shortcuts.
  • nb_ids โ€” how many ids you actually stuffed into that array. and heads up: this gets ignored when ids is NULL (yes, the original says ids here, we don't make the rules ๐Ÿ™ˆ).

Returns like:

  • Zero โ€” stats reset, slayed, done. โœจ
  • Negative value โ€” -EINVAL if your parameters are invalid, or -ENOTSUP if this device simply does not support it. not her fault.

๐Ÿ—‘๏ธ __rte_experimental int rte_ml_dev_dump (int16_t dev_id, FILE * fd)

Dump all the internal tea about dev_id into the FILE* you hand over in fd. it's giving "spill everything to a file". โ˜•

Parameters

  • dev_id โ€” the identifier of the device.
  • fd โ€” a pointer to a file for output.

Returns

  • 0 โ€” on success. ๐Ÿ‘‘
  • <0 โ€” on failure. ๐Ÿ˜ญ

๐Ÿชž __rte_experimental int rte_ml_dev_selftest (int16_t dev_id)

Trigger the ML device self test. it's literally looking in the mirror and checking itself out.

Parameters

  • dev_id โ€” the identifier of the device.

Returns

  • 0 โ€” Selftest successful. ๐Ÿ’…
  • -ENOTSUP โ€” if the device doesn't support selftest. not every queen does the full routine.
  • other values < 0 โ€” on failure.

๐Ÿ“ฅ __rte_experimental int rte_ml_model_load (int16_t dev_id, struct rte_ml_model_params * params, uint16_t * model_id)

Load an ML model onto the device. ๐Ÿฆ‹

She loads an ML model to the device with the parameters you requested in the structure rte_ml_model_params.

Parameters

  • dev_id โ€” the identifier of the device.
  • params โ€” parameters for the model to be loaded.
  • model_id โ€” identifier of the model loaded.

Returns

  • 0 โ€” Success, Model loaded. main character behavior.
  • < 0 โ€” Failure, Error code of the model load driver function.

๐Ÿ“ค __rte_experimental int rte_ml_model_unload (int16_t dev_id, uint16_t model_id)

Unload an ML model from the device. saying goodbye, respectfully. ๐Ÿซถ

Parameters

  • dev_id โ€” the identifier of the device.
  • model_id โ€” identifier of the model to be unloaded.

Returns

  • 0 โ€” Success, Model unloaded.
  • < 0 โ€” Failure, Error code of the model unload driver function.

โ–ถ๏ธ __rte_experimental int rte_ml_model_start (int16_t dev_id, uint16_t model_id)

Start an ML model for the given device ID. โœจ

Start an ML model so it can accept inference requests. she's open for business, bestie.

Parameters

  • dev_id โ€” the identifier of the device.
  • model_id โ€” identifier of the model to be started.

Returns

  • 0 โ€” Success, Model started. ๐Ÿ”ฅ
  • < 0 โ€” Failure, Error code of the model start driver function.

โธ๏ธ __rte_experimental int rte_ml_model_stop (int16_t dev_id, uint16_t model_id)

Stop an ML model for the given device ID.

Model stop would disable the ML model from being used for inference jobs. and lowkey the important part: all inference jobs must have been completed before model stop is attempted. no yanking the plug mid-sentence, fr.

Parameters

  • dev_id โ€” the identifier of the device.
  • model_id โ€” identifier of the model to be stopped.

Returns

  • 0 โ€” Success, Model stopped.
  • < 0 โ€” Failure, Error code of the model stop driver function.

๐Ÿ” __rte_experimental int rte_ml_model_info_get (int16_t dev_id, uint16_t model_id, struct rte_ml_model_info * model_info)

Get ML model information. the โœจreceiptsโœจ.

Parameters

  • dev_id โ€” the identifier of the device.
  • model_id โ€” identifier for the model created
  • model_info โ€” pointer to a model info structure

Returns

  • Returns 0 on success
  • Returns negative value on failure

๐Ÿ”ง __rte_experimental int rte_ml_model_params_update (int16_t dev_id, uint16_t model_id, void * buffer)

Update the model parameters without unloading the model. glow-up in place, no reload needed. ๐Ÿ’…

Update model parameters such as weights and bias without unloading the model. and listen: rte_ml_model_stop() must be called before invoking this API. no cap.

Parameters

  • dev_id โ€” the identifier of the device.
  • model_id โ€” identifier for the model created
  • buffer โ€” pointer to the model weights and bias buffer. Size of the buffer is equal to wb_size returned in rte_ml_model_info.

Returns

  • Returns 0 on success
  • Returns negative value on failure

๐ŸŒธ __rte_experimental int rte_ml_io_float32_to_int8 (const void * fp32, void * i8, uint64_t nb_elements, float scale, int8_t zero_point)

Convert a buffer containing numbers in single precision floating format (float32) to signed 8-bit integer format (INT8). glow-down, i guess. ๐Ÿฆ‹

Parameters

  • fp32 โ€” input buffer containing float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
  • i8 โ€” output buffer to store INT8 numbers. Size of buffer is equal to (nb_elements * 1) bytes.
  • nb_elements โ€” number of elements in the buffer.
  • scale โ€” scale factor for conversion.
  • zero_point โ€” zero point for conversion.

Returns

  • 0 โ€” Success.
  • < 0 โ€” Error code on failure.

๐ŸŒธ __rte_experimental int rte_ml_io_int8_to_float32 (const void * i8, void * fp32, uint64_t nb_elements, float scale, int8_t zero_point)

Convert a buffer containing numbers in signed 8-bit integer format (INT8) to single precision floating format (float32). she's upgrading, periodt.

Parameters

  • i8 โ€” input buffer containing INT8 numbers. Size of buffer is equal to (nb_elements * 1) bytes.
  • fp32 โ€” output buffer to store float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
  • nb_elements โ€” number of elements in the buffer.
  • scale โ€” scale factor for conversion.
  • zero_point โ€” zero point for conversion.

Returns

  • 0 โ€” Success.
  • < 0 โ€” Error code on failure.

๐ŸŽ€ __rte_experimental int rte_ml_io_float32_to_uint8 (const void * fp32, void * ui8, uint64_t nb_elements, float scale, uint8_t zero_point)

Convert a buffer containing numbers in single precision floating format (float32) to unsigned 8-bit integer format (UINT8). keepin' it positive โœจ.

Parameters

  • fp32 โ€” input buffer containing float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
  • ui8 โ€” output buffer to store UINT8 numbers. Size of buffer is equal to (nb_elements * 1) bytes.
  • nb_elements โ€” number of elements in the buffer.
  • scale โ€” scale factor for conversion.
  • zero_point โ€” zero point for conversion.

Returns

  • 0 โ€” Success.
  • < 0 โ€” Error code on failure.

๐ŸŽ€ __rte_experimental int rte_ml_io_uint8_to_float32 (const void * ui8, void * fp32, uint64_t nb_elements, float scale, uint8_t zero_point)

Convert a buffer containing numbers in unsigned 8-bit integer format (UINT8) to single precision floating format (float32).

Parameters

  • ui8 โ€” input buffer containing UINT8 numbers. Size of buffer is equal to (nb_elements * 1) bytes.
  • fp32 โ€” output buffer to store float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
  • nb_elements โ€” number of elements in the buffer.
  • scale โ€” scale factor for conversion.
  • zero_point โ€” zero point for conversion.

Returns

  • 0 โ€” Success.
  • < 0 โ€” Error code on failure.

๐Ÿ’œ __rte_experimental int rte_ml_io_float32_to_int16 (const void * fp32, void * i16, uint64_t nb_elements, float scale, int16_t zero_point)

Convert a buffer containing numbers in single precision floating format (float32) to signed 16-bit integer format (INT16).

Parameters

  • fp32 โ€” input buffer containing float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
  • i16 โ€” output buffer to store INT16 numbers. Size of buffer is equal to (nb_elements * 2) bytes.
  • nb_elements โ€” number of elements in the buffer.
  • scale โ€” scale factor for conversion.
  • zero_point โ€” zero point for conversion.

Returns

  • 0 โ€” Success.
  • < 0 โ€” Error code on failure.

๐Ÿ’œ __rte_experimental int rte_ml_io_int16_to_float32 (const void * i16, void * fp32, uint64_t nb_elements, float scale, int16_t zero_point)

Convert a buffer containing numbers in signed 16-bit integer format (INT16) to single precision floating format (float32).

Parameters

  • i16 โ€” input buffer containing INT16 numbers. Size of buffer is equal to (nb_elements * 2) bytes.
  • fp32 โ€” output buffer to store float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
  • nb_elements โ€” number of elements in the buffer.
  • scale โ€” scale factor for conversion.
  • zero_point โ€” zero point for conversion.

Returns

  • 0 โ€” Success.
  • < 0 โ€” Error code on failure.

๐Ÿงš __rte_experimental int rte_ml_io_float32_to_uint16 (const void * fp32, void * ui16, uint64_t nb_elements, float scale, uint16_t zero_point)

Convert a buffer containing numbers in single precision floating format (float32) to unsigned 16-bit integer format (UINT16).

Parameters

  • fp32 โ€” input buffer containing float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
  • ui16 โ€” output buffer to store UINT16 numbers. Size of buffer is equal to (nb_elements * 2) bytes.
  • nb_elements โ€” number of elements in the buffer.
  • scale โ€” scale factor for conversion.
  • zero_point โ€” zero point for conversion.

Returns

  • 0 โ€” Success.
  • < 0 โ€” Error code on failure.

๐Ÿงš __rte_experimental int rte_ml_io_uint16_to_float32 (const void * ui16, void * fp32, uint64_t nb_elements, float scale, uint16_t zero_point)

Convert a buffer containing numbers in unsigned 16-bit integer format (UINT16) to single precision floating format (float32).

Parameters

  • ui16 โ€” input buffer containing UINT16 numbers. Size of buffer is equal to (nb_elements * 2) bytes.
  • fp32 โ€” output buffer to store float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
  • nb_elements โ€” number of elements in the buffer.
  • scale โ€” scale factor for conversion.
  • zero_point โ€” zero point for conversion.

Returns

  • 0 โ€” Success.
  • < 0 โ€” Error code on failure.

๐ŸŒˆ __rte_experimental int rte_ml_io_float32_to_int32 (const void * fp32, void * i32, uint64_t nb_elements, float scale, int32_t zero_point)

Convert a buffer containing numbers in single precision floating format (float32) to signed 32-bit integer format (INT32).

Parameters

  • fp32 โ€” input buffer containing float32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
  • i32 โ€” output buffer to store INT32 numbers. Size of buffer is equal to (nb_elements * 4) bytes.
  • nb_elements โ€” number of elements in the buffer.
  • scale โ€” scale factor for conversion.
  • zero_point โ€” zero point for conversion.

Returns

  • 0 โ€” Success.
  • < 0 โ€” Error code on failure.

๐ŸŒˆ __rte_experimental int rte_ml_io_int32_to_float32 (const void * i32, void * fp32, uint64_t nb_elements, float scale, int32_t zero_point)

Convert a buffer containing numbers in signed 32-bit integer format (INT32) to single precision floating format (float32).

๐ŸŒธ the i32 โ†’ fp32 one (finishing off what we started up there)

Parameters

  • i32 โ€” input buffer stuffed with INT32 numbers, and the way the size math works is size of buffer == nb_elements * 4 bytes ๐Ÿซถ
  • fp32 โ€” output buffer where the float32 numbers land, also sized nb_elements * 4 bytes ๐Ÿ’–
  • nb_elements โ€” how many elements are chilling in the buffer
  • scale โ€” the scale factor for the conversion
  • zero_point โ€” the zero point for the conversion

Returns

  • 0, Success. ๐ŸŽ€
  • < 0, error code on failure ๐Ÿ˜ญ

๐Ÿ’… rte_ml_io_float32_to_uint32

__rte_experimental int rte_ml_io_float32_to_uint32 (const void * fp32, void * ui32, uint64_t nb_elements, float scale, uint32_t zero_point)

Take a whole buffer of single precision floating point (float32) numbers and convert them into unsigned 32-bit integer (UINT32) format. Glow up, but in integers โœจ

Parameters

  • fp32 โ€” input buffer holding the float32 numbers, size equal to (nb_elements * 4) bytes
  • ui32 โ€” output buffer to store the UINT32 numbers, size equal to (nb_elements * 4) bytes
  • nb_elements โ€” Number of elements in the buffer.
  • scale โ€” Scale factor for conversion.
  • zero_point โ€” Zero point for conversion.

Returns

  • 0, Success.
  • < 0, Error code on failure.

๐Ÿฆ‹ rte_ml_io_uint32_to_float32

__rte_experimental int rte_ml_io_uint32_to_float32 (const void * ui32, void * fp32, uint64_t nb_elements, float scale, uint32_t zero_point)

The reverse glow up, bestie โ€” buffer full of unsigned 32-bit integer (UINT32) numbers goes in, single precision floating point (float32) comes out ๐Ÿ’œ

Parameters

  • ui32 โ€” input buffer holding the UINT32 numbers, size equal to (nb_elements * 4) bytes
  • fp32 โ€” output buffer to store the float32 numbers, size equal to (nb_elements * 4) bytes
  • nb_elements โ€” Number of elements in the buffer.
  • scale โ€” Scale factor for conversion.
  • zero_point โ€” Zero point for conversion.

Returns

  • 0, Success.
  • < 0, Error code on failure.

๐ŸŒˆ rte_ml_io_float32_to_int64

__rte_experimental int rte_ml_io_float32_to_int64 (const void * fp32, void * i64, uint64_t nb_elements, float scale, int64_t zero_point)

float32 in, signed 64-bit integer (INT64) out. Big numbers only, no cap fr fr ๐Ÿ”ฅ

Parameters

  • fp32 โ€” input buffer holding the float32 numbers, size equal to (nb_elements * 4) bytes
  • i64 โ€” output buffer to store the INT64 numbers, size equal to (nb_elements * 4) bytes
  • nb_elements โ€” Number of elements in the buffer.
  • scale โ€” Scale factor for conversion.
  • zero_point โ€” Zero point for conversion.

Returns

  • 0, Success.
  • < 0, Error code on failure.

๐Ÿงš rte_ml_io_int64_to_float32

__rte_experimental int rte_ml_io_int64_to_float32 (const void * i64, void * fp32, uint64_t nb_elements, float scale, int64_t zero_point)

Signed 64-bit integer (INT64) numbers go in, single precision floating point (float32) comes out. it's giving โœจprecisionโœจ

Parameters

  • i64 โ€” input buffer holding the INT64 numbers, size equal to (nb_elements * 4) bytes
  • fp32 โ€” output buffer to store the float32 numbers, size equal to (nb_elements * 4) bytes
  • nb_elements โ€” Number of elements in the buffer.
  • scale โ€” Scale factor for conversion.
  • zero_point โ€” Zero point for conversion.

Returns

  • 0, Success.
  • < 0, Error code on failure.

๐Ÿ“ rte_ml_io_float32_to_uint64

__rte_experimental int rte_ml_io_float32_to_uint64 (const void * fp32, void * ui64, uint64_t nb_elements, float scale, uint64_t zero_point)

float32 โ†’ unsigned 64-bit integer (UINT64). Same energy as the other 64-bit one but this time we're staying positive ๐Ÿซถ

Parameters

  • fp32 โ€” input buffer holding the float32 numbers, size equal to (nb_elements * 4) bytes
  • ui64 โ€” output buffer to store the UINT64 numbers, size equal to (nb_elements * 4) bytes
  • nb_elements โ€” Number of elements in the buffer.
  • scale โ€” Scale factor for conversion.
  • zero_point โ€” Zero point for conversion.

Returns

  • 0, Success.
  • < 0, Error code on failure.

๐Ÿ‘‘ rte_ml_io_uint64_to_float32

__rte_experimental int rte_ml_io_uint64_to_float32 (const void * ui64, void * fp32, uint64_t nb_elements, float scale, uint64_t zero_point)

Unsigned 64-bit integer (UINT64) buffer in, single precision floating point (float32) buffer out. iconic behaviour honestly ๐Ÿ’…

Parameters

  • ui64 โ€” input buffer holding the UINT64 numbers, size equal to (nb_elements * 4) bytes
  • fp32 โ€” output buffer to store the float32 numbers, size equal to (nb_elements * 4) bytes
  • nb_elements โ€” Number of elements in the buffer.
  • scale โ€” Scale factor for conversion.
  • zero_point โ€” Zero point for conversion.

Returns

  • 0, Success.
  • < 0, Error code on failure.

๐Ÿ’– rte_ml_io_float32_to_float16

__rte_experimental int rte_ml_io_float32_to_float16 (const void * fp32, void * fp16, uint64_t nb_elements)

Squish single precision floating point (float32) down into half precision floating point (FP16). Smaller. Cuter. Still floating point ๐ŸŽ€

Parameters

  • fp32 โ€” input buffer holding the float32 numbers, size equal to (nb_elements * 4) bytes
  • fp16 โ€” output buffer to store the float16 numbers, size equal to (nb_elements * 2) bytes
  • nb_elements โ€” Number of elements in the buffer.

Returns

  • 0, Success.
  • < 0, Error code on failure.

๐ŸŒธ rte_ml_io_float16_to_float32

__rte_experimental int rte_ml_io_float16_to_float32 (const void * fp16, void * fp32, uint64_t nb_elements)

Half precision floating point (FP16) in, single precision floating point (float32) out. Un-squishing the squish ๐Ÿฆ‹

Parameters

  • fp16 โ€” input buffer holding the float16 numbers, size equal to (nb_elements * 2) bytes
  • fp32 โ€” output buffer to store the float32 numbers, size equal to (nb_elements * 4) bytes
  • nb_elements โ€” Number of elements in the buffer.

Returns

  • 0, Success.
  • < 0, Error code on failure.

โญ rte_ml_io_float32_to_bfloat16

__rte_experimental int rte_ml_io_float32_to_bfloat16 (const void * fp32, void * bf16, uint64_t nb_elements)

float32 โ†’ brain floating point (bfloat16). Yes bestie, it's an actual format, and yes it's as unhinged as it sounds ๐Ÿ’€

Parameters

  • fp32 โ€” input buffer holding the float32 numbers, size equal to (nb_elements * 4) bytes
  • bf16 โ€” output buffer to store the bfloat16 numbers, size equal to (nb_elements * 2) bytes
  • nb_elements โ€” Number of elements in the buffer.

Returns

  • 0, Success.
  • < 0, Error code on failure.

๐Ÿ”ฅ rte_ml_io_bfloat16_to_float32

__rte_experimental int rte_ml_io_bfloat16_to_float32 (const void * bf16, void * fp32, uint64_t nb_elements)

Brain floating point (bfloat16) in, single precision floating point (float32) out. Bringing the brain cells back up to full size ๐Ÿง โœจ

Parameters

  • bf16 โ€” input buffer holding the bfloat16 numbers, size equal to (nb_elements * 2) bytes
  • fp32 โ€” output buffer to store the float32 numbers, size equal to (nb_elements * 4) bytes
  • nb_elements โ€” Number of elements in the buffer.

Returns

  • 0, Success.
  • < 0, Error code on failure.

๐ŸŽ€ rte_ml_io_quantize

__rte_experimental int rte_ml_io_quantize (int16_t dev_id, uint16_t model_id, struct rte_ml_buff_seg ** dbuffer, struct rte_ml_buff_seg ** qbuffer)

Quantize input data, bestie ๐Ÿ“‰

Quantization converts data from higher precision types to lower precision types so the model execution gets better throughput and efficiency, with only minimal loss of accuracy. The types of dequantized data and quantized data are specified by the model โ€” so that's the model's call, not yours, don't fight it ๐Ÿ’…

Parameters

  • dev_id โ€” The identifier of the device.
  • model_id โ€” Identifier for the model
  • dbuffer โ€” Address of dequantized input data
  • qbuffer โ€” Address of quantized input data

Returns

  • Returns 0 on success
  • Returns negative value on failure

๐Ÿ’œ rte_ml_io_dequantize

__rte_experimental int rte_ml_io_dequantize (int16_t dev_id, uint16_t model_id, struct rte_ml_buff_seg ** qbuffer, struct rte_ml_buff_seg ** dbuffer)

Dequantize output data ๐Ÿ“ˆ

Dequantization converts data from a lower precision type to a higher precision type. The types of quantized data and dequantized data are both specified by the model ๐Ÿซถ

Parameters

  • dev_id โ€” The identifier of the device.
  • model_id โ€” Identifier for the model
  • qbuffer โ€” Address of quantized output data
  • dbuffer โ€” Address of dequantized output data

Returns

  • Returns 0 on success
  • Returns negative value on failure

๐ŸŒˆ rte_ml_op_pool_create

__rte_experimental struct rte_mempool * rte_ml_op_pool_create (const char * name, unsigned int nb_elts, unsigned int cache_size, uint16_t user_size, int socket_id)

Create an ML operation pool ๐ŸŠโ€โ™€๏ธโœจ

Parameters

  • name โ€” ML operations pool name
  • nb_elts โ€” Number of elements in pool
  • cache_size โ€” Number of elements to cache on lcore, see rte_mempool_create for further details about cache size
  • user_size โ€” Size of private data to allocate for user with each operation
  • socket_id โ€” Socket to identifier allocate memory on

Returns

  • On success pointer to mempool
  • On failure NULL

๐Ÿค— rte_ml_op_pool_free

__rte_experimental void rte_ml_op_pool_free (struct rte_mempool * mempool)

Free an ML operation pool ๐Ÿซถ bye bestie

Parameters

  • mempool โ€” A pointer to the mempool structure. If NULL then, the function does nothing.

๐Ÿ’ซ Author

Generated automatically by Doxygen for DPDK from the source code ๐Ÿงš


okay that's a wrap on rte_mldev.h(3), bestie โ€” this was Version 25.11.3 of the page, straight out of the DPDK source tree, and honestly? iconic. go build something unhinged with it ๐Ÿ’…๐ŸŽ€๐Ÿ’–

๐Ÿ“ฆ where this page comes from