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_infostruct rte_ml_dev_configstruct rte_ml_dev_qp_confstruct rte_ml_buff_segstruct rte_ml_opstruct rte_ml_op_errorstruct rte_ml_dev_statsstruct rte_ml_dev_xstats_mapstruct rte_ml_model_paramsstruct rte_ml_io_infostruct 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 fighterenum 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_maxbeing 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 thisdev_ideven 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 intodev_info__rte_experimental int rte_ml_dev_configure (int16_t dev_id, const struct rte_ml_dev_config *config)โ set the device up withconfig__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 intoerror__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 whatevermode, for whatevermodel_id, intoxstats_mapofsize__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 itsnameand get itsstat_idandvalue__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 fornb_idsstat 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 intofd__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 fromparams, get itsmodel_idback__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 intomodel_info__rte_experimental int rte_ml_model_params_update (int16_t dev_id, uint16_t model_id, void *buffer)โ swap the model's params usingbuffer__rte_experimental int rte_ml_io_float32_to_int8 (const void *fp32, void *i8, uint64_t nb_elements, float scale, int8_t zero_point)โ convertfp32โi8,nb_elementsat a time, withscaleandzero_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 dequantizeddbufferand quantize it intoqbufferfor 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 quantizedqbufferback intodbuffer__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 aname,nb_elts,cache_size,user_size, andsocket_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 invokerte_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 integerRTE_ML_IO_TYPE_UINT8โ 8-bit unsigned integerRTE_ML_IO_TYPE_INT16โ 16-bit integerRTE_ML_IO_TYPE_UINT16โ 16-bit unsigned integerRTE_ML_IO_TYPE_INT32โ 32-bit integerRTE_ML_IO_TYPE_UINT32โ 32-bit unsigned integerRTE_ML_IO_TYPE_INT64โ 32-bit integerRTE_ML_IO_TYPE_UINT64โ 32-bit unsigned integerRTE_ML_IO_TYPE_FP8โ 8-bit floating point numberRTE_ML_IO_TYPE_FP16โ IEEE 754 16-bit floating point numberRTE_ML_IO_TYPE_FP32โ IEEE 754 32-bit floating point numberRTE_ML_IO_TYPE_BFLOAT16โ 16-bit brain floating point number.
Definition at line 875 of file rte_mldev.h.
Okay bestie, not me noticing thatRTE_ML_IO_TYPE_INT64says "32-bit integer" andRTE_ML_IO_TYPE_UINT64says "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 torte_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 torte_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
0on success,-rte_errnootherwise:ENOMEMif out of memoryEINVALif 0 sizeEBUSYif 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
0if device state is not in ready state.1if 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
0If 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 typerte_ml_dev_infoto 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 torte_ml_dev_configure().qp_confโ the pointer to the configuration data to be used for the queue pair.socket_idโ thesocket_idargument is the socket identifier in case of NUMA. The value can beSOCKET_ID_ANYif 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:
0on successfully closing device. Bye bestie. ๐<0on 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 torte_ml_dev_configure.opsโ the address of an array ofnb_opspointers torte_ml_opstructures 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 torte_ml_dev_configure().opsโ the address of an array of pointers torte_ml_opstructures that must be large enough to storenb_opspointers 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 identifieropโ Handle of ML operationerrorโ Address of structurerte_ml_op_errorto be filled
Returns:
- Returns
0on 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:
0on 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 leastsizein capacity. If set toNULL, function returns required capacity. The id values returned can be passed torte_ml_dev_xstats_getto select statistics.sizeโ Capacity ofxstats_names(number ofxstats_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:
-ENODEVfor invaliddev_id.-EINVALfor invalid mode, model parameters.-ENOTSUPif 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 usingrte_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:
-EINVALif stat not found,-ENOTSUPif 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 fromrte_ml_dev_xstats_names_get(), or by usingrte_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
valuesarray. Slay! ๐ - Negative value on error:
-ENODEVfor invaliddev_id.-EINVALfor invalid mode, model id or stat id parameters.-ENOTSUPif 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.0and 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'sNULL, everything selected bymodegets reset. if it's notNULL, it has to point to an array of at leastnb_idsin size. no shortcuts.nb_idsโ how many ids you actually stuffed into that array. and heads up: this gets ignored whenidsisNULL(yes, the original saysidshere, we don't make the rules ๐).
Returns like:
- Zero โ stats reset, slayed, done. โจ
- Negative value โ
-EINVALif your parameters are invalid, or-ENOTSUPif 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 createdmodel_infoโ pointer to a model info structure
Returns
- Returns
0on 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 createdbufferโ pointer to the model weights and bias buffer. Size of the buffer is equal towb_sizereturned inrte_ml_model_info.
Returns
- Returns
0on 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 withINT32numbers, and the way the size math works is size of buffer ==nb_elements * 4bytes ๐ซถfp32โ output buffer where thefloat32numbers land, also sizednb_elements * 4bytes ๐nb_elementsโ how many elements are chilling in the bufferscaleโ the scale factor for the conversionzero_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 thefloat32numbers, size equal to(nb_elements * 4)bytesui32โ output buffer to store theUINT32numbers, size equal to(nb_elements * 4)bytesnb_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 theUINT32numbers, size equal to(nb_elements * 4)bytesfp32โ output buffer to store thefloat32numbers, size equal to(nb_elements * 4)bytesnb_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 thefloat32numbers, size equal to(nb_elements * 4)bytesi64โ output buffer to store theINT64numbers, size equal to(nb_elements * 4)bytesnb_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 theINT64numbers, size equal to(nb_elements * 4)bytesfp32โ output buffer to store thefloat32numbers, size equal to(nb_elements * 4)bytesnb_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 thefloat32numbers, size equal to(nb_elements * 4)bytesui64โ output buffer to store theUINT64numbers, size equal to(nb_elements * 4)bytesnb_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 theUINT64numbers, size equal to(nb_elements * 4)bytesfp32โ output buffer to store thefloat32numbers, size equal to(nb_elements * 4)bytesnb_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 thefloat32numbers, size equal to(nb_elements * 4)bytesfp16โ output buffer to store thefloat16numbers, size equal to(nb_elements * 2)bytesnb_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 thefloat16numbers, size equal to(nb_elements * 2)bytesfp32โ output buffer to store thefloat32numbers, size equal to(nb_elements * 4)bytesnb_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 thefloat32numbers, size equal to(nb_elements * 4)bytesbf16โ output buffer to store thebfloat16numbers, size equal to(nb_elements * 2)bytesnb_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 thebfloat16numbers, size equal to(nb_elements * 2)bytesfp32โ output buffer to store thefloat32numbers, size equal to(nb_elements * 4)bytesnb_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 modeldbufferโ Address of dequantized input dataqbufferโ Address of quantized input data
Returns
- Returns
0on 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 modelqbufferโ Address of quantized output datadbufferโ Address of dequantized output data
Returns
- Returns
0on 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 namenb_eltsโ Number of elements in poolcache_sizeโ Number of elements to cache on lcore, seerte_mempool_createfor further details about cache sizeuser_sizeโ Size of private data to allocate for user with each operationsocket_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. IfNULLthen, 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
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 ยท BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms