mldev: introduce machine learning device library
Subsystems (2)
cover mldev: introduce machine learning device library
From: Jerin Jacob <[email protected]>
Machine learning inference library
==================================
Definition of machine learning inference
----------------------------------------
Inference in machine learning is the process of making an output prediction based on new input data using a pre-trained machine learning model.
The scope of the RFC would include only inferencing with pre-trained machine learning models, training and building/compiling the ML models is out of scope for this RFC or DPDK mldev API. Use existing machine learning compiler frameworks for model creation.
Motivation for the new library
------------------------------
Multiple semiconductor vendors are offering accelerator products such as DPU (often called Smart-NIC), FPGA, GPU, etc., which have ML inferencing capabilities integrated as part of the product. Use of ML inferencing is increasing in the domain of packet processing for flow classification, intrusion, malware and anomaly detection.
Lack of inferencing support through DPDK APIs will involve complexities and increased latency from moving data across frameworks (i.e, dataplane to non dataplane ML frameworks and vice-versa). Having a standardized DPDK APIs for ML inferencing would enable the dataplane solutions to harness the benefit of inline inferencing supported by the hardware.
Contents of RFC
---------------
This RFC attempts to define standard APIs for:
1) Discovery of ML capabilities (e.g., device specific features) in a vendor independent fashion
2) Definition of functions to handle ML devices, which includes probing, initialization and termination of the devices.
3) Definition of functions to handle ML models used to perform inference operations.
4) Definition of function to handle quantize and dequantize operations
Roadmap
-------
1) Address the comments for this RFC.
2) Common code for mldev
3) SW mldev driver based on TVM (https://tvm.apache.org/)
4) HW mldev driver for cn10k
3) Add app/test-mldev application similar to other device class tests
Machine learning library framework
----------------------------------
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()
| +-------------+ |<------- 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 ML device API for running inferences using a pre-trained ML model.
ML Model: An ML model is an algorithm trained over a dataset. A model consists of procedure/algorithm and data/pattern required to make predictions on live data. Once the model is created and trained outside of the DPDK scope, the model can be loaded via rte_ml_model_load() and then start it using rte_ml_model_start() API. The rte_ml_model_params_update() can be used to update the model parameters such as weight and bias without unloading the model using rte_ml_model_unload().
ML Inference: ML inference is the process of feeding data to the model via rte_ml_enqueue_burst() API and use rte_ml_dequeue_burst() API to get the calculated outputs/predictions from the started model.
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 setup a device designated by its device identifier must be invoked in the following order:
- 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. Application needs to invoke the ML model API in the following order before queueing inference jobs.
- rte_ml_model_load()
- rte_ml_model_start()
The rte_ml_model_info() API is provided to retrieve the information related to the model. The information would include the shape and type of input and output required for the inference.
Data quantization and dequantization is one of the main aspects in ML domain. This involves conversion of 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.
Two utility APIs rte_ml_io_input_size_get() and rte_ml_io_output_size_get() can used to get the size of quantized and de-quantized multi-batch input and output buffers.
User can optionally update the model parameters with rte_ml_model_params_update() after invoking rte_ml_model_stop() API on a given model ID.
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 application must stop the device using rte_ml_dev_stop() API. Likewise, if model parameters need to be updated then the application must call rte_ml_model_stop() followed by 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.
Once the device is in the start state after invoking rte_ml_dev_start() API and the model is in start state after invoking rte_ml_model_start() API, then the application can call rte_ml_enqueue() and rte_ml_dequeue() API on the destined device and model ID.
Finally, an application can close an ML device by invoking the rte_ml_dev_close() function.
Typical application utilisation of the ML API will follow the following programming flow.
- rte_ml_dev_configure()
- rte_ml_dev_queue_pair_setup()
- rte_ml_model_load()
- rte_ml_model_start()
- rte_ml_model_info()
- rte_ml_dev_start()
- 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 to not be 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 same queue pair. Of course, this function can be invoked in parallel by different logical core on different queue pair.
It is the responsibility of the user application to enforce this rule.
Example application usage for ML inferencing
--------------------------------------------
This example application is to demonstrate the programming model of ML device library. This example omits the error checks to simplify the application. This example also assumes that the input data received is quantized and output expected is also quantized. In order to handle non-quantized inputs and outputs, users can invoke rte_ml_io_quantize() or rte_ml_io_dequantize() for data type conversions.
#define ML_MODEL_NAME "model"
#define IO_MZ "io_mz"
struct app_ctx {
char model_file[PATH_MAX];
char inp_file[PATH_MAX];
char out_file[PATH_MAX];
struct rte_ml_model_params params;
struct rte_ml_model_info info;
uint16_t id;
uint64_t input_size;
uint64_t output_size;
uint8_t *input_buffer;
uint8_t *output_buffer;
} __rte_cache_aligned;struct app_ctx ctx;
static intparse_args(int argc, char **argv)
{
int opt, option_index;
static struct option lgopts[] = {{"model", required_argument, NULL, 'm'},
{"input", required_argument, NULL, 'i'},
{"output", required_argument, NULL, 'o'},
{NULL, 0, NULL, 0}};
while ((opt = getopt_long(argc, argv, "m:i:o:", lgopts, &option_index)) != EOF)
switch (opt) {
case 'm':
strncpy(ctx.model_file, optarg, PATH_MAX - 1);
break;
case 'i':
strncpy(ctx.inp_file, optarg, PATH_MAX - 1);
break;
case 'o':
strncpy(ctx.out_file, optarg, PATH_MAX - 1);
break;
default:
return -1;
}
return 0;
}intmain(int argc, char **argv)
{
struct rte_ml_dev_qp_conf qp_conf;
struct rte_ml_dev_config config;
struct rte_ml_dev_info dev_info;
const struct rte_memzone *mz;
struct rte_mempool *op_pool;
struct rte_ml_op *op_enq;
struct rte_ml_op *op_deq;
FILE *fp;
int rc;
/* Initialize EAL */
rc = rte_eal_init(argc, argv);
if (rc < 0)
rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n");
argc -= rc;
argv += rc;
/* Parse application arguments (after the EAL args) */
if (parse_args(argc, argv) < 0)
rte_exit(EXIT_FAILURE, "Invalid application arguments\n");
/* Step 1: Check for ML devices */
if (rte_ml_dev_count() <= 0)
rte_exit(EXIT_FAILURE, "Failed to find ML devices\n");
/* Step 2: Get device info */
if (rte_ml_dev_info_get(0, &dev_info) != 0)
rte_exit(EXIT_FAILURE, "Failed to get device info\n");
/* Step 3: Configure ML device, use device 0 */
config.socket_id = rte_ml_dev_socket_id(0);
config.max_nb_models = dev_info.max_models;
config.nb_queue_pairs = dev_info.max_queue_pairs;
if (rte_ml_dev_configure(0, &config) != 0)
rte_exit(EXIT_FAILURE, "Device configuration failed\n");
/* Step 4: Setup queue pairs, used qp_id = 0 */
qp_conf.nb_desc = 1;
if (rte_ml_dev_queue_pair_setup(0, 0, &qp_conf, config.socket_id) != 0)
rte_exit(EXIT_FAILURE, "Queue-pair setup failed\n");
/* Step 5: Start device */
if (rte_ml_dev_start(0) != 0)
rte_exit(EXIT_FAILURE, "Device start failed\n");
/* Step 6: Read model data and update load params structure */
fp = fopen(ctx.model_file, "r+");
if (fp == NULL)
rte_exit(EXIT_FAILURE, "Failed to open model file\n");
fseek(fp, 0, SEEK_END);
ctx.params.size = ftell(fp);
fseek(fp, 0, SEEK_SET);
ctx.params.addr = malloc(ctx.params.size);
if (fread(ctx.params.addr, 1, ctx.params.size, fp) != ctx.params.size){
fclose(fp);
rte_exit(EXIT_FAILURE, "Failed to read model\n");
}
fclose(fp);
strcpy(ctx.params.name, ML_MODEL_NAME);
/* Step 7: Load the model */
if (rte_ml_model_load(0, &ctx.params, &ctx.id) != 0)
rte_exit(EXIT_FAILURE, "Failed to load model\n");
free(ctx.params.addr);
/* Step 8: Start the model */
if (rte_ml_model_start(0, ctx.id) != 0)
rte_exit(EXIT_FAILURE, "Failed to start model\n");
/* Step 9: Allocate buffers for quantized input and output */
/* Get model information */
if (rte_ml_model_info_get(0, ctx.id, &ctx.info) != 0)
rte_exit(EXIT_FAILURE, "Failed to get model info\n");
/* Get the buffer size for input and output */
rte_ml_io_input_size_get(0, ctx.id, ctx.info.batch_size, &ctx.input_size, NULL);
rte_ml_io_output_size_get(0, ctx.id, ctx.info.batch_size, &ctx.output_size, NULL);
mz = rte_memzone_reserve(IO_MZ, ctx.input_size + ctx.output_size, config.socket_id, 0);
if (mz == NULL)
rte_exit(EXIT_FAILURE, "Failed to create IO memzone\n");
ctx.input_buffer = mz->addr;
ctx.output_buffer = ctx.input_buffer + ctx.input_size;
/* Step 10: Fill the input data */
fp = fopen(ctx.inp_file, "r+");
if (fp == NULL)
rte_exit(EXIT_FAILURE, "Failed to open input file\n");
if (fread(ctx.input_buffer, 1, ctx.input_size, fp) != ctx.input_size) {
fclose(fp);
rte_exit(EXIT_FAILURE, "Failed to read input file\n");
}
fclose(fp);
/* Step 11: Create ML op mempool */
op_pool = rte_ml_op_pool_create("ml_op_pool", 1, 0, 0, config.socket_id);
if (op_pool == NULL)
rte_exit(EXIT_FAILURE, "Failed to create op pool\n");
/* Step 12: Form an ML op */
rte_mempool_get_bulk(op_pool, (void *)op_enq, 1);
op_enq->model_id = ctx.id;
op_enq->nb_batches = ctx.info.batch_size;
op_enq->mempool = op_pool;
op_enq->input.addr = ctx.input_buffer;
op_enq->input.length = ctx.input_size;
op_enq->input.next = NULL;
op_enq->output.addr = ctx.output_buffer;
op_enq->output.length = ctx.output_size;
op_enq->output.next = NULL;
/* Step 13: Enqueue jobs */
rte_ml_enqueue_burst(0, 0, &op_enq, 1);
/* Step 14: Dequeue jobs and release op pool */
while (rte_ml_dequeue_burst(0, 0, &op_deq, 1) != 1)
;
/* Step 15: Write output */
fp = fopen(ctx.out_file, "w+");
if (fp == NULL)
rte_exit(EXIT_FAILURE, "Failed to open output file\n");
fwrite(ctx.output_buffer, 1, ctx.output_size, fp);
fclose(fp);
/* Step 16: Clean up */
/* Stop ML model */
rte_ml_model_stop(0, ctx.id);
/* Unload ML model */
rte_ml_model_unload(0, ctx.id);
/* Free input/output memory */
rte_memzone_free(rte_memzone_lookup(IO_MZ));
/* Free the ml op back to pool */
rte_mempool_put_bulk(op_pool, (void *)op_deq, 1);
/* Free ml op pool */
rte_mempool_free(op_pool);
/* Stop the device */
rte_ml_dev_stop(0);
rte_ml_dev_close(0);
rte_eal_cleanup();
return 0;
}Jerin Jacob (1):
mldev: introduce machine learning device library
config/rte_config.h | 3 + doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/mldev.rst | 164 +++++ lib/eal/common/eal_common_log.c | 1 + lib/eal/include/rte_log.h | 1 + lib/meson.build | 1 + lib/mldev/meson.build | 12 + lib/mldev/rte_mldev.c | 5 + lib/mldev/rte_mldev.h | 1081 +++++++++++++++++++++++++++++++ lib/mldev/version.map | 5 + 12 files changed, 1276 insertions(+) create mode 100644 doc/guides/prog_guide/mldev.rst create mode 100644 lib/mldev/meson.build create mode 100644 lib/mldev/rte_mldev.c create mode 100644 lib/mldev/rte_mldev.h create mode 100644 lib/mldev/version.map
Signature · 1 line
2.37.1
RFC PATCH 1/1 mldev: introduce machine learning device library
From: Jerin Jacob <[email protected]>
Add mldev API specification to standardize and use the machine learning device and inference operations in vendor neutral way.
Following operations are abstracted through APIs
- ML device capability probe
- ML device configuration
- ML device queue pair configuration
- ML device state management
- ML device stat/xstat operations
- ML model load/unload/start/stop operations
- ML model information probe
- ML IO operations to find size for input and output buffers
- ML quantize and dequantize operations
- ML ops pool creation and free operations
- ML device enqueue/dequeue fastpath interference operations
--- config/rte_config.h | 3 + doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/mldev.rst | 164 +++++ lib/eal/common/eal_common_log.c | 1 + lib/eal/include/rte_log.h | 1 + lib/meson.build | 1 + lib/mldev/meson.build | 12 + lib/mldev/rte_mldev.c | 5 + lib/mldev/rte_mldev.h | 1081 +++++++++++++++++++++++++++++++ lib/mldev/version.map | 5 + 12 files changed, 1276 insertions(+) create mode 100644 doc/guides/prog_guide/mldev.rst create mode 100644 lib/mldev/meson.build create mode 100644 lib/mldev/rte_mldev.c create mode 100644 lib/mldev/rte_mldev.h create mode 100644 lib/mldev/version.map
config/rte_config.h +3 -0
@@ -81,6 +81,9 @@/* rawdev defines */ #define RTE_RAWDEV_MAX_DEVS 64 +/* mldev defines */ +#define RTE_MLDEV_MAX_DEVS 64 +/* ip_fragmentation defines */ #define RTE_LIBRTE_IP_FRAG_MAX_FRAG 8// RTE_LIBRTE_IP_FRAG_TBL_STAT is not set
doc/api/doxy-api-index.md +1 -0
@@ -22,6 +22,7 @@ The public API headers are grouped by topics: [compress](@ref rte_comp.h), [regexdev](@ref rte_regexdev.h), [dmadev](@ref rte_dmadev.h), + [mldev](@ref rte_mldev.h), [eventdev](@ref rte_eventdev.h), [event_eth_rx_adapter](@ref rte_event_eth_rx_adapter.h), [event_eth_tx_adapter](@ref rte_event_eth_tx_adapter.h),
doc/api/doxy-api.conf.in +1 -0
@@ -59,6 +59,7 @@ INPUT = @TOPDIR@/doc/api/doxy-api-index.md \ @TOPDIR@/lib/mempool \ @TOPDIR@/lib/meter \ @TOPDIR@/lib/metrics \ + @TOPDIR@/lib/mldev \ @TOPDIR@/lib/node \ @TOPDIR@/lib/net \ @TOPDIR@/lib/pcapng \
doc/guides/prog_guide/index.rst +1 -0
@@ -30,6 +30,7 @@ Programmer's Guide regexdev dmadev gpudev + mldev rte_security rawdev link_bonding_poll_mode_drv_lib
doc/guides/prog_guide/mldev.rst new file +164 -0
164 lines not on this page · raw message
lib/eal/common/eal_common_log.c +1 -0
@@ -369,6 +369,7 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EFD, "lib.efd"}, {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, {RTE_LOGTYPE_GSO, "lib.gso"}, + {RTE_LOGTYPE_MLDEV, "lib.mldev"}, {RTE_LOGTYPE_USER1, "user1"}, {RTE_LOGTYPE_USER2, "user2"}, {RTE_LOGTYPE_USER3, "user3"},
lib/eal/include/rte_log.h +1 -0
@@ -48,6 +48,7 @@ extern "C" {#define RTE_LOGTYPE_EFD 18/**< Log related to EFD. */ #define RTE_LOGTYPE_EVENTDEV 19/**< Log related to eventdev. */ #define RTE_LOGTYPE_GSO 20/**< Log related to GSO. */ +#define RTE_LOGTYPE_MLDEV 21/**< Log related to mldev. */ /* these log types can be used in an application */ #define RTE_LOGTYPE_USER1 24/**< User-defined log type 1. */
lib/meson.build +1 -0
@@ -63,6 +63,7 @@ libraries = [ 'flow_classify', # flow_classify lib depends on pkt framework table lib 'graph', 'node', + 'mldev' ] optional_libs = [
lib/mldev/meson.build new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2022 Marvell. + +sources = files( + 'rte_mldev.c', +) + +headers = files( + 'rte_mldev.h', +) + +deps += ['mempool']
lib/mldev/rte_mldev.c new file +5 -0
@@ -0,0 +1,5 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 Marvell. +*/ + +#include <rte_mldev.h>
lib/mldev/rte_mldev.h new file +1081 -0
1,081 lines not on this page · raw message
lib/mldev/version.map new file +5 -0
@@ -0,0 +1,5 @@ +EXPERIMENTAL { + + local: *; +}; +
Signature · 1 line
2.37.1
cover mldev: introduce machine learning device library
From: Jerin Jacob <[email protected]>
Machine learning inference library
==================================
Definition of machine learning inference
----------------------------------------
Inference in machine learning is the process of making an output prediction based on new input data using a pre-trained machine learning model.
The scope of the RFC would include only inferencing with pre-trained machine learning models, training and building/compiling the ML models is out of scope for this RFC or DPDK mldev API. Use existing machine learning compiler frameworks for model creation.
Motivation for the new library
------------------------------
Multiple semiconductor vendors are offering accelerator products such as DPU (often called Smart-NIC), FPGA, GPU, etc., which have ML inferencing capabilities integrated as part of the product. Use of ML inferencing is increasing in the domain of packet processing for flow classification, intrusion, malware and anomaly detection.
Lack of inferencing support through DPDK APIs will involve complexities and increased latency from moving data across frameworks (i.e, dataplane to non dataplane ML frameworks and vice-versa). Having a standardized DPDK APIs for ML inferencing would enable the dataplane solutions to harness the benefit of inline inferencing supported by the hardware.
Contents
---------------
A) API specification for:
1) Discovery of ML capabilities (e.g., device specific features) in a vendor independent fashion
2) Definition of functions to handle ML devices, which includes probing, initialization and termination of the devices.
3) Definition of functions to handle ML models used to perform inference operations.
4) Definition of function to handle quantize and dequantize operations
B) Common code for above specification
Roadmap
-------
1) SW mldev driver based on TVM (https://tvm.apache.org/)
2) HW mldev driver for cn10k
3) Add app/test-mldev application similar to other device class tests
rfc..v1:
- Added programmer guide documentation
- Added implementation for common code
Machine learning library framework
----------------------------------
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()
| +-------------+ |<------- 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 ML device API for running inferences using a pre-trained ML model.
ML Model: An ML model is an algorithm trained over a dataset. A model consists of procedure/algorithm and data/pattern required to make predictions on live data. Once the model is created and trained outside of the DPDK scope, the model can be loaded via rte_ml_model_load() and then start it using rte_ml_model_start() API. The rte_ml_model_params_update() can be used to update the model parameters such as weight and bias without unloading the model using rte_ml_model_unload().
ML Inference: ML inference is the process of feeding data to the model via rte_ml_enqueue_burst() API and use rte_ml_dequeue_burst() API to get the calculated outputs/predictions from the started model.
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 setup a device designated by its device identifier must be invoked in the following order:
- 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. Application needs to invoke the ML model API in the following order before queueing inference jobs.
- rte_ml_model_load()
- rte_ml_model_start()
The rte_ml_model_info() API is provided to retrieve the information related to the model. The information would include the shape and type of input and output required for the inference.
Data quantization and dequantization is one of the main aspects in ML domain. This involves conversion of 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.
Two utility APIs rte_ml_io_input_size_get() and rte_ml_io_output_size_get() can used to get the size of quantized and de-quantized multi-batch input and output buffers.
User can optionally update the model parameters with rte_ml_model_params_update() after invoking rte_ml_model_stop() API on a given model ID.
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 application must stop the device using rte_ml_dev_stop() API. Likewise, if model parameters need to be updated then the application must call rte_ml_model_stop() followed by 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.
Once the device is in the start state after invoking rte_ml_dev_start() API and the model is in start state after invoking rte_ml_model_start() API, then the application can call rte_ml_enqueue() and rte_ml_dequeue() API on the destined device and model ID.
Finally, an application can close an ML device by invoking the rte_ml_dev_close() function.
Typical application utilisation of the ML API will follow the following programming flow.
- rte_ml_dev_configure()
- rte_ml_dev_queue_pair_setup()
- rte_ml_model_load()
- rte_ml_model_start()
- rte_ml_model_info()
- rte_ml_dev_start()
- 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 to not be 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 same queue pair. Of course, this function can be invoked in parallel by different logical core on different queue pair.
It is the responsibility of the user application to enforce this rule.
Example application usage for ML inferencing
--------------------------------------------
This example application is to demonstrate the programming model of ML device library. This example omits the error checks to simplify the application. This example also assumes that the input data received is quantized and output expected is also quantized. In order to handle non-quantized inputs and outputs, users can invoke rte_ml_io_quantize() or rte_ml_io_dequantize() for data type conversions.
#define ML_MODEL_NAME "model"
#define IO_MZ "io_mz"
struct app_ctx {
char model_file[PATH_MAX];
char inp_file[PATH_MAX];
char out_file[PATH_MAX];
struct rte_ml_model_params params;
struct rte_ml_model_info info;
uint16_t id;
uint64_t input_size;
uint64_t output_size;
uint8_t *input_buffer;
uint8_t *output_buffer;
} __rte_cache_aligned;struct app_ctx ctx;
static intparse_args(int argc, char **argv)
{
int opt, option_index;
static struct option lgopts[] = {{"model", required_argument, NULL, 'm'},
{"input", required_argument, NULL, 'i'},
{"output", required_argument, NULL, 'o'},
{NULL, 0, NULL, 0}};
while ((opt = getopt_long(argc, argv, "m:i:o:", lgopts, &option_index)) != EOF)
switch (opt) {
case 'm':
strncpy(ctx.model_file, optarg, PATH_MAX - 1);
break;
case 'i':
strncpy(ctx.inp_file, optarg, PATH_MAX - 1);
break;
case 'o':
strncpy(ctx.out_file, optarg, PATH_MAX - 1);
break;
default:
return -1;
}
return 0;
}intmain(int argc, char **argv)
{
struct rte_ml_dev_qp_conf qp_conf;
struct rte_ml_dev_config config;
struct rte_ml_dev_info dev_info;
const struct rte_memzone *mz;
struct rte_mempool *op_pool;
struct rte_ml_op *op_enq;
struct rte_ml_op *op_deq;
FILE *fp;
int rc;
/* Initialize EAL */
rc = rte_eal_init(argc, argv);
if (rc < 0)
rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n");
argc -= rc;
argv += rc;
/* Parse application arguments (after the EAL args) */
if (parse_args(argc, argv) < 0)
rte_exit(EXIT_FAILURE, "Invalid application arguments\n");
/* Step 1: Check for ML devices */
if (rte_ml_dev_count() <= 0)
rte_exit(EXIT_FAILURE, "Failed to find ML devices\n");
/* Step 2: Get device info */
if (rte_ml_dev_info_get(0, &dev_info) != 0)
rte_exit(EXIT_FAILURE, "Failed to get device info\n");
/* Step 3: Configure ML device, use device 0 */
config.socket_id = rte_ml_dev_socket_id(0);
config.max_nb_models = dev_info.max_models;
config.nb_queue_pairs = dev_info.max_queue_pairs;
if (rte_ml_dev_configure(0, &config) != 0)
rte_exit(EXIT_FAILURE, "Device configuration failed\n");
/* Step 4: Setup queue pairs, used qp_id = 0 */
qp_conf.nb_desc = 1;
if (rte_ml_dev_queue_pair_setup(0, 0, &qp_conf, config.socket_id) != 0)
rte_exit(EXIT_FAILURE, "Queue-pair setup failed\n");
/* Step 5: Start device */
if (rte_ml_dev_start(0) != 0)
rte_exit(EXIT_FAILURE, "Device start failed\n");
/* Step 6: Read model data and update load params structure */
fp = fopen(ctx.model_file, "r+");
if (fp == NULL)
rte_exit(EXIT_FAILURE, "Failed to open model file\n");
fseek(fp, 0, SEEK_END);
ctx.params.size = ftell(fp);
fseek(fp, 0, SEEK_SET);
ctx.params.addr = malloc(ctx.params.size);
if (fread(ctx.params.addr, 1, ctx.params.size, fp) != ctx.params.size){
fclose(fp);
rte_exit(EXIT_FAILURE, "Failed to read model\n");
}
fclose(fp);
strcpy(ctx.params.name, ML_MODEL_NAME);
/* Step 7: Load the model */
if (rte_ml_model_load(0, &ctx.params, &ctx.id) != 0)
rte_exit(EXIT_FAILURE, "Failed to load model\n");
free(ctx.params.addr);
/* Step 8: Start the model */
if (rte_ml_model_start(0, ctx.id) != 0)
rte_exit(EXIT_FAILURE, "Failed to start model\n");
/* Step 9: Allocate buffers for quantized input and output */
/* Get model information */
if (rte_ml_model_info_get(0, ctx.id, &ctx.info) != 0)
rte_exit(EXIT_FAILURE, "Failed to get model info\n");
/* Get the buffer size for input and output */
rte_ml_io_input_size_get(0, ctx.id, ctx.info.batch_size, &ctx.input_size, NULL);
rte_ml_io_output_size_get(0, ctx.id, ctx.info.batch_size, &ctx.output_size, NULL);
mz = rte_memzone_reserve(IO_MZ, ctx.input_size + ctx.output_size, config.socket_id, 0);
if (mz == NULL)
rte_exit(EXIT_FAILURE, "Failed to create IO memzone\n");
ctx.input_buffer = mz->addr;
ctx.output_buffer = ctx.input_buffer + ctx.input_size;
/* Step 10: Fill the input data */
fp = fopen(ctx.inp_file, "r+");
if (fp == NULL)
rte_exit(EXIT_FAILURE, "Failed to open input file\n");
if (fread(ctx.input_buffer, 1, ctx.input_size, fp) != ctx.input_size) {
fclose(fp);
rte_exit(EXIT_FAILURE, "Failed to read input file\n");
}
fclose(fp);
/* Step 11: Create ML op mempool */
op_pool = rte_ml_op_pool_create("ml_op_pool", 1, 0, 0, config.socket_id);
if (op_pool == NULL)
rte_exit(EXIT_FAILURE, "Failed to create op pool\n");
/* Step 12: Form an ML op */
rte_mempool_get_bulk(op_pool, (void *)op_enq, 1);
op_enq->model_id = ctx.id;
op_enq->nb_batches = ctx.info.batch_size;
op_enq->mempool = op_pool;
op_enq->input.addr = ctx.input_buffer;
op_enq->input.length = ctx.input_size;
op_enq->input.next = NULL;
op_enq->output.addr = ctx.output_buffer;
op_enq->output.length = ctx.output_size;
op_enq->output.next = NULL;
/* Step 13: Enqueue jobs */
rte_ml_enqueue_burst(0, 0, &op_enq, 1);
/* Step 14: Dequeue jobs and release op pool */
while (rte_ml_dequeue_burst(0, 0, &op_deq, 1) != 1)
;
/* Step 15: Write output */
fp = fopen(ctx.out_file, "w+");
if (fp == NULL)
rte_exit(EXIT_FAILURE, "Failed to open output file\n");
fwrite(ctx.output_buffer, 1, ctx.output_size, fp);
fclose(fp);
/* Step 16: Clean up */
/* Stop ML model */
rte_ml_model_stop(0, ctx.id);
/* Unload ML model */
rte_ml_model_unload(0, ctx.id);
/* Free input/output memory */
rte_memzone_free(rte_memzone_lookup(IO_MZ));
/* Free the ml op back to pool */
rte_mempool_put_bulk(op_pool, (void *)op_deq, 1);
/* Free ml op pool */
rte_mempool_free(op_pool);
/* Stop the device */
rte_ml_dev_stop(0);
rte_ml_dev_close(0);
rte_eal_cleanup();
return 0;
}Jerin Jacob (1):
mldev: introduce machine learning device library
Srikanth Yalavarthi (11):
mldev: add PMD functions for ML device
mldev: support device handling functions
mldev: support device queue-pair setup
mldev: support handling ML models
mldev: support input and output data handling
mldev: support op pool and its operations
mldev: support inference enqueue and dequeue
mldev: support device statistics
mldev: support device extended statistics
mldev: support to retrieve error information
mldev: support to get debug info and test device
MAINTAINERS | 5 + config/rte_config.h | 3 + doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + doc/guides/prog_guide/img/mldev_flow.svg | 714 ++++++++++++++ doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/mldev.rst | 186 ++++ lib/eal/common/eal_common_log.c | 1 + lib/eal/include/rte_log.h | 1 + lib/meson.build | 1 + lib/mldev/meson.build | 27 + lib/mldev/rte_mldev.c | 901 ++++++++++++++++++ lib/mldev/rte_mldev.h | 1092 ++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 724 ++++++++++++++ lib/mldev/rte_mldev_pmd.c | 61 ++ lib/mldev/rte_mldev_pmd.h | 151 +++ lib/mldev/version.map | 49 + 17 files changed, 3919 insertions(+) create mode 100644 doc/guides/prog_guide/img/mldev_flow.svg create mode 100644 doc/guides/prog_guide/mldev.rst create mode 100644 lib/mldev/meson.build create mode 100644 lib/mldev/rte_mldev.c create mode 100644 lib/mldev/rte_mldev.h create mode 100644 lib/mldev/rte_mldev_core.h create mode 100644 lib/mldev/rte_mldev_pmd.c create mode 100644 lib/mldev/rte_mldev_pmd.h create mode 100644 lib/mldev/version.map
Signature · 1 line
2.38.1
PATCH 1/12 mldev: introduce machine learning device library
From: Jerin Jacob <[email protected]>
Add mldev API specification to standardize and use the machine learning device and inference operations in vendor neutral way.
Following operations are abstracted through APIs
- ML device capability probe
- ML device configuration
- ML device queue pair configuration
- ML device state management
- ML device stat/xstat operations
- ML model load/unload/start/stop operations
- ML model information probe
- ML IO operations to find size for input and output buffers
- ML quantize and dequantize operations
- ML ops pool creation and free operations
- ML device enqueue/dequeue fastpath interference operations
Also added programming guide.
--- MAINTAINERS | 5 + config/rte_config.h | 3 + doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + doc/guides/prog_guide/img/mldev_flow.svg | 714 ++++++++++++++ doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/mldev.rst | 186 ++++ lib/eal/common/eal_common_log.c | 1 + lib/eal/include/rte_log.h | 1 + lib/meson.build | 1 + lib/mldev/meson.build | 18 + lib/mldev/rte_mldev.c | 5 + lib/mldev/rte_mldev.h | 1092 ++++++++++++++++++++++ lib/mldev/version.map | 3 + 14 files changed, 2032 insertions(+) create mode 100644 doc/guides/prog_guide/img/mldev_flow.svg create mode 100644 doc/guides/prog_guide/mldev.rst create mode 100644 lib/mldev/meson.build create mode 100644 lib/mldev/rte_mldev.c create mode 100644 lib/mldev/rte_mldev.h create mode 100644 lib/mldev/version.map
MAINTAINERS +5 -0
@@ -534,6 +534,11 @@ F: drivers/raw/skeleton/ F: app/test/test_rawdev.c F: doc/guides/prog_guide/rawdev.rst +ML device API - EXPERIMENTAL +M: Srikanth Yalavarthi <[email protected]> +F: lib/mldev/ +F: doc/guides/prog_guide/mldev.rst + Memory Pool Drivers -------------------
config/rte_config.h +3 -0
@@ -83,6 +83,9 @@/* rawdev defines */ #define RTE_RAWDEV_MAX_DEVS 64 +/* mldev defines */ +#define RTE_MLDEV_MAX_DEVS 64 +/* ip_fragmentation defines */ #define RTE_LIBRTE_IP_FRAG_MAX_FRAG 8// RTE_LIBRTE_IP_FRAG_TBL_STAT is not set
doc/api/doxy-api-index.md +1 -0
@@ -22,6 +22,7 @@ The public API headers are grouped by topics: [compress](@ref rte_comp.h), [regexdev](@ref rte_regexdev.h), [dmadev](@ref rte_dmadev.h), + [mldev](@ref rte_mldev.h), [eventdev](@ref rte_eventdev.h), [event_eth_rx_adapter](@ref rte_event_eth_rx_adapter.h), [event_eth_tx_adapter](@ref rte_event_eth_tx_adapter.h),
doc/api/doxy-api.conf.in +1 -0
@@ -57,6 +57,7 @@ INPUT = @TOPDIR@/doc/api/doxy-api-index.md \ @TOPDIR@/lib/mempool \ @TOPDIR@/lib/meter \ @TOPDIR@/lib/metrics \ + @TOPDIR@/lib/mldev \ @TOPDIR@/lib/node \ @TOPDIR@/lib/net \ @TOPDIR@/lib/pcapng \
doc/guides/prog_guide/img/mldev_flow.svg new file +714 -0
714 lines not on this page · raw message
doc/guides/prog_guide/index.rst +1 -0
@@ -30,6 +30,7 @@ Programmer's Guide regexdev dmadev gpudev + mldev rte_security rawdev link_bonding_poll_mode_drv_lib
doc/guides/prog_guide/mldev.rst new file +186 -0
186 lines not on this page · raw message
lib/eal/common/eal_common_log.c +1 -0
@@ -369,6 +369,7 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EFD, "lib.efd"}, {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, {RTE_LOGTYPE_GSO, "lib.gso"}, + {RTE_LOGTYPE_MLDEV, "lib.mldev"}, {RTE_LOGTYPE_USER1, "user1"}, {RTE_LOGTYPE_USER2, "user2"}, {RTE_LOGTYPE_USER3, "user3"},
lib/eal/include/rte_log.h +1 -0
@@ -48,6 +48,7 @@ extern "C" {#define RTE_LOGTYPE_EFD 18/**< Log related to EFD. */ #define RTE_LOGTYPE_EVENTDEV 19/**< Log related to eventdev. */ #define RTE_LOGTYPE_GSO 20/**< Log related to GSO. */ +#define RTE_LOGTYPE_MLDEV 21/**< Log related to mldev. */ /* these log types can be used in an application */ #define RTE_LOGTYPE_USER1 24/**< User-defined log type 1. */
lib/meson.build +1 -0
@@ -63,6 +63,7 @@ libraries = [ 'flow_classify', # flow_classify lib depends on pkt framework table lib 'graph', 'node', + 'mldev' ] optional_libs = [
lib/mldev/meson.build new file +18 -0
@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2022 Marvell. + +sources = files( + 'rte_mldev.c', +) + +headers = files( + 'rte_mldev.h', +) + +deps += ['mempool'] + +if get_option('buildtype').contains('debug') + cflags += [ '-DRTE_LIBRTE_ML_DEV_DEBUG' ] +else + cflags += [ '-URTE_LIBRTE_ML_DEV_DEBUG' ] +endif
lib/mldev/rte_mldev.c new file +5 -0
@@ -0,0 +1,5 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (c) 2022 Marvell. +*/ + +#include <rte_mldev.h>
lib/mldev/rte_mldev.h new file +1092 -0
1,092 lines not on this page · raw message
lib/mldev/version.map new file +3 -0
@@ -0,0 +1,3 @@ +EXPERIMENTAL { + local: *; +};
Signature · 1 line
2.38.1
Quoted 90 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: Monday, November 14, 2022 5:32 PM
To: [email protected]; Thomas Monjalon <[email protected]>; Bruce Richardson <[email protected]>; Srikanth Yalavarthi <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Devendra Singh Rawat <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Harman Kalra <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Igor Russkikh <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Kiran Kumar Kokkilagadda <[email protected]>; [email protected]; Liron Himi <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Pradeep Kumar Nalla <[email protected]>; Nithin Kumar Dabilpuram <[email protected]>; [email protected]; [email protected]; Radha Chintakuntla <[email protected]>; [email protected]; Rasesh Mody <[email protected]>; [email protected]; [email protected]; Satha Koteswara Rao Kottidi <[email protected]>; Shahed Shaikh <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kumar Kori <[email protected]>; [email protected]; Veerasenareddy Burru <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Prasun Kapoor <[email protected]>; Nadav Haklai <[email protected]>; Satananda Burla <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Akhil Goyal <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ashwin Sekhar T K <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; [email protected]; Derek Chickles <[email protected]>; Shivah Shankar Shankar Narayan Rao <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>
Subject: [dpdk-dev] [PATCH v1 01/12] mldev: introduce machine learning device libraryFrom: Jerin Jacob <[email protected]>
Add mldev API specification to standardize and use the machine learning device and inference operations in vendor neutral way.
Following operations are abstracted through APIs
- ML device capability probe
- ML device configuration
- ML device queue pair configuration
- ML device state management
- ML device stat/xstat operations
- ML model load/unload/start/stop operations
- ML model information probe
- ML IO operations to find size for input and output buffers
- ML quantize and dequantize operations
- ML ops pool creation and free operations
- ML device enqueue/dequeue fastpath interference operationsAlso added programming guide.
Signed-off-by Jerin Jacob <[email protected]>Signed-off-by Srikanth Yalavarthi <[email protected]>--- MAINTAINERS | 5 + config/rte_config.h | 3 + doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + doc/guides/prog_guide/img/mldev_flow.svg | 714 ++++++++++++++ doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/mldev.rst | 186 ++++ lib/eal/common/eal_common_log.c | 1 + lib/eal/include/rte_log.h | 1 + lib/meson.build | 1 + lib/mldev/meson.build | 18 + lib/mldev/rte_mldev.c | 5 + lib/mldev/rte_mldev.h | 1092 ++++++++++++++++++++++
Quoted 9 lines
lib/mldev/version.map | 3 + 14 files changed, 2032 insertions(+) create mode 100644 doc/guides/prog_guide/img/mldev_flow.svg create mode 100644 doc/guides/prog_guide/mldev.rst create mode 100644 lib/mldev/meson.build create mode 100644 lib/mldev/rte_mldev.c create mode 100644 lib/mldev/rte_mldev.h create mode 100644 lib/mldev/version.map
-----Original Message-----
From: [email protected] <[email protected]>
Sent: Monday, November 14, 2022 5:32 PM
To: [email protected]; Thomas Monjalon <[email protected]>; Bruce Richardson <[email protected]>; Srikanth Yalavarthi <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Devendra Singh Rawat <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Harman Kalra <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Igor Russkikh <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Kiran Kumar Kokkilagadda <[email protected]>; [email protected]; Liron Himi <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Pradeep Kumar Nalla <[email protected]>; Nithin Kumar Dabilpuram <[email protected]>; [email protected]; [email protected]; Radha Chintakuntla <[email protected]>; [email protected]; Rasesh Mody <[email protected]>; [email protected]; [email protected]; Satha Koteswara Rao Kottidi <[email protected]>; Shahed Shaikh <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kumar Kori <[email protected]>; [email protected]; Veerasenareddy Burru <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Prasun Kapoor <[email protected]>; Nadav Haklai <[email protected]>; Satananda Burla <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Akhil Goyal <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ashwin Sekhar T K <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; [email protected]; Derek Chickles <[email protected]>; Shivah Shankar Shankar Narayan Rao <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>
Subject: [dpdk-dev] [PATCH v1 01/12] mldev: introduce machine learning device library
From: Jerin Jacob <[email protected]>
Add mldev API specification to standardize and use the machine learning device and inference operations in vendor neutral way.
Following operations are abstracted through APIs
- ML device capability probe
- ML device configuration
- ML device queue pair configuration
- ML device state management
- ML device stat/xstat operations
- ML model load/unload/start/stop operations
- ML model information probe
- ML IO operations to find size for input and output buffers
- ML quantize and dequantize operations
- ML ops pool creation and free operations
- ML device enqueue/dequeue fastpath interference operations
Also added programming guide.
--- MAINTAINERS | 5 + config/rte_config.h | 3 + doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + doc/guides/prog_guide/img/mldev_flow.svg | 714 ++++++++++++++ doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/mldev.rst | 186 ++++ lib/eal/common/eal_common_log.c | 1 + lib/eal/include/rte_log.h | 1 + lib/meson.build | 1 + lib/mldev/meson.build | 18 + lib/mldev/rte_mldev.c | 5 + lib/mldev/rte_mldev.h | 1092 ++++++++++++++++++++++ lib/mldev/version.map | 3 + 14 files changed, 2032 insertions(+) create mode 100644 doc/guides/prog_guide/img/mldev_flow.svg create mode 100644 doc/guides/prog_guide/mldev.rst create mode 100644 lib/mldev/meson.build create mode 100644 lib/mldev/rte_mldev.c create mode 100644 lib/mldev/rte_mldev.h create mode 100644 lib/mldev/version.map
MAINTAINERS +5 -0
@@ -534,6 +534,11 @@ F: drivers/raw/skeleton/ F: app/test/test_rawdev.c F: doc/guides/prog_guide/rawdev.rst +ML device API - EXPERIMENTAL +M: Srikanth Yalavarthi <[email protected]> +F: lib/mldev/ +F: doc/guides/prog_guide/mldev.rst + Memory Pool Drivers -------------------
config/rte_config.h +3 -0
@@ -83,6 +83,9 @@/* rawdev defines */ #define RTE_RAWDEV_MAX_DEVS 64 +/* mldev defines */ +#define RTE_MLDEV_MAX_DEVS 64 +/* ip_fragmentation defines */ #define RTE_LIBRTE_IP_FRAG_MAX_FRAG 8// RTE_LIBRTE_IP_FRAG_TBL_STAT is not set
doc/api/doxy-api-index.md +1 -0
@@ -22,6 +22,7 @@ The public API headers are grouped by topics: [compress](@ref rte_comp.h), [regexdev](@ref rte_regexdev.h), [dmadev](@ref rte_dmadev.h), + [mldev](@ref rte_mldev.h), [eventdev](@ref rte_eventdev.h), [event_eth_rx_adapter](@ref rte_event_eth_rx_adapter.h), [event_eth_tx_adapter](@ref rte_event_eth_tx_adapter.h),
doc/api/doxy-api.conf.in +1 -0
@@ -57,6 +57,7 @@ INPUT = @TOPDIR@/doc/api/doxy-api-index.md \ @TOPDIR@/lib/mempool \ @TOPDIR@/lib/meter \ @TOPDIR@/lib/metrics \ + @TOPDIR@/lib/mldev \ @TOPDIR@/lib/node \ @TOPDIR@/lib/net \ @TOPDIR@/lib/pcapng \
doc/guides/prog_guide/img/mldev_flow.svg new file +714 -0
714 lines not on this page · raw message
doc/guides/prog_guide/index.rst +1 -0
@@ -30,6 +30,7 @@ Programmer's Guide regexdev dmadev gpudev + mldev rte_security rawdev link_bonding_poll_mode_drv_lib
doc/guides/prog_guide/mldev.rst new file +186 -0
186 lines not on this page · raw message
lib/eal/common/eal_common_log.c +1 -0
@@ -369,6 +369,7 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EFD, "lib.efd"}, {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, {RTE_LOGTYPE_GSO, "lib.gso"}, + {RTE_LOGTYPE_MLDEV, "lib.mldev"}, {RTE_LOGTYPE_USER1, "user1"}, {RTE_LOGTYPE_USER2, "user2"}, {RTE_LOGTYPE_USER3, "user3"},
lib/eal/include/rte_log.h +1 -0
@@ -48,6 +48,7 @@ extern "C" {#define RTE_LOGTYPE_EFD 18/**< Log related to EFD. */ #define RTE_LOGTYPE_EVENTDEV 19/**< Log related to eventdev. */ #define RTE_LOGTYPE_GSO 20/**< Log related to GSO. */ +#define RTE_LOGTYPE_MLDEV 21/**< Log related to mldev. */ /* these log types can be used in an application */ #define RTE_LOGTYPE_USER1 24/**< User-defined log type 1. */
lib/meson.build +1 -0
@@ -63,6 +63,7 @@ libraries = [ 'flow_classify', # flow_classify lib depends on pkt framework table lib 'graph', 'node', + 'mldev' ] optional_libs = [
lib/mldev/meson.build new file +18 -0
@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2022 Marvell. + +sources = files( + 'rte_mldev.c', +) + +headers = files( + 'rte_mldev.h', +) + +deps += ['mempool'] + +if get_option('buildtype').contains('debug') + cflags += [ '-DRTE_LIBRTE_ML_DEV_DEBUG' ] +else + cflags += [ '-URTE_LIBRTE_ML_DEV_DEBUG' ] +endif
lib/mldev/rte_mldev.c new file +5 -0
@@ -0,0 +1,5 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (c) 2022 Marvell. +*/ + +#include <rte_mldev.h>
lib/mldev/rte_mldev.h new file +1092 -0
1,092 lines not on this page · raw message
lib/mldev/version.map new file +3 -0
@@ -0,0 +1,3 @@ +EXPERIMENTAL { + local: *; +};
Signature · 1 line
2.38.1
lib/eal/include/rte_log.h extern "C" { · line 51
Quoted 7 lines · On Wed, 1 Feb 2023 13:34:41 +0000 Shivah Shankar Shankar Narayan Rao…
lib/eal/include/rte_log.h +1
-0@@ -48,6 +48,7 @@ extern "C" {#define RTE_LOGTYPE_EFD 18/**< Log related to EFD. */ #define RTE_LOGTYPE_EVENTDEV 19/**< Log related to eventdev. */ #define RTE_LOGTYPE_GSO 20/**< Log related to GSO. */ +#define RTE_LOGTYPE_MLDEV 21/**< Log related to mldev. */
NAK to this part.
No new static logtypes please.
03/02/2023 01:25, Stephen Hemminger:
Quoted 13 lines
lib/eal/include/rte_log.h extern "C" { · line 51
Quoted 7 lines · On Wed, 1 Feb 2023 13:34:41 +0000 Shivah Shankar Shankar Narayan Rao…
lib/eal/include/rte_log.h +1
-0@@ -48,6 +48,7 @@ extern "C" {#define RTE_LOGTYPE_EFD 18/**< Log related to EFD. */ #define RTE_LOGTYPE_EVENTDEV 19/**< Log related to eventdev. */ #define RTE_LOGTYPE_GSO 20/**< Log related to GSO. */ +#define RTE_LOGTYPE_MLDEV 21/**< Log related to mldev. */ NAK to this part.
No new static logtypes please.
Good catch.
By the way, we should remove unused RTE_LOGTYPE_*.
Quoted 15 lines · On Fri, 03 Feb 2023 09:42:45 +0100 Thomas Monjalon <[email protected]> wrote:
03/02/2023 01:25, Stephen Hemminger:
Quoted 13 lines
lib/eal/include/rte_log.h extern "C" { · line 51
Quoted 7 lines · On Wed, 1 Feb 2023 13:34:41 +0000 Shivah Shankar Shankar Narayan Rao…
lib/eal/include/rte_log.h +1
-0@@ -48,6 +48,7 @@ extern "C" {#define RTE_LOGTYPE_EFD 18/**< Log related to EFD. */ #define RTE_LOGTYPE_EVENTDEV 19/**< Log related to eventdev. */ #define RTE_LOGTYPE_GSO 20/**< Log related to GSO. */ +#define RTE_LOGTYPE_MLDEV 21/**< Log related to mldev. */ NAK to this part.
No new static logtypes please.
Quoted 4 lines
Good catch.
By the way, we should remove unused RTE_LOGTYPE_*.
Yes, for 23.11 would like to work down the list.
03/02/2023 18:33, Stephen Hemminger:
Quoted 18 lines
Quoted 15 lines · On Fri, 03 Feb 2023 09:42:45 +0100 Thomas Monjalon <[email protected]> wrote:
03/02/2023 01:25, Stephen Hemminger:
Quoted 13 lines
lib/eal/include/rte_log.h extern "C" { · line 51
Quoted 7 lines · On Wed, 1 Feb 2023 13:34:41 +0000 Shivah Shankar Shankar Narayan Rao…
lib/eal/include/rte_log.h +1
-0@@ -48,6 +48,7 @@ extern "C" {#define RTE_LOGTYPE_EFD 18/**< Log related to EFD. */ #define RTE_LOGTYPE_EVENTDEV 19/**< Log related to eventdev. */ #define RTE_LOGTYPE_GSO 20/**< Log related to GSO. */ +#define RTE_LOGTYPE_MLDEV 21/**< Log related to mldev. */ NAK to this part.
No new static logtypes please.
Quoted 4 lines
Quoted 2 lines
Good catch.
By the way, we should remove unused RTE_LOGTYPE_*.Yes, for 23.11 would like to work down the list.
Do we need to wait 23.11?
It is not an ABI breakage.
And most of these defines are already unused.
Quoted 19 lines · On Fri, 03 Feb 2023 21:18:40 +0100 Thomas Monjalon <[email protected]> wrote:
03/02/2023 18:33, Stephen Hemminger:
Quoted 18 lines
Quoted 15 lines · On Fri, 03 Feb 2023 09:42:45 +0100 Thomas Monjalon <[email protected]> wrote:
03/02/2023 01:25, Stephen Hemminger:
Quoted 13 lines
lib/eal/include/rte_log.h extern "C" { · line 51
Quoted 7 lines · On Wed, 1 Feb 2023 13:34:41 +0000 Shivah Shankar Shankar Narayan Rao…
lib/eal/include/rte_log.h +1
-0@@ -48,6 +48,7 @@ extern "C" {#define RTE_LOGTYPE_EFD 18/**< Log related to EFD. */ #define RTE_LOGTYPE_EVENTDEV 19/**< Log related to eventdev. */ #define RTE_LOGTYPE_GSO 20/**< Log related to GSO. */ +#define RTE_LOGTYPE_MLDEV 21/**< Log related to mldev. */ NAK to this part.
No new static logtypes please.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Good catch.
By the way, we should remove unused RTE_LOGTYPE_*.Yes, for 23.11 would like to work down the list.
Do we need to wait 23.11?
It is not an ABI breakage.
And most of these defines are already unused.
Turning them into deprecated would be API breakage though
03/02/2023 21:26, Stephen Hemminger:
Quoted 25 lines
Quoted 22 lines · On Fri, 03 Feb 2023 21:18:40 +0100 Thomas Monjalon <[email protected]> wrote:
03/02/2023 18:33, Stephen Hemminger:
Quoted 21 lines
Quoted 17 lines · On Fri, 03 Feb 2023 09:42:45 +0100 Thomas Monjalon <[email protected]> wrote:
03/02/2023 01:25, Stephen Hemminger:
Quoted 13 lines
lib/eal/include/rte_log.h extern "C" { · line 51
Quoted 7 lines · On Wed, 1 Feb 2023 13:34:41 +0000 Shivah Shankar Shankar Narayan Rao…
lib/eal/include/rte_log.h +1
-0@@ -48,6 +48,7 @@ extern "C" {#define RTE_LOGTYPE_EFD 18/**< Log related to EFD. */ #define RTE_LOGTYPE_EVENTDEV 19/**< Log related to eventdev. */ #define RTE_LOGTYPE_GSO 20/**< Log related to GSO. */ +#define RTE_LOGTYPE_MLDEV 21/**< Log related to mldev. */ NAK to this part.
No new static logtypes please.Good catch.
By the way, we should remove unused RTE_LOGTYPE_*.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Yes, for 23.11 would like to work down the list.
Do we need to wait 23.11?
It is not an ABI breakage.
And most of these defines are already unused.Turning them into deprecated would be API breakage though
API breakage is not forbidden.
Quoted 5 lines · On Fri, 03 Feb 2023 21:49:02 +0100 Thomas Monjalon <[email protected]> wrote:
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Good catch.
By the way, we should remove unused RTE_LOGTYPE_*.Yes, for 23.11 would like to work down the list.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Do we need to wait 23.11?
It is not an ABI breakage.
And most of these defines are already unused.Turning them into deprecated would be API breakage though
API breakage is not forbidden.
For the internal ones it would be ok, but what about the RTE_LOGTYPE_USER1 etc. These need to go through the regular deprecation process.
The problem is that if the the types are not registered (see eal_common_log.c) they might get reused.
Quoted 4 lines · Stephen Hemminger
On Wed, 1 Feb 2023 13:34:41 +0000
Shivah Shankar Shankar Narayan Rao <[email protected]> wrote:
Quoted 10 lines
lib/eal/include/rte_log.h extern "C" { · line 51
Quoted 7 lines
lib/eal/include/rte_log.h +1
-0@@ -48,6 +48,7 @@ extern "C" {#define RTE_LOGTYPE_EFD 18/**< Log related to EFD. */ #define RTE_LOGTYPE_EVENTDEV 19/**< Log related to eventdev. */ #define RTE_LOGTYPE_GSO 20/**< Log related to GSO. */ +#define RTE_LOGTYPE_MLDEV 21/**< Log related to mldev. */ NAK to this part.
No new static logtypes please.
Ack, will fix in next version.
lib/mldev/rte_mldev.h line 192
Quoted 4 lines · On Wed, 1 Feb 2023 13:34:41 +0000 Shivah Shankar Shankar Narayan Rao…
lib/mldev/rte_mldev.h new file +4
-0+struct rte_ml_dev_info { +const char *driver_name; +/**< Driver name */ +int16_t max_models;
Why is max_models signed? other fields are unsigned
Quoted 10 lines · Stephen Hemminger
lib/mldev/rte_mldev.h line 192
Quoted 4 lines · On Wed, 1 Feb 2023 13:34:41 +0000 Shivah Shankar Shankar Narayan Rao…
lib/mldev/rte_mldev.h new file +4
-0+struct rte_ml_dev_info { +const char *driver_name; +/**< Driver name */ +int16_t max_models;Why is
max_modelssigned? other fields are unsigned
Not needed. I will change as unsigned in next version.
lib/mldev/rte_mldev.h line 145
Quoted 2 lines · On Wed, 1 Feb 2023 13:34:41 +0000 Shivah Shankar Shankar Narayan Rao…
lib/mldev/rte_mldev.h new file +2
-0+#define RTE_ML_STR_MAX 128 +/**< Maximum length of name string */
Fixed length strings do create long term technical issues. But this is big enough, I doubt it matters.
You may want to make sure that string is always at the end of the struct to reduce cache foot print. I.e put important stuff first
Quoted 4 lines · Stephen Hemminger
On Wed, 1 Feb 2023 13:34:41 +0000
Shivah Shankar Shankar Narayan Rao <[email protected]> wrote:
Quoted 8 lines
lib/mldev/rte_mldev.h line 145
Quoted 2 lines
lib/mldev/rte_mldev.h new file +2
-0+#define RTE_ML_STR_MAX 128 +/**< Maximum length of name string */ Fixed length strings do create long term technical issues. But this is big enough, I doubt it matters.
You may want to make sure that string is always at the end of the struct to reduce cache foot print. I.e put important stuff first
Yeah. fastpath stuff first in fast path structures.
PATCH 2/12 mldev: add PMD functions for ML device
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added PMD functions to handle ML devices. The rte_mldev_pmd.* files are for drivers only and should be private to DPDK, and are not installed for application use.
--- lib/mldev/meson.build | 9 +++ lib/mldev/rte_mldev.c | 128 +++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 115 ++++++++++++++++++++++++++++ lib/mldev/rte_mldev_pmd.c | 61 +++++++++++++++ lib/mldev/rte_mldev_pmd.h | 149 +++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 11 +++ 6 files changed, 473 insertions(+) create mode 100644 lib/mldev/rte_mldev_core.h create mode 100644 lib/mldev/rte_mldev_pmd.c create mode 100644 lib/mldev/rte_mldev_pmd.h
lib/mldev/meson.build +9 -0
@@ -2,6 +2,7 @@ # Copyright (c) 2022 Marvell. sources = files( + 'rte_mldev_pmd.c', 'rte_mldev.c', )
@@ -9,6 +10,14 @@ headers = files( 'rte_mldev.h', ) +indirect_headers += files( + 'rte_mldev_core.h', +) + +driver_sdk_headers += files( + 'rte_mldev_pmd.h', +) + deps += ['mempool'] if get_option('buildtype').contains('debug')
lib/mldev/rte_mldev.c +128 -0
131 lines not on this page · raw message
lib/mldev/rte_mldev_core.h new file +115 -0
115 lines not on this page · raw message
lib/mldev/rte_mldev_pmd.c new file +61 -0
61 lines not on this page · raw message
lib/mldev/rte_mldev_pmd.h new file +149 -0
149 lines not on this page · raw message
lib/mldev/version.map +11 -0
@@ -1,3 +1,14 @@ EXPERIMENTAL { local: *; }; + +INTERNAL { + global: + + rte_ml_dev_pmd_allocate; + rte_ml_dev_pmd_create; + rte_ml_dev_pmd_destroy; + rte_ml_dev_pmd_get_dev; + rte_ml_dev_pmd_get_named_dev; + rte_ml_dev_pmd_release; +};
Signature · 1 line
2.38.1
PATCH 3/12 mldev: support device handling functions
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added device handling APIs. These APIs are used to get device information, configure, start, stop and close ML devices. Added function prototypes to PMD layer which are used by the ML driver implementations in the poll mode driver.
--- lib/mldev/rte_mldev.c | 175 +++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 107 +++++++++++++++++++++++ lib/mldev/version.map | 11 +++ 3 files changed, 293 insertions(+)
lib/mldev/rte_mldev.c +175 -0
@@ -131,3 +131,178 @@ rte_ml_dev_pmd_release(struct rte_ml_dev *dev)return ret; } + +uint16_t +rte_ml_dev_count (void ) +{ +return ml_dev_globals.nb_devs; +} + +int +rte_ml_dev_is_valid_dev (int16_t dev_id) +{ +struct rte_ml_dev *dev =NULL ; + +if (dev_id >= ml_dev_globals.max_devs || ml_devices[dev_id].data ==NULL ) +return 0 ; + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (dev->attached !=ML_DEV_ATTACHED ) +return 0 ; +else +return 1 ; +} + +int +rte_ml_dev_socket_id (int16_t dev_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); + +return dev->data->socket_id; +} + +int +rte_ml_dev_info_get (int16_t dev_id,struct rte_ml_dev_info *dev_info) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_info_get ==NULL ) +return -ENOTSUP ; + +if (dev_info ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, dev_info cannot be NULL\n" , dev_id); +return -EINVAL ; + } +memset (dev_info,0 ,sizeof (struct rte_ml_dev_info )); + +return (*dev->dev_ops->dev_info_get)(dev, dev_info); +} + +int +rte_ml_dev_configure (int16_t dev_id,const struct rte_ml_dev_config *config) +{ +struct rte_ml_dev_info dev_info; +struct rte_ml_dev *dev; +int ret; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_configure ==NULL ) +return -ENOTSUP ; + +if (dev->data->dev_started) { +ML_DEV_LOG (ERR ,"Device %d must be stopped to allow configuration" , dev_id); +return -EBUSY ; + } + +if (config ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, config cannot be NULL\n" , dev_id); +return -EINVAL ; + } + + ret =rte_ml_dev_info_get (dev_id, &dev_info); +if (ret <0 ) +return ret; + +if (config->nb_queue_pairs > dev_info.max_queue_pairs) { +ML_DEV_LOG (ERR ,"Device %d num of queues %u > %u\n" , dev_id, config->nb_queue_pairs, + dev_info.max_queue_pairs); +return -EINVAL ; + } + +return (*dev->dev_ops->dev_configure)(dev, config); +} + +int +rte_ml_dev_close (int16_t dev_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_close ==NULL ) +return -ENOTSUP ; + +/* Device must be stopped before it can be closed */ +if (dev->data->dev_started ==1 ) { +ML_DEV_LOG (ERR ,"Device %d must be stopped before closing" , dev_id); +return -EBUSY ; + } + +return (*dev->dev_ops->dev_close)(dev); +} + +int +rte_ml_dev_start (int16_t dev_id) +{ +struct rte_ml_dev *dev; +int ret; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_start ==NULL ) +return -ENOTSUP ; + +if (dev->data->dev_started !=0 ) { +ML_DEV_LOG (ERR ,"Device %d is already started" , dev_id); +return -EBUSY ; + } + + ret = (*dev->dev_ops->dev_start)(dev); +if (ret ==0 ) + dev->data->dev_started =1 ; + +return ret; +} + +int +rte_ml_dev_stop (int16_t dev_id) +{ +struct rte_ml_dev *dev; +int ret; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_stop ==NULL ) +return -ENOTSUP ; + +if (dev->data->dev_started ==0 ) { +ML_DEV_LOG (ERR ,"Device %d is not started" , dev_id); +return -EBUSY ; + } + + ret = (*dev->dev_ops->dev_stop)(dev); +if (ret ==0 ) + dev->data->dev_started =0 ; + +return ret; +}
lib/mldev/rte_mldev_core.h +107 -0
119 lines not on this page · raw message
lib/mldev/version.map +11 -0
@@ -1,4 +1,15 @@ EXPERIMENTAL { + global: + + rte_ml_dev_close; + rte_ml_dev_configure; + rte_ml_dev_count; + rte_ml_dev_info_get; + rte_ml_dev_is_valid_dev; + rte_ml_dev_socket_id; + rte_ml_dev_start; + rte_ml_dev_stop; + local: *; };
Signature · 1 line
2.38.1
PATCH 4/12 mldev: support device queue-pair setup
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added APIs to create a queue-pair attached to ML device. Queue pairs are created with a user specified ID. Added function prototypes to be used by ML drivers for queue pair create and destroy.
--- lib/mldev/rte_mldev.c | 33 ++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 44 ++++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 1 + 3 files changed, 78 insertions(+)
lib/mldev/rte_mldev.c +33 -0
@@ -306,3 +306,36 @@ rte_ml_dev_stop(int16_t dev_id)return ret; } + +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) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_queue_pair_setup ==NULL ) +return -ENOTSUP ; + +if (queue_pair_id >= dev->data->nb_queue_pairs) { +ML_DEV_LOG (ERR ,"Invalid queue_pair_id = %d" , queue_pair_id); +return -EINVAL ; + } + +if (qp_conf ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, qp_conf cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (dev->data->dev_started) { +ML_DEV_LOG (ERR ,"Device %d must be stopped to allow configuration" , dev_id); +return -EBUSY ; + } + +return (*dev->dev_ops->dev_queue_pair_setup)(dev, queue_pair_id, qp_conf, socket_id); +}
lib/mldev/rte_mldev_core.h +44 -0
56 lines not on this page · raw message
lib/mldev/version.map +1 -0
@@ -6,6 +6,7 @@ EXPERIMENTAL { rte_ml_dev_count; rte_ml_dev_info_get; rte_ml_dev_is_valid_dev; + rte_ml_dev_queue_pair_setup; rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stop;
Signature · 1 line
2.38.1
PATCH 5/12 mldev: support handling ML models
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added RTE functions to handle ML models. These APIs can load, unload, start, and stop an ML model. Additional APIs to update model parameters and get model information are added.
--- lib/mldev/rte_mldev.c | 123 +++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 122 ++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 6 ++ 3 files changed, 251 insertions(+)
lib/mldev/rte_mldev.c +123 -0
@@ -339,3 +339,126 @@ rte_ml_dev_queue_pair_setup(int16_t dev_id, uint16_t queue_pair_id,return (*dev->dev_ops->dev_queue_pair_setup)(dev, queue_pair_id, qp_conf, socket_id); } + +int +rte_ml_model_load (int16_t dev_id,struct rte_ml_model_params *params,int16_t *model_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_load ==NULL ) +return -ENOTSUP ; + +if (params ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, params cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (model_id ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, model_id cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->model_load)(dev, params, model_id); +} + +int +rte_ml_model_unload (int16_t dev_id,int16_t model_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_unload ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->model_unload)(dev, model_id); +} + +int +rte_ml_model_start (int16_t dev_id,int16_t model_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_start ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->model_start)(dev, model_id); +} + +int +rte_ml_model_stop (int16_t dev_id,int16_t model_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_stop ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->model_stop)(dev, model_id); +} + +int +rte_ml_model_info_get (int16_t dev_id,int16_t model_id,struct rte_ml_model_info *model_info) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_info_get ==NULL ) +return -ENOTSUP ; + +if (model_info ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, model_id %d, model_info cannot be NULL\n" , dev_id, + model_id); +return -EINVAL ; + } + +return (*dev->dev_ops->model_info_get)(dev, model_id, model_info); +} + +int +rte_ml_model_params_update (int16_t dev_id,int16_t model_id,void *buffer) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_params_update ==NULL ) +return -ENOTSUP ; + +if (buffer ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, buffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->model_params_update)(dev, model_id, buffer); +}
lib/mldev/rte_mldev_core.h +122 -0
134 lines not on this page · raw message
lib/mldev/version.map +6 -0
@@ -10,6 +10,12 @@ EXPERIMENTAL { rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stop; + rte_ml_model_info_get; + rte_ml_model_load; + rte_ml_model_params_update; + rte_ml_model_start; + rte_ml_model_stop; + rte_ml_model_unload; local: *; };
Signature · 1 line
2.38.1
PATCH 6/12 mldev: support input and output data handling
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added RTE library functions to handle model input and output data. The APIs can be used to get the size of I/O buffers, quantize input data and dequantize output data.
--- lib/mldev/rte_mldev.c | 94 ++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 106 +++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 4 ++ 3 files changed, 204 insertions(+)
lib/mldev/rte_mldev.c +94 -0
@@ -462,3 +462,97 @@ rte_ml_model_params_update(int16_t dev_id, int16_t model_id, void *buffer)return (*dev->dev_ops->model_params_update)(dev, model_id, buffer); } + +int +rte_ml_io_input_size_get (int16_t dev_id,int16_t model_id,uint32_t nb_batches, +uint64_t *input_qsize,uint64_t *input_dsize) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->io_input_size_get ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->io_input_size_get)(dev, model_id, nb_batches, input_qsize, + input_dsize); +} + +int +rte_ml_io_output_size_get (int16_t dev_id,int16_t model_id,uint32_t nb_batches, +uint64_t *output_qsize,uint64_t *output_dsize) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->io_output_size_get ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->io_output_size_get)(dev, model_id, nb_batches, output_qsize, + output_dsize); +} + +int +rte_ml_io_quantize (int16_t dev_id,int16_t model_id,uint16_t nb_batches,void *dbuffer, +void *qbuffer) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->io_quantize ==NULL ) +return -ENOTSUP ; + +if (dbuffer ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, dbuffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (qbuffer ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, qbuffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->io_quantize)(dev, model_id, nb_batches, dbuffer, qbuffer); +} + +int +rte_ml_io_dequantize (int16_t dev_id,int16_t model_id,uint16_t nb_batches,void *qbuffer, +void *dbuffer) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->io_dequantize ==NULL ) +return -ENOTSUP ; + +if (qbuffer ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, qbuffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (dbuffer ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, dbuffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->io_dequantize)(dev, model_id, nb_batches, qbuffer, dbuffer); +}
lib/mldev/rte_mldev_core.h +106 -0
118 lines not on this page · raw message
lib/mldev/version.map +4 -0
@@ -10,6 +10,10 @@ EXPERIMENTAL { rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stop; + rte_ml_io_dequantize; + rte_ml_io_input_size_get; + rte_ml_io_output_size_get; + rte_ml_io_quantize; rte_ml_model_info_get; rte_ml_model_load; rte_ml_model_params_update;
Signature · 1 line
2.38.1
PATCH 7/12 mldev: support op pool and its operations
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added RTE library functions to create and free ML op pool. Create function allocates new ML op pool and initializes ML ops to their defaults.
--- lib/mldev/rte_mldev.c | 69 +++++++++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 2 ++ 2 files changed, 71 insertions(+)
lib/mldev/rte_mldev.c +69 -0
@@ -10,6 +10,17 @@ static struct rte_ml_dev ml_devices[RTE_MLDEV_MAX_DEVS];static struct rte_ml_dev_global ml_dev_globals = { .devs = ml_devices, .data = {NULL }, .nb_devs =0 , .max_devs =RTE_MLDEV_MAX_DEVS }; +/* +* Private data structure of an operation pool. +* +* A structure that contains ml op_pool specific data that is +* appended after the mempool structure (in private data). +*/ +struct rte_ml_op_pool_private { +uint16_t user_size; +/*< Size of private user data with each operation. */ +}; +struct rte_ml_dev *rte_ml_dev_pmd_get_dev (int16_t dev_id) {
@@ -556,3 +567,61 @@ rte_ml_io_dequantize(int16_t dev_id, int16_t model_id, uint16_t nb_batches, voidreturn (*dev->dev_ops->io_dequantize)(dev, model_id, nb_batches, qbuffer, dbuffer); } + +/** Initialise rte_ml_op mempool element */ +static void +ml_op_init(struct rte_mempool *mempool, __rte_unused void *opaque_arg, void *_op_data, + __rte_unused unsigned int i) +{ +struct rte_ml_op *op = _op_data; + +memset (_op_data,0 , mempool->elt_size); + op->status =RTE_ML_OP_STATUS_NOT_PROCESSED ; + op->mempool = mempool; +} + +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) +{ +struct rte_ml_op_pool_private *priv; +struct rte_mempool *mp; +unsigned int elt_size; + +/* lookup mempool in case already allocated */ + mp =rte_mempool_lookup (name); + elt_size =sizeof (struct rte_ml_op ) + user_size; + +if (mp !=NULL ) { + priv = (struct rte_ml_op_pool_private *)rte_mempool_get_priv (mp); +if (mp->elt_size != elt_size || mp->cache_size < cache_size || mp->size < nb_elts || + priv->user_size < user_size) { + mp =NULL ; +ML_DEV_LOG (ERR , +"Mempool %s already exists but with incompatible parameters" , + name); +return NULL ; + } +return mp; + } + + mp =rte_mempool_create (name, nb_elts, elt_size, cache_size, +sizeof (struct rte_ml_op_pool_private ),NULL ,NULL , ml_op_init,NULL , + socket_id,0 ); +if (mp ==NULL ) { +ML_DEV_LOG (ERR ,"Failed to create mempool %s" , name); +return NULL ; + } + + priv = (struct rte_ml_op_pool_private *)rte_mempool_get_priv (mp); + priv->user_size = user_size; + +return mp; +} + +void +rte_ml_op_pool_free (struct rte_mempool *mempool) +{ +if (mempool !=NULL ) +rte_mempool_free (mempool); +}
lib/mldev/version.map +2 -0
@@ -20,6 +20,8 @@ EXPERIMENTAL { rte_ml_model_start; rte_ml_model_stop; rte_ml_model_unload; + rte_ml_op_pool_create; + rte_ml_op_pool_free; local: *; };
Signature · 1 line
2.38.1
PATCH 8/12 mldev: support inference enqueue and dequeue
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added implementations of fast-path functions to enqueue and dequeue ML requests from an ML device queue-pair.
--- lib/mldev/rte_mldev.c | 76 ++++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 46 +++++++++++++++++++++++ lib/mldev/rte_mldev_pmd.h | 2 + lib/mldev/version.map | 2 + 4 files changed, 126 insertions(+)
lib/mldev/rte_mldev.c +76 -0
@@ -2,6 +2,7 @@* Copyright (c) 2022 Marvell. */ +#include <rte_errno.h> #include <rte_mldev.h> #include <rte_mldev_pmd.h>
@@ -105,6 +106,9 @@ rte_ml_dev_pmd_allocate(const char *name, uint8_t socket_id) ml_dev_globals.nb_devs++; } + dev->enqueue_burst =NULL ; + dev->dequeue_burst =NULL ; +return dev; }
@@ -625,3 +629,75 @@ rte_ml_op_pool_free(struct rte_mempool *mempool)if (mempool !=NULL )rte_mempool_free (mempool); } + +uint16_t +rte_ml_enqueue_burst (int16_t dev_id,uint16_t qp_id,struct rte_ml_op **ops,uint16_t nb_ops) +{ +struct rte_ml_dev *dev; + +#ifdef RTE_LIBRTE_ML_DEV_DEBUG +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); + rte_errno = -EINVAL ; +return 0 ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->enqueue_burst ==NULL ) { + rte_errno = -ENOTSUP ; +return 0 ; + } + +if (ops ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, ops cannot be NULL\n" , dev_id); + rte_errno = -EINVAL ; +return 0 ; + } + +if (qp_id >= dev->data->nb_queue_pairs) { +ML_DEV_LOG (ERR ,"Invalid qp_id %u\n" , qp_id); + rte_errno = -EINVAL ; +return 0 ; + } +#else + dev =rte_ml_dev_pmd_get_dev (dev_id); +#endif + +return (*dev->enqueue_burst)(dev, qp_id, ops, nb_ops); +} + +uint16_t +rte_ml_dequeue_burst (int16_t dev_id,uint16_t qp_id,struct rte_ml_op **ops,uint16_t nb_ops) +{ +struct rte_ml_dev *dev; + +#ifdef RTE_LIBRTE_ML_DEV_DEBUG +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); + rte_errno = -EINVAL ; +return 0 ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dequeue_burst ==NULL ) { + rte_errno = -ENOTSUP ; +return 0 ; + } + +if (ops ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, ops cannot be NULL\n" , dev_id); + rte_errno = -EINVAL ; +return 0 ; + } + +if (qp_id >= dev->data->nb_queue_pairs) { +ML_DEV_LOG (ERR ,"Invalid qp_id %u\n" , qp_id); + rte_errno = -EINVAL ; +return 0 ; + } +#else + dev =rte_ml_dev_pmd_get_dev (dev_id); +#endif + +return (*dev->dequeue_burst)(dev, qp_id, ops, nb_ops); +}
lib/mldev/rte_mldev_core.h +46 -0
58 lines not on this page · raw message
lib/mldev/rte_mldev_pmd.h +2 -0
@@ -40,6 +40,8 @@ struct rte_ml_dev_pmd_init_params {uint64_t private_data_size; }; +struct rte_ml_dev ; +/** * @internal *
lib/mldev/version.map +2 -0
@@ -1,6 +1,7 @@ EXPERIMENTAL { global: + rte_ml_dequeue_burst; rte_ml_dev_close; rte_ml_dev_configure; rte_ml_dev_count;
@@ -10,6 +11,7 @@ EXPERIMENTAL { rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stop; + rte_ml_enqueue_burst; rte_ml_io_dequantize; rte_ml_io_input_size_get; rte_ml_io_output_size_get;
Signature · 1 line
2.38.1
PATCH 9/12 mldev: support device statistics
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added functions to get and reset device stats.
Device stats include number of requests enqueued, dequeued and errors. Added function prototypes to used by driver implementations.
--- lib/mldev/rte_mldev.c | 40 ++++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 32 ++++++++++++++++++++++++++++++ lib/mldev/version.map | 2 ++ 3 files changed, 74 insertions(+)
lib/mldev/rte_mldev.c +40 -0
@@ -355,6 +355,46 @@ rte_ml_dev_queue_pair_setup(int16_t dev_id, uint16_t queue_pair_id,return (*dev->dev_ops->dev_queue_pair_setup)(dev, queue_pair_id, qp_conf, socket_id); } +int +rte_ml_dev_stats_get (int16_t dev_id,struct rte_ml_dev_stats *stats) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_stats_get ==NULL ) +return -ENOTSUP ; + +if (stats ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, stats cannot be NULL\n" , dev_id); +return -EINVAL ; + } +memset (stats,0 ,sizeof (struct rte_ml_dev_stats )); + +return (*dev->dev_ops->dev_stats_get)(dev, stats); +} + +void +rte_ml_dev_stats_reset (int16_t dev_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_stats_reset ==NULL ) +return ; + + (*dev->dev_ops->dev_stats_reset)(dev); +} +int rte_ml_model_load (int16_t dev_id,struct rte_ml_model_params *params,int16_t *model_id) {
lib/mldev/rte_mldev_core.h +32 -0
@@ -195,6 +195,32 @@ typedef int (*mldev_queue_pair_setup_t)(struct rte_ml_dev *dev, uint16_t queue_p*/ typedef int (*mldev_queue_pair_release_t )(struct rte_ml_dev *dev,uint16_t queue_pair_id); +/** +* @internal +* +* Function used to get device statistics. +* +* @param dev +* ML device pointer. +* @param stats +* Pointer to ML device stats structure to update. +* +* @return +* - 0 on success. +* - < 0, error on failure. +*/ +typedef int (*mldev_stats_get_t )(struct rte_ml_dev *dev,struct rte_ml_dev_stats *stats); + +/** +* @internal +* +* Function used to reset device statistics. +* +* @param dev +* ML device pointer. +*/ +typedef void (*mldev_stats_reset_t )(struct rte_ml_dev *dev); +/** * @internal *
@@ -420,6 +446,12 @@ struct rte_ml_dev_ops {/** Release a device queue pair. */ mldev_queue_pair_release_t dev_queue_pair_release; +/** Get device statistics. */ +mldev_stats_get_t dev_stats_get; + +/** Reset device statistics. */ +mldev_stats_reset_t dev_stats_reset; +/** Load an ML model. */ mldev_model_load_t model_load;
lib/mldev/version.map +2 -0
@@ -10,6 +10,8 @@ EXPERIMENTAL { rte_ml_dev_queue_pair_setup; rte_ml_dev_socket_id; rte_ml_dev_start; + rte_ml_dev_stats_get; + rte_ml_dev_stats_reset; rte_ml_dev_stop; rte_ml_enqueue_burst; rte_ml_io_dequantize;
Signature · 1 line
2.38.1
PATCH 10/12 mldev: support device extended statistics
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added functions to handle device extended stats.
xstats supported are driver specific and can include stats specific to ML device or ML model and I/O.
Added prototypes for functions to be called by the device drivers.
--- lib/mldev/rte_mldev.c | 88 ++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 93 ++++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 4 ++ 3 files changed, 185 insertions(+)
lib/mldev/rte_mldev.c +88 -0
@@ -395,6 +395,94 @@ rte_ml_dev_stats_reset(int16_t dev_id) (*dev->dev_ops->dev_stats_reset)(dev); } +int +rte_ml_dev_xstats_names_get (int16_t dev_id,struct rte_ml_dev_xstats_map *xstats_map,uint32_t size) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_xstats_names_get ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->dev_xstats_names_get)(dev, xstats_map, size); +} + +int +rte_ml_dev_xstats_by_name_get (int16_t dev_id,const char *name,uint16_t *stat_id,uint64_t *value) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_xstats_by_name_get ==NULL ) +return -ENOTSUP ; + +if (name ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, name cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (value ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, value cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->dev_xstats_by_name_get)(dev, name, stat_id, value); +} + +int +rte_ml_dev_xstats_get (int16_t dev_id,const uint16_t *stat_ids,uint64_t *values,uint16_t nb_ids) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_xstats_get ==NULL ) +return -ENOTSUP ; + +if (stat_ids ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, stat_ids cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (values ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, values cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->dev_xstats_get)(dev, stat_ids, values, nb_ids); +} + +int +rte_ml_dev_xstats_reset (int16_t dev_id,const uint16_t *stat_ids,uint16_t nb_ids) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_xstats_reset ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->dev_xstats_reset)(dev, stat_ids, nb_ids); +} +int rte_ml_model_load (int16_t dev_id,struct rte_ml_model_params *params,int16_t *model_id) {
lib/mldev/rte_mldev_core.h +93 -0
105 lines not on this page · raw message
lib/mldev/version.map +4 -0
@@ -13,6 +13,10 @@ EXPERIMENTAL { rte_ml_dev_stats_get; rte_ml_dev_stats_reset; rte_ml_dev_stop; + rte_ml_dev_xstats_by_name_get; + rte_ml_dev_xstats_get; + rte_ml_dev_xstats_names_get; + rte_ml_dev_xstats_reset; rte_ml_enqueue_burst; rte_ml_io_dequantize; rte_ml_io_input_size_get;
Signature · 1 line
2.38.1
PATCH 11/12 mldev: support to retrieve error information
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added functions to get error information for an ML op. This information can include both drive specific error message and error code.
--- lib/mldev/rte_mldev.c | 31 +++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 22 ++++++++++++++++++++++ lib/mldev/version.map | 1 + 3 files changed, 54 insertions(+)
lib/mldev/rte_mldev.c +31 -0
@@ -829,3 +829,34 @@ rte_ml_dequeue_burst(int16_t dev_id, uint16_t qp_id, struct rte_ml_op **ops, uinreturn (*dev->dequeue_burst)(dev, qp_id, ops, nb_ops); } + +int +rte_ml_op_error_get (int16_t dev_id,struct rte_ml_op *op,struct rte_ml_op_error *error) +{ +struct rte_ml_dev *dev; + +#ifdef RTE_LIBRTE_ML_DEV_DEBUG +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->op_error_get ==NULL ) +return -ENOTSUP ; + +if (op ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, op cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (error ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, error cannot be NULL\n" , dev_id); +return -EINVAL ; + } +#else + dev =rte_ml_dev_pmd_get_dev (dev_id); +#endif + +return (*dev->op_error_get)(dev, op, error); +}
lib/mldev/rte_mldev_core.h +22 -0
@@ -77,6 +77,25 @@ typedef uint16_t (*mldev_enqueue_t)(struct rte_ml_dev *dev, uint16_t qp_id, strutypedef uint16_t (*mldev_dequeue_t )(struct rte_ml_dev *dev,uint16_t qp_id,struct rte_ml_op **ops,uint16_t nb_ops); +/** +* @internal +* +* Get error information for an Op. +* +* @param dev +* ML device pointer. +* @param op +* ML Op handle. +* @param error +* Pointer to error structure. +* +* @return +* - 0 on success. +* - <0, error on failure. +*/ +typedef int (*mldev_op_error_get_t )(struct rte_ml_dev *dev,struct rte_ml_op *op, +struct rte_ml_op_error *error); +/** * Definitions of all functions exported by a driver through the generic structure of type * *ml_dev_ops* supplied in the *rte_ml_dev* structure associated with a device.
@@ -626,6 +645,9 @@ struct rte_ml_dev {/** Pointer to PMD dequeue function. */ mldev_dequeue_t dequeue_burst; +/** Pointer to PMD Op error get function. */ +mldev_op_error_get_t op_error_get; +/** Pointer to device data. */ struct rte_ml_dev_data *data;
lib/mldev/version.map +1 -0
@@ -28,6 +28,7 @@ EXPERIMENTAL { rte_ml_model_start; rte_ml_model_stop; rte_ml_model_unload; + rte_ml_op_error_get; rte_ml_op_pool_create; rte_ml_op_pool_free;
Signature · 1 line
2.38.1
PATCH 12/12 mldev: support to get debug info and test device
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added library functions for ML device debug APIs.
The APIs are used to dump ML device debug information and to run selftest.
--- lib/mldev/rte_mldev.c | 39 ++++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 37 ++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 2 ++ 3 files changed, 78 insertions(+)
lib/mldev/rte_mldev.c +39 -0
@@ -483,6 +483,45 @@ rte_ml_dev_xstats_reset(int16_t dev_id, const uint16_t *stat_ids, uint16_t nb_idreturn (*dev->dev_ops->dev_xstats_reset)(dev, stat_ids, nb_ids); } +int +rte_ml_dev_dump (int16_t dev_id,FILE *fd) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_dump ==NULL ) +return -ENOTSUP ; + +if (fd ==NULL ) { +ML_DEV_LOG (ERR ,"Dev %d, file descriptor cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->dev_dump)(dev, fd); +} + +int +rte_ml_dev_selftest (int16_t dev_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +ML_DEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_selftest ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->dev_selftest)(dev); +} +int rte_ml_model_load (int16_t dev_id,struct rte_ml_model_params *params,int16_t *model_id) {
lib/mldev/rte_mldev_core.h +37 -0
@@ -321,6 +321,37 @@ typedef int (*mldev_xstats_get_t)(struct rte_ml_dev *dev, const uint16_t *stat_itypedef int (*mldev_xstats_reset_t )(struct rte_ml_dev *dev,const uint16_t *stat_ids,uint16_t nb_ids); +/** +* @internal +* +* Function used to dump ML device debug info. +* +* @param dev +* ML device pointer. +* @param fd +* File descriptor to dump the debug info. +* +* @return +* - 0 on success. +* - < 0, error code on failure. +*/ + +typedef int (*mldev_dump_t )(struct rte_ml_dev *dev,FILE *fd); + +/** +* @internal +* +* Function used for selftest of ML device. +* +* @param dev +* ML device pointer. +* +* @return +* - 0 on success. +* - < 0, error on failure. +*/ +typedef int (*mldev_selftest_t )(struct rte_ml_dev *dev); +/** * @internal *
@@ -564,6 +595,12 @@ struct rte_ml_dev_ops {/** Reset extended stats of the device. */ mldev_xstats_reset_t dev_xstats_reset; +/** Dump ML device debug info. */ +mldev_dump_t dev_dump; + +/** Dump ML device debug info. */ +mldev_selftest_t dev_selftest; +/** Load an ML model. */ mldev_model_load_t model_load;
lib/mldev/version.map +2 -0
@@ -5,9 +5,11 @@ EXPERIMENTAL { rte_ml_dev_close; rte_ml_dev_configure; rte_ml_dev_count; + rte_ml_dev_dump; rte_ml_dev_info_get; rte_ml_dev_is_valid_dev; rte_ml_dev_queue_pair_setup; + rte_ml_dev_selftest; rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stats_get;
Signature · 1 line
2.38.1
14/11/2022 13:02, [email protected]:
Quoted 32 lines
From: Jerin Jacob <[email protected]>
Machine learning inference library
==================================Definition of machine learning inference
----------------------------------------
Inference in machine learning is the process of making an output prediction based on new input data using a pre-trained machine learning model.The scope of the RFC would include only inferencing with pre-trained machine learning models, training and building/compiling the ML models is out of scope for this RFC or DPDK mldev API. Use existing machine learning compiler frameworks for model creation.
Motivation for the new library
------------------------------
Multiple semiconductor vendors are offering accelerator products such as DPU (often called Smart-NIC), FPGA, GPU, etc., which have ML inferencing capabilities integrated as part of the product. Use of ML inferencing is increasing in the domain of packet processing for flow classification, intrusion, malware and anomaly detection.Lack of inferencing support through DPDK APIs will involve complexities and increased latency from moving data across frameworks (i.e, dataplane to non dataplane ML frameworks and vice-versa). Having a standardized DPDK APIs for ML inferencing would enable the dataplane solutions to harness the benefit of inline inferencing supported by the hardware.
Contents
---------------A) API specification for:
Quoted 8 lines
1) Discovery of ML capabilities (e.g., device specific features) in a vendor independent fashion
2) Definition of functions to handle ML devices, which includes probing, initialization and termination of the devices.
3) Definition of functions to handle ML models used to perform inference operations.
4) Definition of function to handle quantize and dequantize operationsB) Common code for above specification
Can we compare this library with WinML?
https://learn.microsoft.com/en-us/windows/ai/windows-ml/api-reference
Is there things we can learn from it?
Quoted 6 lines
ML Model: An ML model is an algorithm trained over a dataset. A model consists of procedure/algorithm and data/pattern required to make predictions on live data. Once the model is created and trained outside of the DPDK scope, the model can be loaded via
rte_ml_model_load()and then start it usingrte_ml_model_start()API. Therte_ml_model_params_update()can be used to update the model parameters such as weight and bias without unloading the model usingrte_ml_model_unload().
The fact that the model is prepared outside means the model format is free and probably different per mldev driver.
I think it is OK but it requires a lot of documentation effort to explain how to bind the model and its parameters with the DPDK API.
Also we may need to pass some metadata from the model builder
to the inference engine in order to enable optimizations prepared in the model. And the other way, we may need inference capabilities in order to generate an optimized model which can run in the inference engine.
[...]
Quoted 15 lines
Typical application utilisation of the ML API will follow the following programming flow.
-
rte_ml_dev_configure()
-rte_ml_dev_queue_pair_setup()
-rte_ml_model_load()
-rte_ml_model_start()
-rte_ml_model_info()
-rte_ml_dev_start()
-rte_ml_enqueue_burst()
-rte_ml_dequeue_burst()
-rte_ml_model_stop()
-rte_ml_model_unload()
-rte_ml_dev_stop()
-rte_ml_dev_close()
Where is parameters update in this flow?
Should we update all parameters at once or can it be done more fine-grain?
Question about the memory used by mldev:
Can we manage where the memory is allocated (host, device, mix, etc)?
Quoted 42 lines · Thomas Monjalon
14/11/2022 13:02, [email protected]:
Quoted 40 lines
From: Jerin Jacob <[email protected]>
Machine learning inference library
==================================Definition of machine learning inference
----------------------------------------
Inference in machine learning is the process of making an output prediction based on new input data using a pre-trained machine learning model.The scope of the RFC would include only inferencing with pre-trained machine learning models, training and building/compiling the ML models is out of scope for this RFC or DPDK mldev API. Use existing machine learning compiler frameworks for model creation.
Motivation for the new library
------------------------------
Multiple semiconductor vendors are offering accelerator products such as DPU (often called Smart-NIC), FPGA, GPU, etc., which have ML inferencing capabilities integrated as part of the product. Use of ML inferencing is increasing in the domain of packet processing for flow classification, intrusion, malware and anomaly detection.Lack of inferencing support through DPDK APIs will involve complexities and increased latency from moving data across frameworks (i.e, dataplane to non dataplane ML frameworks and vice-versa). Having a standardized DPDK APIs for ML inferencing would enable the dataplane solutions to harness the benefit of inline inferencing supported by the hardware.
Contents
---------------A) API specification for:
1) Discovery of ML capabilities (e.g., device specific features) in a vendor independent fashion
2) Definition of functions to handle ML devices, which includes probing, initialization and termination of the devices.
3) Definition of functions to handle ML models used to perform inference operations.
4) Definition of function to handle quantize and dequantize operationsB) Common code for above specification
Thanks for the review.
Quoted 3 lines
Can we compare this library with WinML?
https://learn.microsoft.com/en-us/windows/ai/windows-ml/api-reference
Proposed DPDK library supports only inferencing with pre-trained models.
Quoted 1 line
Is there things we can learn from it?
Comparing to winML, API provide functionality similar to "LearningModel*" classes provides.
Support related to handling custom operators and Native APIs like winML is provided through this API.
There may more features which we can add where there are drivers which supports it.
Quoted 9 lines
Quoted 8 lines
ML Model: An ML model is an algorithm trained over a dataset. A model consists of procedure/algorithm and data/pattern required to make predictions on live data. Once the model is created and trained outside of the DPDK scope, the model can be loaded via
rte_ml_model_load()and then start it usingrte_ml_model_start()API. Therte_ml_model_params_update()can be used to update the model parameters such as weight and bias without unloading the model usingrte_ml_model_unload().
Quoted 8 lines
The fact that the model is prepared outside means the model format is free and probably different per mldev driver.
I think it is OK but it requires a lot of documentation effort to explain how to bind the model and its parameters with the DPDK API.
Also we may need to pass some metadata from the model builder
to the inference engine in order to enable optimizations prepared in the model. And the other way, we may need inference capabilities in order to generate an optimized model which can run in the inference engine.
The base API specification kept absolute minimum. Currently, weight and biases parameters updated through rte_ml_model_params_update(). It can be extended when there are drivers supports it or if you have any specific parameter you would like to add
it in rte_ml_model_params_update().
Other metadata data like batch, shapes, formats queried using rte_ml_io_info().
Quoted 19 lines
[...]
Quoted 15 lines
Typical application utilisation of the ML API will follow the following programming flow.
-
rte_ml_dev_configure()
-rte_ml_dev_queue_pair_setup()
-rte_ml_model_load()
-rte_ml_model_start()
-rte_ml_model_info()
-rte_ml_dev_start()
-rte_ml_enqueue_burst()
-rte_ml_dequeue_burst()
-rte_ml_model_stop()
-rte_ml_model_unload()
-rte_ml_dev_stop()
-rte_ml_dev_close()
Quoted 1 line
Where is parameters update in this flow?
Added the mandatory APIs in the top level flow doc. rte_ml_model_params_update() used to update the parameters.
Quoted 1 line
Should we update all parameters at once or can it be done more fine-grain?
Currently, rte_ml_model_params_update() can be used to update weight and bias via buffer when device is
in stop state and without unloading the model.
Quoted 4 lines
Question about the memory used by mldev:
Can we manage where the memory is allocated (host, device, mix, etc)?
Just passing buffer pointers now like other subsystem. Other EAL infra service can take care of the locality of memory as it is not specific to ML dev.
+/** ML operation's input and output buffer representation as scatter gather list
+ */
+struct rte_ml_buff_seg {
+ rte_iova_t iova_addr;
+ /**< IOVA address of segment buffer. */
+ void *addr;
+ /**< Virtual address of segment buffer. */
+ uint32_t length;
+ /**< Segment length. */
+ uint32_t reserved;
+ /**< Reserved for future use. */
+ struct rte_ml_buff_seg *next;
+ /**< Points to next segment. Value NULL represents the last segment. */ +};
Quoted 2 lines
25/01/2023 20:01, Jerin Jacob:
Quoted 18 lines · Thomas Monjalon
Quoted 8 lines
14/11/2022 13:02, [email protected]:
Quoted 6 lines
ML Model: An ML model is an algorithm trained over a dataset. A model consists of procedure/algorithm and data/pattern required to make predictions on live data. Once the model is created and trained outside of the DPDK scope, the model can be loaded via
rte_ml_model_load()and then start it usingrte_ml_model_start()API. Therte_ml_model_params_update()can be used to update the model parameters such as weight and bias without unloading the model usingrte_ml_model_unload().Quoted 8 lines
The fact that the model is prepared outside means the model format is free and probably different per mldev driver.
I think it is OK but it requires a lot of documentation effort to explain how to bind the model and its parameters with the DPDK API.
Also we may need to pass some metadata from the model builder
to the inference engine in order to enable optimizations prepared in the model. And the other way, we may need inference capabilities in order to generate an optimized model which can run in the inference engine.
Quoted 5 lines
The base API specification kept absolute minimum. Currently, weight and biases parameters updated through
rte_ml_model_params_update(). It can be extended when there are drivers supports it or if you have any specific parameter you would like to add
it inrte_ml_model_params_update().
This function is
int rte_ml_model_params_update(int16_t dev_id, int16_t model_id, void *buffer);
How are we supposed to provide separate parameters in this void* ?
Quoted 1 line
Other metadata data like batch, shapes, formats queried using
rte_ml_io_info().
Copying:
+/** Input and output data information structure
+ *
+ * Specifies the type and shape of input and output data.
+ */
+struct rte_ml_io_info {
+ char name[RTE_ML_STR_MAX]; + /**< Name of data */ + struct rte_ml_io_shape shape; + /**< Shape of data */ + enum rte_ml_io_type qtype; + /**< Type of quantized data */ + enum rte_ml_io_type dtype; + /**< Type of de-quantized data */
+};
Is it the right place to notify the app that some model optimizations are supported? (example: merge some operations in the graph)
Quoted 17 lines
Quoted 17 lines
[...]
Quoted 15 lines
Typical application utilisation of the ML API will follow the following programming flow.
-
rte_ml_dev_configure()
-rte_ml_dev_queue_pair_setup()
-rte_ml_model_load()
-rte_ml_model_start()
-rte_ml_model_info()
-rte_ml_dev_start()
-rte_ml_enqueue_burst()
-rte_ml_dequeue_burst()
-rte_ml_model_stop()
-rte_ml_model_unload()
-rte_ml_dev_stop()
-rte_ml_dev_close()
Quoted 4 lines
Quoted 1 line
Where is parameters update in this flow?
Added the mandatory APIs in the top level flow doc.
rte_ml_model_params_update()used to update the parameters.
The question is "where" should it be done?
Before/after start?
Quoted 5 lines
Quoted 1 line
Should we update all parameters at once or can it be done more fine-grain?
Currently,
rte_ml_model_params_update()can be used to update weight and bias via buffer when device is
in stop state and without unloading the model.
The question is "can we update a single parameter"? And how?
Quoted 6 lines
Quoted 2 lines
Question about the memory used by mldev:
Can we manage where the memory is allocated (host, device, mix, etc)?Just passing buffer pointers now like other subsystem. Other EAL infra service can take care of the locality of memory as it is not specific to ML dev.
I was thinking about memory allocation required by the inference engine. How to specify where to allocate? Is it just hardcoded in the driver?
External Email
----------------------------------------------------------------------
25/01/2023 20:01, Jerin Jacob:
Quoted 18 lines · Thomas Monjalon
Quoted 8 lines
14/11/2022 13:02, [email protected]:
Quoted 6 lines
ML Model: An ML model is an algorithm trained over a dataset. A
model consists of procedure/algorithm and data/pattern required to make predictions on live data. Once the model is created and trained outside of the DPDK scope,
the model can be loaded viarte_ml_model_load()and then start it usingrte_ml_model_start()API. Therte_ml_model_params_update()can be used to update the model
parameters such as weight and bias without unloading the model usingrte_ml_model_unload().Quoted 8 lines
The fact that the model is prepared outside means the model format is free and probably different per mldev driver.
I think it is OK but it requires a lot of documentation effort to explain how to bind the model and its parameters with the DPDK API. Also we may need to pass some metadata from the model builder to the inference engine in order to enable optimizations prepared in the model. And the other way, we may need inference capabilities in order to generate an optimized model which can run in the inference engine.
Quoted 5 lines
The base API specification kept absolute minimum. Currently, weight and biases parameters updated through
rte_ml_model_params_update(). It can be extended when there are drivers supports it or if you have any specific parameter you would like to add it inrte_ml_model_params_update().
This function is
int rte_ml_model_params_update(int16_t dev_id, int16_t model_id, void *buffer);
How are we supposed to provide separate parameters in this void* ?
Just to clarify on what "parameters" mean, they just mean weights and biases of the model, which are the parameters for a model.
Also, the Proposed APIs are for running the inference on a pre-trained model. For running the inference the amount of parameters tuning needed/done is limited/none. The only parameters that get may get changed are the Weights and Bias which the API rte_ml_model_params_update() caters to.
While running the inference on a Model there won't be any random addition or removal of operators to/from the model or there won't be any changes in the actual flow of model. Since the only parameter that can be changed is Weights and Biases the above API should take care.
Quoted 1 line
Other metadata data like batch, shapes, formats queried using
rte_ml_io_info().
Copying:
+/** Input and output data information structure
+ *
+ * Specifies the type and shape of input and output data.
+ */
+struct rte_ml_io_info {
+ char name[RTE_ML_STR_MAX]; + /**< Name of data */ + struct rte_ml_io_shape shape; + /**< Shape of data */ + enum rte_ml_io_type qtype; + /**< Type of quantized data */ + enum rte_ml_io_type dtype; + /**< Type of de-quantized data */ };
Is it the right place to notify the app that some model optimizations are supported? (example: merge some operations in the graph)
The inference is run on a pre-trained model, which means any merges /additions of operations to the graph are NOT done.
If any such things are done then the changed model needs to go through the training and compilation once again which is out of scope of these APIs.
Quoted 17 lines
Quoted 17 lines
[...]
Quoted 15 lines
Typical application utilisation of the ML API will follow the following programming flow.
-
rte_ml_dev_configure()
-rte_ml_dev_queue_pair_setup()
-rte_ml_model_load()
-rte_ml_model_start()
-rte_ml_model_info()
-rte_ml_dev_start()
-rte_ml_enqueue_burst()
-rte_ml_dequeue_burst()
-rte_ml_model_stop()
-rte_ml_model_unload()
-rte_ml_dev_stop()
-rte_ml_dev_close()
Quoted 4 lines
Quoted 1 line
Where is parameters update in this flow?
Added the mandatory APIs in the top level flow doc.
rte_ml_model_params_update()used to update the parameters.
The question is "where" should it be done?
Before/after start?
The model image comes with the Weights and Bias and will be loaded and used as a part of rte_ml_model_load and rte_ml_model_start.
In rare scenarios where the user wants to update the Weights and Bias of an already loaded model, the rte_ml_model_stop can be called to stop the model and the Weights and Biases can be updated using the The parameters (Weights&Biases) can be updated when the rte_ml_model_params_update() API followed by rte_ml_model_start to start the model with the new Weights and Biases.
Quoted 5 lines
Quoted 1 line
Should we update all parameters at once or can it be done more fine-grain?
Currently,
rte_ml_model_params_update()can be used to update weight and bias via buffer when device is in stop state and without unloading the model.
The question is "can we update a single parameter"?
And how?
As mentioned above for running inference the model is already trained the only parameter that is updated is the Weights and Biases. "Parameters" is another word for Weights and Bias. No other parameters are considered.
Are there any other parameters you have on your mind?
Quoted 6 lines
Quoted 2 lines
Question about the memory used by mldev:
Can we manage where the memory is allocated (host, device, mix, etc)?Just passing buffer pointers now like other subsystem. Other EAL infra service can take care of the locality of memory as it is not specific to ML dev.
I was thinking about memory allocation required by the inference engine. How to specify where to allocate? Is it just hardcoded in the driver?
Any memory within the hardware is managed by the driver.
Quoted 107 lines · Shivah Shankar Shankar Narayan Rao
External Email
----------------------------------------------------------------------
25/01/2023 20:01, Jerin Jacob:Quoted 18 lines · Thomas Monjalon
Quoted 8 lines
14/11/2022 13:02, [email protected]:
Quoted 6 lines
ML Model: An ML model is an algorithm trained over a dataset. A
model consists of procedure/algorithm and data/pattern required to make predictions on live data. Once the model is created and trained outside of the DPDK scope,
the model can be loaded viarte_ml_model_load()and then start it usingrte_ml_model_start()API. Therte_ml_model_params_update()can be used to update the model
parameters such as weight and bias without unloading the model usingrte_ml_model_unload().Quoted 8 lines
The fact that the model is prepared outside means the model format is free and probably different per mldev driver.
I think it is OK but it requires a lot of documentation effort to explain how to bind the model and its parameters with the DPDK API. Also we may need to pass some metadata from the model builder to the inference engine in order to enable optimizations prepared in the model. And the other way, we may need inference capabilities in order to generate an optimized model which can run in the inference engine.Quoted 5 lines
The base API specification kept absolute minimum. Currently, weight and biases parameters updated through
rte_ml_model_params_update(). It can be extended when there are drivers supports it or if you have any specific parameter you would like to add it inrte_ml_model_params_update().This function is
intrte_ml_model_params_update(int16_t dev_id, int16_t model_id, void *buffer);How are we supposed to provide separate parameters in this void* ?
Just to clarify on what "parameters" mean, they just mean weights and biases of the model, which are the parameters for a model.
Also, the Proposed APIs are for running the inference on a pre-trained model. For running the inference the amount of parameters tuning needed/done is limited/none. The only parameters that get may get changed are the Weights and Bias which the APIrte_ml_model_params_update()caters to.While running the inference on a Model there won't be any random addition or removal of operators to/from the model or there won't be any changes in the actual flow of model. Since the only parameter that can be changed is Weights and Biases the above API should take care.
Quoted 1 line
Other metadata data like batch, shapes, formats queried using
rte_ml_io_info().Copying:
lib/mldev/rte_mldev.h new file +13
-0+/** Input and output data information structure +* +* Specifies the type and shape of input and output data. +*/ +struct rte_ml_io_info { +char name[RTE_ML_STR_MAX ]; +/**< Name of data */ +struct rte_ml_io_shape shape; +/**< Shape of data */ +enum rte_ml_io_type qtype; +/**< Type of quantized data */ +enum rte_ml_io_type dtype; +/**< Type of de-quantized data */ };Is it the right place to notify the app that some model optimizations are supported? (example: merge some operations in the graph)
The inference is run on a pre-trained model, which means any merges /additions of operations to the graph are NOT done.
If any such things are done then the changed model needs to go through the training and compilation once again which is out of scope of these APIs.Quoted 17 lines
Quoted 17 lines
[...]
Quoted 15 lines
Typical application utilisation of the ML API will follow the following programming flow.
-
rte_ml_dev_configure()
-rte_ml_dev_queue_pair_setup()
-rte_ml_model_load()
-rte_ml_model_start()
-rte_ml_model_info()
-rte_ml_dev_start()
-rte_ml_enqueue_burst()
-rte_ml_dequeue_burst()
-rte_ml_model_stop()
-rte_ml_model_unload()
-rte_ml_dev_stop()
-rte_ml_dev_close()Quoted 4 lines
Quoted 1 line
Where is parameters update in this flow?
Added the mandatory APIs in the top level flow doc.
rte_ml_model_params_update()used to update the parameters.The question is "where" should it be done?
Before/after start?The model image comes with the Weights and Bias and will be loaded and used as a part of
rte_ml_model_loadandrte_ml_model_start.
In rare scenarios where the user wants to update the Weights and Bias of an already loaded model, therte_ml_model_stopcan be called to stop the model and the Weights and Biases can be updated using the The parameters (Weights&Biases) can be updated when therte_ml_model_params_update()API followed byrte_ml_model_startto start the model with the new Weights and Biases.Quoted 5 lines
Quoted 1 line
Should we update all parameters at once or can it be done more fine-grain?
Currently,
rte_ml_model_params_update()can be used to update weight and bias via buffer when device is in stop state and without unloading the model.The question is "can we update a single parameter"?
And how?
As mentioned above for running inference the model is already trained the only parameter that is updated is the Weights and Biases. "Parameters" is another word for Weights and Bias. No other parameters are considered.Are there any other parameters you have on your mind?
Quoted 3 lines
Quoted 2 lines
Question about the memory used by mldev:
Can we manage where the memory is allocated (host, device, mix, etc)?
Quoted 8 lines
Quoted 3 lines
Just passing buffer pointers now like other subsystem. Other EAL infra service can take care of the locality of memory as it is not specific to ML dev.
I was thinking about memory allocation required by the inference engine. How to specify where to allocate? Is it just hardcoded in the driver?
Any memory within the hardware is managed by the driver.
I think, Thomas is asking input and output memory for interference. If so, the parameters for
struct rte_ml_buff_seg or needs to add type or so. Thomas, Please propose what parameters you want here.
In case if it is for internal driver memory, We can pass the memory type in rte_ml_dev_configure(), If so, please propose
the memory types you need and the parameters.
Quoted 2 lines
Hi,
Shivah Shankar, please quote your replies
so we can distinguish what I said from what you say.
Please try to understand my questions, you tend to reply to something else.
27/01/2023 05:29, Jerin Jacob:
Quoted 36 lines
Quoted 34 lines · Shivah Shankar Shankar Narayan Rao
25/01/2023 20:01, Jerin Jacob:
Quoted 32 lines · Thomas Monjalon
Quoted 20 lines
14/11/2022 13:02, [email protected]:
Quoted 9 lines
Quoted 9 lines
ML Model: An ML model is an algorithm trained over a dataset. A model consists of procedure/algorithm and data/pattern required to make predictions on live data. Once the model is created and trained outside of the DPDK scope,
the model can be loaded viarte_ml_model_load()and then start it usingrte_ml_model_start()API. Therte_ml_model_params_update()can be used to update the model
parameters such as weight and bias without unloading the model usingrte_ml_model_unload().> > > > >Quoted 9 lines
The fact that the model is prepared outside means the model format is free and probably different per mldev driver.
I think it is OK but it requires a lot of documentation effort to explain how to bind the model and its parameters with the DPDK API. Also we may need to pass some metadata from the model builder to the inference engine in order to enable optimizations prepared in the model.
And the other way, we may need inference capabilities in order to generate an optimized model which can run in the inference engine.Quoted 5 lines
The base API specification kept absolute minimum. Currently, weight and biases parameters updated through
rte_ml_model_params_update(). It can be extended when there are drivers supports it or if you have any specific parameter you would like to add it inrte_ml_model_params_update().This function is
intrte_ml_model_params_update(int16_t dev_id, int16_t model_id, void *buffer);How are we supposed to provide separate parameters in this void* ?
Quoted 7 lines
Quoted 7 lines
Just to clarify on what "parameters" mean,
they just mean weights and biases of the model, which are the parameters for a model.
Also, the Proposed APIs are for running the inference on a pre-trained model.
For running the inference the amount of parameters tuning needed/done is limited/none.
Why is it limited?
I think you are limiting to *your* model.
Quoted 2 lines
Quoted 2 lines
The only parameters that get may get changed are the Weights and Bias which the API
rte_ml_model_params_update()caters to.
We cannot imagine a model with more type of parameters?
Quoted 5 lines
Quoted 5 lines
While running the inference on a Model there won't be any random addition or removal of operators to/from the model or there won't be any changes in the actual flow of model.
Since the only parameter that can be changed is Weights and Biases the above API should take care.
No, you don't reply to my question.
I want to be able to change a single parameter.
I am expecting a more fine-grain API than a simple "void*". We could give the name of the parameter and a value, why not?
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 2 lines
Other metadata data like batch, shapes, formats queried using
rte_ml_io_info().Copying:
(quoted diff) +13
-0+/** Input and output data information structure + * + * Specifies the type and shape of input and output data. + */ +struct rte_ml_io_info { + char name[RTE_ML_STR_MAX]; + /**< Name of data */ + struct rte_ml_io_shape shape; + /**< Shape of data */ + enum rte_ml_io_type qtype; + /**< Type of quantized data */ + enum rte_ml_io_type dtype; + /**< Type of de-quantized data */ };
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Is it the right place to notify the app that some model optimizations are supported? (example: merge some operations in the graph)
The inference is run on a pre-trained model, which means any merges /additions of operations to the graph are NOT done. If any such things are done then the changed model needs to go through the training and compilation once again which is out of scope of these APIs.
Please try to understand what I am saying.
I want the application to be able to know some capabilities are supported by the inference driver.
So it will allow to generate the model with some optimizations.
Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
Quoted 17 lines
Quoted 17 lines
[...]
Quoted 15 lines
Typical application utilisation of the ML API will follow the following programming flow.
-
rte_ml_dev_configure()
-rte_ml_dev_queue_pair_setup()
-rte_ml_model_load()
-rte_ml_model_start()
-rte_ml_model_info()
-rte_ml_dev_start()
-rte_ml_enqueue_burst()
-rte_ml_dequeue_burst()
-rte_ml_model_stop()
-rte_ml_model_unload()
-rte_ml_dev_stop()
-rte_ml_dev_close()Quoted 4 lines
Quoted 1 line
Where is parameters update in this flow?
Added the mandatory APIs in the top level flow doc.
rte_ml_model_params_update()used to update the parameters.The question is "where" should it be done?
Before/after start?
Quoted 11 lines
Quoted 11 lines
The model image comes with the Weights and Bias and will be loaded and used as a part of
rte_ml_model_loadandrte_ml_model_start.
In rare scenarios where the user wants to update the Weights and Bias of an already loaded model, therte_ml_model_stopcan be called to stop the model and the Weights and Biases can be updated using the The parameters (Weights&Biases) can be updated when therte_ml_model_params_update()API followed byrte_ml_model_startto start the model with the new Weights and Biases.
OK please sure it is documented that parameters update must be done on a stopped engine.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Should we update all parameters at once or can it be done more fine-grain?
Currently,
rte_ml_model_params_update()can be used to update weight and bias via buffer when device is in stop state and without unloading the model.
Passing a raw buffer is a really dark API.
We need to know how to fill the buffer.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
The question is "can we update a single parameter"? And how?
As mentioned above for running inference the model is already trained the only parameter that is updated is the Weights and Biases. "Parameters" is another word for Weights and Bias.
No other parameters are considered.
You are not replying to the question.
How can we update a single parameter?
Quoted 1 line
Quoted 1 line
Are there any other parameters you have on your mind?
No
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Question about the memory used by mldev:
Can we manage where the memory is allocated (host, device, mix, etc)?Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Just passing buffer pointers now like other subsystem. Other EAL infra service can take care of the locality of memory as it is not specific to ML dev.
I was thinking about memory allocation required by the inference engine. How to specify where to allocate? Is it just hardcoded in the driver?
Any memory within the hardware is managed by the driver.
Quoted 7 lines
I think, Thomas is asking input and output memory for interference. If so, the parameters for
structrte_ml_buff_segor needs to add type or so. Thomas, Please propose what parameters you want here.
In case if it is for internal driver memory, We can pass the memory type inrte_ml_dev_configure(), If so, please propose
the memory types you need and the parameters.
I'm talking about the memory used by the driver to make the inference works. In some cases we may prefer the hardware using host memory, sometimes use the device memory.
I think that's something we may tune in the configuration.
I suppose we are fine with allocation hardcoded in the driver for now, as I don't have a clear need.
Quoted 54 lines · Thomas Monjalon
Hi,
Shivah Shankar, please quote your replies
so we can distinguish what I said from what you say.Please try to understand my questions, you tend to reply to something else.
27/01/2023 05:29, Jerin Jacob:
Quoted 36 lines
Quoted 34 lines · Shivah Shankar Shankar Narayan Rao
25/01/2023 20:01, Jerin Jacob:
Quoted 32 lines · Thomas Monjalon
Quoted 20 lines
14/11/2022 13:02, [email protected]:
Quoted 9 lines
Quoted 9 lines
ML Model: An ML model is an algorithm trained over a dataset. A model consists of procedure/algorithm and data/pattern required to make predictions on live data. Once the model is created and trained outside of the DPDK scope,
the model can be loaded viarte_ml_model_load()and then start it usingrte_ml_model_start()API. Therte_ml_model_params_update()can be used to update the model
parameters such as weight and bias without unloading the model usingrte_ml_model_unload().> > > > >Quoted 9 lines
The fact that the model is prepared outside means the model format is free and probably different per mldev driver.
I think it is OK but it requires a lot of documentation effort to explain how to bind the model and its parameters with the DPDK API. Also we may need to pass some metadata from the model builder to the inference engine in order to enable optimizations prepared in the model.
And the other way, we may need inference capabilities in order to generate an optimized model which can run in the inference engine.Quoted 5 lines
The base API specification kept absolute minimum. Currently, weight and biases parameters updated through
rte_ml_model_params_update(). It can be extended when there are drivers supports it or if you have any specific parameter you would like to add it inrte_ml_model_params_update().This function is
intrte_ml_model_params_update(int16_t dev_id, int16_t model_id, void *buffer);How are we supposed to provide separate parameters in this void* ?
Quoted 7 lines
Quoted 7 lines
Just to clarify on what "parameters" mean,
they just mean weights and biases of the model, which are the parameters for a model.
Also, the Proposed APIs are for running the inference on a pre-trained model.
For running the inference the amount of parameters tuning needed/done is limited/none.
Quoted 2 lines
Why is it limited?
I think you are limiting to *your* model.
See below.
Quoted 12 lines
Quoted 3 lines
Quoted 3 lines
The only parameters that get may get changed are the Weights and Bias which the API
rte_ml_model_params_update()caters to.We cannot imagine a model with more type of parameters?
Quoted 5 lines
Quoted 5 lines
While running the inference on a Model there won't be any random addition or removal of operators to/from the model or there won't be any changes in the actual flow of model.
Since the only parameter that can be changed is Weights and Biases the above API should take care.
Quoted 4 lines
No, you don't reply to my question.
I want to be able to change a single parameter.
I am expecting a more fine-grain API than a simple "void*". We could give the name of the parameter and a value, why not?
The current API model is follows
1)The model is developed outside DPDK and binary file is loaded via rte_ml_model_load()
2)The modes "read only" capabilities like shape or quantized data can be read throughrte_ml_model_info_get() API. If you wish to advertise any other capability for optimization etc
please give inline reply around rte_ml_io_info for the parameter and its comment.
We can review and add it.
3)Now comes the parameter, which is the "update" on the model which loaded prior via rte_ml_model_load() .
Also, it created outside DPDK. User have an "update" to the parameter when we have new set of training happens.
Currently we are assuming this as single blob due to that fact that It is model specific and it just continues
stream of bytes from model and thus void* is given.
If you have use case or your model support more parameter update as separate blob, we should
able to update rte_ml_model_params_update() as needed. Please suggest the new rte_ml_model_params_type enum or so. We can add that to rte_ml_model_params_update().
Also, if you have concrete data type instead of void* for given TYPE. Please propose the structure
for that as well, We should be able to update struct rte_ml_dev_info for these capabilities
to abstract the models or inference engine differences.
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 3 lines
Other metadata data like batch, shapes, formats queried using
rte_ml_io_info().Copying:
(quoted diff) +13
-0+/** Input and output data information structure + * + * Specifies the type and shape of input and output data. + */ +struct rte_ml_io_info { + char name[RTE_ML_STR_MAX]; + /**< Name of data */ + struct rte_ml_io_shape shape; + /**< Shape of data */ + enum rte_ml_io_type qtype; + /**< Type of quantized data */ + enum rte_ml_io_type dtype; + /**< Type of de-quantized data */ };Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Is it the right place to notify the app that some model optimizations are supported? (example: merge some operations in the graph)
The inference is run on a pre-trained model, which means any merges /additions of operations to the graph are NOT done. If any such things are done then the changed model needs to go through the training and compilation once again which is out of scope of these APIs.
Quoted 4 lines
Please try to understand what I am saying.
I want the application to be able to know some capabilities are supported by the inference driver.
So it will allow to generate the model with some optimizations.
See above. Yes, this place to add that. Please propose any changes that you want to add.
Quoted 38 lines
Quoted 26 lines
Quoted 26 lines
Quoted 25 lines
Quoted 18 lines
Quoted 18 lines
[...]
Quoted 15 lines
Typical application utilisation of the ML API will follow the following programming flow.
-
rte_ml_dev_configure()
-rte_ml_dev_queue_pair_setup()
-rte_ml_model_load()
-rte_ml_model_start()
-rte_ml_model_info()
-rte_ml_dev_start()
-rte_ml_enqueue_burst()
-rte_ml_dequeue_burst()
-rte_ml_model_stop()
-rte_ml_model_unload()
-rte_ml_dev_stop()
-rte_ml_dev_close()Quoted 4 lines
Quoted 1 line
Where is parameters update in this flow?
Added the mandatory APIs in the top level flow doc.
rte_ml_model_params_update()used to update the parameters.The question is "where" should it be done?
Before/after start?Quoted 11 lines
Quoted 11 lines
The model image comes with the Weights and Bias and will be loaded and used as a part of
rte_ml_model_loadandrte_ml_model_start.
In rare scenarios where the user wants to update the Weights and Bias of an already loaded model, therte_ml_model_stopcan be called to stop the model and the Weights and Biases can be updated using the The parameters (Weights&Biases) can be updated when therte_ml_model_params_update()API followed byrte_ml_model_startto start the model with the new Weights and Biases.
Quoted 2 lines
OK please sure it is documented that parameters update must be done on a stopped engine.
The doc is already there in the exisitng patch. Please see
+/**
+ * Update the model parameters without unloading model.
+ *
+ * Update model parameters such as weights and bias without unloading the model.
+ * rte_ml_model_stop() must be called before invoking this API.
+ *
+ * @param[in] dev_id
+ * The identifier of the device.
+ * @param[in] model_id
+ * Identifier for the model created
+ * @param[in] buffer
+ * Pointer to the model weights and bias buffer.
+ * Size of the buffer is equal to wb_size returned in *rte_ml_model_info*.
+ *
+ * @return
+ * - Returns 0 on success
+ * - Returns negative value on failure
+ */
+__rte_experimental
+int
+rte_ml_model_params_update(int16_t dev_id, int16_t model_id, void *buffer);
Quoted 10 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Should we update all parameters at once or can it be done more fine-grain?
Currently,
rte_ml_model_params_update()can be used to update weight and bias via buffer when device is in stop state and without unloading the model.Passing a raw buffer is a really dark API.
We need to know how to fill the buffer.
See above, Currently it is model specific and model is spitting out the paramater
blob update after the traning or so. DPDK interfence engine API is a means to transport these blob from model to ML engine.
Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
The question is "can we update a single parameter"? And how?
As mentioned above for running inference the model is already trained the only parameter that is updated is the Weights and Biases. "Parameters" is another word for Weights and Bias.
No other parameters are considered.You are not replying to the question.
How can we update a single parameter?
See above.
I see main comments are on param update and get the capablities. To enable that, please propose the changes around rte_ml_model_params_update(), rte_ml_model_info. We should able to take that and send v2.
Quoted 26 lines
Quoted 2 lines
Quoted 2 lines
Are there any other parameters you have on your mind?
No
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Question about the memory used by mldev:
Can we manage where the memory is allocated (host, device, mix, etc)?Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Just passing buffer pointers now like other subsystem. Other EAL infra service can take care of the locality of memory as it is not specific to ML dev.
I was thinking about memory allocation required by the inference engine. How to specify where to allocate? Is it just hardcoded in the driver?
Any memory within the hardware is managed by the driver.
Quoted 7 lines
I think, Thomas is asking input and output memory for interference. If so, the parameters for
structrte_ml_buff_segor needs to add type or so. Thomas, Please propose what parameters you want here.
In case if it is for internal driver memory, We can pass the memory type inrte_ml_dev_configure(), If so, please propose
the memory types you need and the parameters.
Quoted 6 lines
I'm talking about the memory used by the driver to make the inference works. In some cases we may prefer the hardware using host memory, sometimes use the device memory.
I think that's something we may tune in the configuration.
I suppose we are fine with allocation hardcoded in the driver for now, as I don't have a clear need.
OK.
Quoted 2 lines
28/01/2023 12:27, Jerin Jacob:
Quoted 3 lines
I see main comments are on param update and get the capablities. To enable that, please propose the changes around
rte_ml_model_params_update(),rte_ml_model_info. We should able to take that and send v2.
Sorry I don't have the bandwidth to work on mldev now.
I understand you took the easy path of opaque pointer, and you are OK to refine it if needed.
Because there is not much reviews, I think we should merge it as-is and keep it experimental the time needed to have more feedbacks and a second vendor implementing it.
Quoted 7 lines · Thomas Monjalon
28/01/2023 12:27, Jerin Jacob:
Quoted 3 lines
I see main comments are on param update and get the capablities. To enable that, please propose the changes around
rte_ml_model_params_update(),rte_ml_model_info. We should able to take that and send v2.Sorry I don't have the bandwidth to work on mldev now.
Understandable.
Quoted 1 line
I understand you took the easy path of opaque pointer,
I would say not easy path, rather the use case I am not aware of and the model that we are supporting.
Quoted 1 line
and you are OK to refine it if needed.
Yes
Quoted 3 lines
Because there is not much reviews, I think we should merge it as-is and keep it experimental the time needed to have more feedbacks and a second vendor implementing it.
Ack.I think, it is reasonable the first patch was pushed on Aug3. It was around 6 months for reviews.
https://inbox.dpdk.org/dev/[email protected]/
Quoted 2 lines
v2 cover mldev: introduce machine learning device library
In reply to [email protected]From: Jerin Jacob <[email protected]>
Machine learning inference library
==================================
Definition of machine learning inference
----------------------------------------
Inference in machine learning is the process of making an output prediction based on new input data using a pre-trained machine learning model.
The scope of the RFC would include only inferencing with pre-trained machine learning models, training and building/compiling the ML models is out of scope for this RFC or DPDK mldev API. Use existing machine learning compiler frameworks for model creation.
Motivation for the new library
------------------------------
Multiple semiconductor vendors are offering accelerator products such as DPU (often called Smart-NIC), FPGA, GPU, etc., which have ML inferencing capabilities integrated as part of the product. Use of ML inferencing is increasing in the domain of packet processing for flow classification, intrusion, malware and anomaly detection.
Lack of inferencing support through DPDK APIs will involve complexities and increased latency from moving data across frameworks (i.e, dataplane to non dataplane ML frameworks and vice-versa). Having a standardized DPDK APIs for ML inferencing would enable the dataplane solutions to harness the benefit of inline inferencing supported by the hardware.
Contents
---------------
A) API specification for:
1) Discovery of ML capabilities (e.g., device specific features) in a vendor independent fashion
2) Definition of functions to handle ML devices, which includes probing, initialization and termination of the devices.
3) Definition of functions to handle ML models used to perform inference operations.
4) Definition of function to handle quantize and dequantize operations
B) Common code for above specification
rfc..v1:
- Added programmer guide documentation
- Added implementation for common code
v2..v1:
- Moved dynamic log (Stephen)
- model id to uint16_t from int16t_t (Stephen)
- added release note updates
Machine learning library framework
----------------------------------
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()
| +-------------+ |<------- 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 ML device API for running inferences using a pre-trained ML model.
ML Model: An ML model is an algorithm trained over a dataset. A model consists of procedure/algorithm and data/pattern required to make predictions on live data. Once the model is created and trained outside of the DPDK scope, the model can be loaded via rte_ml_model_load() and then start it using rte_ml_model_start() API. The rte_ml_model_params_update() can be used to update the model parameters such as weight and bias without unloading the model using rte_ml_model_unload().
ML Inference: ML inference is the process of feeding data to the model via rte_ml_enqueue_burst() API and use rte_ml_dequeue_burst() API to get the calculated outputs/predictions from the started model.
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 setup a device designated by its device identifier must be invoked in the following order:
- 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. Application needs to invoke the ML model API in the following order before queueing inference jobs.
- rte_ml_model_load()
- rte_ml_model_start()
The rte_ml_model_info() API is provided to retrieve the information related to the model. The information would include the shape and type of input and output required for the inference.
Data quantization and dequantization is one of the main aspects in ML domain. This involves conversion of 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.
Two utility APIs rte_ml_io_input_size_get() and rte_ml_io_output_size_get() can used to get the size of quantized and de-quantized multi-batch input and output buffers.
User can optionally update the model parameters with rte_ml_model_params_update() after invoking rte_ml_model_stop() API on a given model ID.
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 application must stop the device using rte_ml_dev_stop() API. Likewise, if model parameters need to be updated then the application must call rte_ml_model_stop() followed by 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.
Once the device is in the start state after invoking rte_ml_dev_start() API and the model is in start state after invoking rte_ml_model_start() API, then the application can call rte_ml_enqueue() and rte_ml_dequeue() API on the destined device and model ID.
Finally, an application can close an ML device by invoking the rte_ml_dev_close() function.
Typical application utilisation of the ML API will follow the following programming flow.
- rte_ml_dev_configure()
- rte_ml_dev_queue_pair_setup()
- rte_ml_model_load()
- rte_ml_model_start()
- rte_ml_model_info()
- rte_ml_dev_start()
- 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 to not be 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 same queue pair. Of course, this function can be invoked in parallel by different logical core on different queue pair.
It is the responsibility of the user application to enforce this rule.
Example application usage for ML inferencing
--------------------------------------------
This example application is to demonstrate the programming model of ML device library. This example omits the error checks to simplify the application. This example also assumes that the input data received is quantized and output expected is also quantized. In order to handle non-quantized inputs and outputs, users can invoke rte_ml_io_quantize() or rte_ml_io_dequantize() for data type conversions.
#define ML_MODEL_NAME "model"
#define IO_MZ "io_mz"
struct app_ctx {
char model_file[PATH_MAX];
char inp_file[PATH_MAX];
char out_file[PATH_MAX];
struct rte_ml_model_params params;
struct rte_ml_model_info info;
uint16_t id;
uint64_t input_size;
uint64_t output_size;
uint8_t *input_buffer;
uint8_t *output_buffer;
} __rte_cache_aligned;struct app_ctx ctx;
static intparse_args(int argc, char **argv)
{
int opt, option_index;
static struct option lgopts[] = {{"model", required_argument, NULL, 'm'},
{"input", required_argument, NULL, 'i'},
{"output", required_argument, NULL, 'o'},
{NULL, 0, NULL, 0}};
while ((opt = getopt_long(argc, argv, "m:i:o:", lgopts, &option_index)) != EOF)
switch (opt) {
case 'm':
strncpy(ctx.model_file, optarg, PATH_MAX - 1);
break;
case 'i':
strncpy(ctx.inp_file, optarg, PATH_MAX - 1);
break;
case 'o':
strncpy(ctx.out_file, optarg, PATH_MAX - 1);
break;
default:
return -1;
}
return 0;
}intmain(int argc, char **argv)
{
struct rte_ml_dev_qp_conf qp_conf;
struct rte_ml_dev_config config;
struct rte_ml_dev_info dev_info;
const struct rte_memzone *mz;
struct rte_mempool *op_pool;
struct rte_ml_op *op_enq;
struct rte_ml_op *op_deq;
FILE *fp;
int rc;
/* Initialize EAL */
rc = rte_eal_init(argc, argv);
if (rc < 0)
rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n");
argc -= rc;
argv += rc;
/* Parse application arguments (after the EAL args) */
if (parse_args(argc, argv) < 0)
rte_exit(EXIT_FAILURE, "Invalid application arguments\n");
/* Step 1: Check for ML devices */
if (rte_ml_dev_count() <= 0)
rte_exit(EXIT_FAILURE, "Failed to find ML devices\n");
/* Step 2: Get device info */
if (rte_ml_dev_info_get(0, &dev_info) != 0)
rte_exit(EXIT_FAILURE, "Failed to get device info\n");
/* Step 3: Configure ML device, use device 0 */
config.socket_id = rte_ml_dev_socket_id(0);
config.max_nb_models = dev_info.max_models;
config.nb_queue_pairs = dev_info.max_queue_pairs;
if (rte_ml_dev_configure(0, &config) != 0)
rte_exit(EXIT_FAILURE, "Device configuration failed\n");
/* Step 4: Setup queue pairs, used qp_id = 0 */
qp_conf.nb_desc = 1;
if (rte_ml_dev_queue_pair_setup(0, 0, &qp_conf, config.socket_id) != 0)
rte_exit(EXIT_FAILURE, "Queue-pair setup failed\n");
/* Step 5: Start device */
if (rte_ml_dev_start(0) != 0)
rte_exit(EXIT_FAILURE, "Device start failed\n");
/* Step 6: Read model data and update load params structure */
fp = fopen(ctx.model_file, "r+");
if (fp == NULL)
rte_exit(EXIT_FAILURE, "Failed to open model file\n");
fseek(fp, 0, SEEK_END);
ctx.params.size = ftell(fp);
fseek(fp, 0, SEEK_SET);
ctx.params.addr = malloc(ctx.params.size);
if (fread(ctx.params.addr, 1, ctx.params.size, fp) != ctx.params.size){
fclose(fp);
rte_exit(EXIT_FAILURE, "Failed to read model\n");
}
fclose(fp);
strcpy(ctx.params.name, ML_MODEL_NAME);
/* Step 7: Load the model */
if (rte_ml_model_load(0, &ctx.params, &ctx.id) != 0)
rte_exit(EXIT_FAILURE, "Failed to load model\n");
free(ctx.params.addr);
/* Step 8: Start the model */
if (rte_ml_model_start(0, ctx.id) != 0)
rte_exit(EXIT_FAILURE, "Failed to start model\n");
/* Step 9: Allocate buffers for quantized input and output */
/* Get model information */
if (rte_ml_model_info_get(0, ctx.id, &ctx.info) != 0)
rte_exit(EXIT_FAILURE, "Failed to get model info\n");
/* Get the buffer size for input and output */
rte_ml_io_input_size_get(0, ctx.id, ctx.info.batch_size, &ctx.input_size, NULL);
rte_ml_io_output_size_get(0, ctx.id, ctx.info.batch_size, &ctx.output_size, NULL);
mz = rte_memzone_reserve(IO_MZ, ctx.input_size + ctx.output_size, config.socket_id, 0);
if (mz == NULL)
rte_exit(EXIT_FAILURE, "Failed to create IO memzone\n");
ctx.input_buffer = mz->addr;
ctx.output_buffer = ctx.input_buffer + ctx.input_size;
/* Step 10: Fill the input data */
fp = fopen(ctx.inp_file, "r+");
if (fp == NULL)
rte_exit(EXIT_FAILURE, "Failed to open input file\n");
if (fread(ctx.input_buffer, 1, ctx.input_size, fp) != ctx.input_size) {
fclose(fp);
rte_exit(EXIT_FAILURE, "Failed to read input file\n");
}
fclose(fp);
/* Step 11: Create ML op mempool */
op_pool = rte_ml_op_pool_create("ml_op_pool", 1, 0, 0, config.socket_id);
if (op_pool == NULL)
rte_exit(EXIT_FAILURE, "Failed to create op pool\n");
/* Step 12: Form an ML op */
rte_mempool_get_bulk(op_pool, (void *)op_enq, 1);
op_enq->model_id = ctx.id;
op_enq->nb_batches = ctx.info.batch_size;
op_enq->mempool = op_pool;
op_enq->input.addr = ctx.input_buffer;
op_enq->input.length = ctx.input_size;
op_enq->input.next = NULL;
op_enq->output.addr = ctx.output_buffer;
op_enq->output.length = ctx.output_size;
op_enq->output.next = NULL;
/* Step 13: Enqueue jobs */
rte_ml_enqueue_burst(0, 0, &op_enq, 1);
/* Step 14: Dequeue jobs and release op pool */
while (rte_ml_dequeue_burst(0, 0, &op_deq, 1) != 1)
;
/* Step 15: Write output */
fp = fopen(ctx.out_file, "w+");
if (fp == NULL)
rte_exit(EXIT_FAILURE, "Failed to open output file\n");
fwrite(ctx.output_buffer, 1, ctx.output_size, fp);
fclose(fp);
/* Step 16: Clean up */
/* Stop ML model */
rte_ml_model_stop(0, ctx.id);
/* Unload ML model */
rte_ml_model_unload(0, ctx.id);
/* Free input/output memory */
rte_memzone_free(rte_memzone_lookup(IO_MZ));
/* Free the ml op back to pool */
rte_mempool_put_bulk(op_pool, (void *)op_deq, 1);
/* Free ml op pool */
rte_mempool_free(op_pool);
/* Stop the device */
rte_ml_dev_stop(0);
rte_ml_dev_close(0);
rte_eal_cleanup();
return 0;
}Jerin Jacob (1):
mldev: introduce machine learning device library
Srikanth Yalavarthi (11):
mldev: support PMD functions for ML device
mldev: support ML device handling functions
mldev: support ML device queue-pair setup
mldev: support handling ML models
mldev: support input and output data handling
mldev: support ML op pool and ops
mldev: support inference enqueue and dequeue
mldev: support device statistics
mldev: support device extended statistics
mldev: support to retrieve error information
mldev: support to get debug info and test device
MAINTAINERS | 5 + config/rte_config.h | 3 + doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + doc/guides/prog_guide/img/mldev_flow.svg | 714 ++++++++++++++ doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/mldev.rst | 186 ++++ doc/guides/rel_notes/release_23_03.rst | 5 + lib/meson.build | 1 + lib/mldev/meson.build | 27 + lib/mldev/rte_mldev.c | 905 ++++++++++++++++++ lib/mldev/rte_mldev.h | 1099 ++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 720 ++++++++++++++ lib/mldev/rte_mldev_pmd.c | 62 ++ lib/mldev/rte_mldev_pmd.h | 151 +++ lib/mldev/version.map | 50 + 16 files changed, 3931 insertions(+) create mode 100644 doc/guides/prog_guide/img/mldev_flow.svg create mode 100644 doc/guides/prog_guide/mldev.rst create mode 100644 lib/mldev/meson.build create mode 100644 lib/mldev/rte_mldev.c create mode 100644 lib/mldev/rte_mldev.h create mode 100644 lib/mldev/rte_mldev_core.h create mode 100644 lib/mldev/rte_mldev_pmd.c create mode 100644 lib/mldev/rte_mldev_pmd.h create mode 100644 lib/mldev/version.map
Signature · 1 line
2.39.1
PATCH v2 1/12 mldev: introduce machine learning device library
From: Jerin Jacob <[email protected]>
Add mldev API specification to standardize and use the machine learning device and inference operations in vendor neutral way.
Following operations are abstracted through APIs
- ML device capability probe
- ML device configuration
- ML device queue pair configuration
- ML device state management
- ML device stat/xstat operations
- ML model load/unload/start/stop operations
- ML model information probe
- ML IO operations to find size for input and output buffers
- ML quantize and dequantize operations
- ML ops pool creation and free operations
- ML device enqueue/dequeue fastpath interference operations
Also added programming guide.
--- MAINTAINERS | 5 + config/rte_config.h | 3 + doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + doc/guides/prog_guide/img/mldev_flow.svg | 714 ++++++++++++++ doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/mldev.rst | 186 ++++ doc/guides/rel_notes/release_23_03.rst | 5 + lib/meson.build | 1 + lib/mldev/meson.build | 18 + lib/mldev/rte_mldev.c | 8 + lib/mldev/rte_mldev.h | 1099 ++++++++++++++++++++++ lib/mldev/version.map | 7 + 13 files changed, 2049 insertions(+) create mode 100644 doc/guides/prog_guide/img/mldev_flow.svg create mode 100644 doc/guides/prog_guide/mldev.rst create mode 100644 lib/mldev/meson.build create mode 100644 lib/mldev/rte_mldev.c create mode 100644 lib/mldev/rte_mldev.h create mode 100644 lib/mldev/version.map
MAINTAINERS +5 -0
@@ -538,6 +538,11 @@ F: drivers/raw/skeleton/ F: app/test/test_rawdev.c F: doc/guides/prog_guide/rawdev.rst +ML device API - EXPERIMENTAL +M: Srikanth Yalavarthi <[email protected]> +F: lib/mldev/ +F: doc/guides/prog_guide/mldev.rst + Memory Pool Drivers -------------------
config/rte_config.h +3 -0
@@ -82,6 +82,9 @@/* rawdev defines */ #define RTE_RAWDEV_MAX_DEVS 64 +/* mldev defines */ +#define RTE_MLDEV_MAX_DEVS 64 +/* ip_fragmentation defines */ #define RTE_LIBRTE_IP_FRAG_MAX_FRAG 8// RTE_LIBRTE_IP_FRAG_TBL_STAT is not set
doc/api/doxy-api-index.md +1 -0
@@ -22,6 +22,7 @@ The public API headers are grouped by topics: [compress](@ref rte_comp.h), [regexdev](@ref rte_regexdev.h), [dmadev](@ref rte_dmadev.h), + [mldev](@ref rte_mldev.h), [eventdev](@ref rte_eventdev.h), [event_eth_rx_adapter](@ref rte_event_eth_rx_adapter.h), [event_eth_tx_adapter](@ref rte_event_eth_tx_adapter.h),
doc/api/doxy-api.conf.in +1 -0
@@ -57,6 +57,7 @@ INPUT = @TOPDIR@/doc/api/doxy-api-index.md \ @TOPDIR@/lib/mempool \ @TOPDIR@/lib/meter \ @TOPDIR@/lib/metrics \ + @TOPDIR@/lib/mldev \ @TOPDIR@/lib/node \ @TOPDIR@/lib/net \ @TOPDIR@/lib/pcapng \
doc/guides/prog_guide/img/mldev_flow.svg new file +714 -0
714 lines not on this page · raw message
doc/guides/prog_guide/index.rst +1 -0
@@ -30,6 +30,7 @@ Programmer's Guide regexdev dmadev gpudev + mldev rte_security rawdev link_bonding_poll_mode_drv_lib
doc/guides/prog_guide/mldev.rst new file +186 -0
186 lines not on this page · raw message
doc/guides/rel_notes/release_23_03.rst +5 -0
@@ -78,6 +78,11 @@ New Features ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter required for eth_rx, eth_tx, crypto and timer eventdev adapters. +* **Added machine learning inference device library.** + + * Added a machine learning inference device framework for management and provision of + hardware and software machine learning inference devices. + Removed Items -------------
lib/meson.build +1 -0
@@ -63,6 +63,7 @@ libraries = [ 'flow_classify', # flow_classify lib depends on pkt framework table lib 'graph', 'node', + 'mldev', ] optional_libs = [
lib/mldev/meson.build new file +18 -0
@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2022 Marvell. + +sources = files( + 'rte_mldev.c', +) + +headers = files( + 'rte_mldev.h', +) + +deps += ['mempool'] + +if get_option('buildtype').contains('debug') + cflags += [ '-DRTE_LIBRTE_ML_DEV_DEBUG' ] +else + cflags += [ '-URTE_LIBRTE_ML_DEV_DEBUG' ] +endif
lib/mldev/rte_mldev.c new file +8 -0
@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (c) 2022 Marvell. +*/ + +#include <rte_log.h> +#include <rte_mldev.h> + +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev.h new file +1099 -0
1,099 lines not on this page · raw message
lib/mldev/version.map new file +7 -0
@@ -0,0 +1,7 @@ +EXPERIMENTAL { + global: + + rte_ml_dev_logtype; + + local: *; +};
Signature · 1 line
2.39.1
PATCH v2 2/12 mldev: support PMD functions for ML device
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added PMD functions to handle ML devices. The rte_mldev_pmd.* files are for drivers only and should be private to DPDK, and are not installed for application use.
--- lib/mldev/meson.build | 9 +++ lib/mldev/rte_mldev.c | 129 ++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 111 +++++++++++++++++++++++++++ lib/mldev/rte_mldev_pmd.c | 62 +++++++++++++++ lib/mldev/rte_mldev_pmd.h | 149 +++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 11 +++ 6 files changed, 471 insertions(+) create mode 100644 lib/mldev/rte_mldev_core.h create mode 100644 lib/mldev/rte_mldev_pmd.c create mode 100644 lib/mldev/rte_mldev_pmd.h
lib/mldev/meson.build +9 -0
@@ -2,6 +2,7 @@ # Copyright (c) 2022 Marvell. sources = files( + 'rte_mldev_pmd.c', 'rte_mldev.c', )
@@ -9,6 +10,14 @@ headers = files( 'rte_mldev.h', ) +indirect_headers += files( + 'rte_mldev_core.h', +) + +driver_sdk_headers += files( + 'rte_mldev_pmd.h', +) + deps += ['mempool'] if get_option('buildtype').contains('debug')
lib/mldev/rte_mldev.c +129 -0
134 lines not on this page · raw message
lib/mldev/rte_mldev_core.h new file +111 -0
111 lines not on this page · raw message
lib/mldev/rte_mldev_pmd.c new file +62 -0
62 lines not on this page · raw message
lib/mldev/rte_mldev_pmd.h new file +149 -0
149 lines not on this page · raw message
lib/mldev/version.map +11 -0
@@ -5,3 +5,14 @@ EXPERIMENTAL { local: *; }; + +INTERNAL { + global: + + rte_ml_dev_pmd_allocate; + rte_ml_dev_pmd_create; + rte_ml_dev_pmd_destroy; + rte_ml_dev_pmd_get_dev; + rte_ml_dev_pmd_get_named_dev; + rte_ml_dev_pmd_release; +};
Signature · 1 line
2.39.1
Re: [dpdk-dev] [PATCH v2 02/12] mldev: support PMD functions for ML device
Quoted 2 lines · On Tue, 7 Feb 2023 01:54:43 +0530 <[email protected]> wrote:
+static struct
rte_ml_devml_devices[RTE_MLDEV_MAX_DEVS];
This will reserve space for 64 devices, but almost all users will only have one. Maybe a level of indirection and allocate as needed?
You could even use a single allocation for the pmd and device private data portion.
lib/mldev/rte_mldev_core.h line 42
Quoted 4 lines
+ */
lib/mldev/rte_mldev_core.h new file +3
-0+struct rte_ml_dev_data { +/** Unique identifier name. */ +char name[RTE_ML_STR_MAX ];
Why is name first, it is the least used field. Might want it to be last for cache locality.
lib/mldev/rte_mldev_core.h line 69
Quoted 2 lines
lib/mldev/rte_mldev_core.h new file +2
-0+/** Reserved for future fields */ +uint64_t reserved[3 ];
Reserved fields have been a problem in the past.
Why do this? Are thy just available pad elements to be cache line size?
And why bother being cache aligned for an info struct?
Re: [dpdk-dev] [PATCH v2 02/12] mldev: support PMD functions for ML device
06/02/2023 22:04, Stephen Hemminger:
Quoted 11 lines
Quoted 2 lines · On Tue, 7 Feb 2023 01:54:43 +0530 <[email protected]> wrote:
+static struct
rte_ml_devml_devices[RTE_MLDEV_MAX_DEVS];This will reserve space for 64 devices, but almost all users will only have one. Maybe a level of indirection and allocate as needed?
You could even use a single allocation for the pmd and device private data portion.
I like what we did for GPU class: rte_gpu_init(size_t dev_max) If not called by the app, it is called automatically with a default size. So you can have a small default and there is no compilation settings.
Re: [dpdk-dev] [PATCH v2 02/12] mldev: support PMD functions for ML device
In reply to Stephen HemmingerQuoted 9 lines · Stephen Hemminger
Quoted 2 lines · On Tue, 7 Feb 2023 01:54:43 +0530 <[email protected]> wrote:
+static struct
rte_ml_devml_devices[RTE_MLDEV_MAX_DEVS];This will reserve space for 64 devices, but almost all users will only have one. Maybe a level of indirection and allocate as needed?
As Thomas suggested, I will add something similar to rte_gpu_init()
Quoted 4 lines
You could even use a single allocation for the pmd and device private data portion.
Quoted 8 lines
lib/mldev/rte_mldev_core.h line 42
Quoted 4 lines
+ */
lib/mldev/rte_mldev_core.h new file +3
-0+struct rte_ml_dev_data { +/** Unique identifier name. */ +char name[RTE_ML_STR_MAX ];Why is name first, it is the least used field. Might want it to be last for cache locality.
It is slowpath, does not matter. But there is no harm in moving end of it. I will move to end of the structure.
Quoted 5 lines
lib/mldev/rte_mldev_core.h line 69
Quoted 3 lines
lib/mldev/rte_mldev_core.h new file +2
-0+/** Reserved for future fields */ +uint64_t reserved[3 ];Reserved fields have been a problem in the past.
Will remove it.
Quoted 1 line
Why do this? Are thy just available pad elements to be cache line size?
Yes.
Quoted 2 lines
And why bother being cache aligned for an info struct?
We can remove it. Will removing reserved and cache aligned.
Quoted 1 line
PATCH v2 3/12 mldev: support ML device handling functions
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added ML device handling APIs. These APIs are used to get device information, configure, start, stop and close ML devices. Added function prototypes to PMD layer which are used by the ML driver implementations in the poll mode driver.
--- lib/mldev/rte_mldev.c | 175 +++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 107 +++++++++++++++++++++++ lib/mldev/version.map | 8 ++ 3 files changed, 290 insertions(+)
lib/mldev/rte_mldev.c +175 -0
@@ -134,4 +134,179 @@ rte_ml_dev_pmd_release(struct rte_ml_dev *dev)return ret; } +uint16_t +rte_ml_dev_count (void ) +{ +return ml_dev_globals.nb_devs; +} + +int +rte_ml_dev_is_valid_dev (int16_t dev_id) +{ +struct rte_ml_dev *dev =NULL ; + +if (dev_id >= ml_dev_globals.max_devs || ml_devices[dev_id].data ==NULL ) +return 0 ; + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (dev->attached !=ML_DEV_ATTACHED ) +return 0 ; +else +return 1 ; +} + +int +rte_ml_dev_socket_id (int16_t dev_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); + +return dev->data->socket_id; +} + +int +rte_ml_dev_info_get (int16_t dev_id,struct rte_ml_dev_info *dev_info) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_info_get ==NULL ) +return -ENOTSUP ; + +if (dev_info ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, dev_info cannot be NULL\n" , dev_id); +return -EINVAL ; + } +memset (dev_info,0 ,sizeof (struct rte_ml_dev_info )); + +return (*dev->dev_ops->dev_info_get)(dev, dev_info); +} + +int +rte_ml_dev_configure (int16_t dev_id,const struct rte_ml_dev_config *config) +{ +struct rte_ml_dev_info dev_info; +struct rte_ml_dev *dev; +int ret; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_configure ==NULL ) +return -ENOTSUP ; + +if (dev->data->dev_started) { +RTE_MLDEV_LOG (ERR ,"Device %d must be stopped to allow configuration" , dev_id); +return -EBUSY ; + } + +if (config ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, config cannot be NULL\n" , dev_id); +return -EINVAL ; + } + + ret =rte_ml_dev_info_get (dev_id, &dev_info); +if (ret <0 ) +return ret; + +if (config->nb_queue_pairs > dev_info.max_queue_pairs) { +RTE_MLDEV_LOG (ERR ,"Device %d num of queues %u > %u\n" , dev_id, + config->nb_queue_pairs, dev_info.max_queue_pairs); +return -EINVAL ; + } + +return (*dev->dev_ops->dev_configure)(dev, config); +} + +int +rte_ml_dev_close (int16_t dev_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_close ==NULL ) +return -ENOTSUP ; + +/* Device must be stopped before it can be closed */ +if (dev->data->dev_started ==1 ) { +RTE_MLDEV_LOG (ERR ,"Device %d must be stopped before closing" , dev_id); +return -EBUSY ; + } + +return (*dev->dev_ops->dev_close)(dev); +} + +int +rte_ml_dev_start (int16_t dev_id) +{ +struct rte_ml_dev *dev; +int ret; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_start ==NULL ) +return -ENOTSUP ; + +if (dev->data->dev_started !=0 ) { +RTE_MLDEV_LOG (ERR ,"Device %d is already started" , dev_id); +return -EBUSY ; + } + + ret = (*dev->dev_ops->dev_start)(dev); +if (ret ==0 ) + dev->data->dev_started =1 ; + +return ret; +} + +int +rte_ml_dev_stop (int16_t dev_id) +{ +struct rte_ml_dev *dev; +int ret; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_stop ==NULL ) +return -ENOTSUP ; + +if (dev->data->dev_started ==0 ) { +RTE_MLDEV_LOG (ERR ,"Device %d is not started" , dev_id); +return -EBUSY ; + } + + ret = (*dev->dev_ops->dev_stop)(dev); +if (ret ==0 ) + dev->data->dev_started =0 ; + +return ret; +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev_core.h +107 -0
119 lines not on this page · raw message
lib/mldev/version.map +8 -0
@@ -1,7 +1,15 @@ EXPERIMENTAL { global: + rte_ml_dev_close; + rte_ml_dev_configure; + rte_ml_dev_count; + rte_ml_dev_info_get; + rte_ml_dev_is_valid_dev; rte_ml_dev_logtype; + rte_ml_dev_socket_id; + rte_ml_dev_start; + rte_ml_dev_stop; local: *; };
Signature · 1 line
2.39.1
PATCH v2 4/12 mldev: support ML device queue-pair setup
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added APIs to create a queue-pair attached to ML device. Queue pairs are created with a user specified ID. Added function prototypes to be used by ML drivers for queue pair create and destroy.
--- lib/mldev/rte_mldev.c | 33 ++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 44 ++++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 1 + 3 files changed, 78 insertions(+)
lib/mldev/rte_mldev.c +33 -0
@@ -309,4 +309,37 @@ rte_ml_dev_stop(int16_t dev_id)return ret; } +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) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_queue_pair_setup ==NULL ) +return -ENOTSUP ; + +if (queue_pair_id >= dev->data->nb_queue_pairs) { +RTE_MLDEV_LOG (ERR ,"Invalid queue_pair_id = %d" , queue_pair_id); +return -EINVAL ; + } + +if (qp_conf ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, qp_conf cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (dev->data->dev_started) { +RTE_MLDEV_LOG (ERR ,"Device %d must be stopped to allow configuration" , dev_id); +return -EBUSY ; + } + +return (*dev->dev_ops->dev_queue_pair_setup)(dev, queue_pair_id, qp_conf, socket_id); +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev_core.h +44 -0
56 lines not on this page · raw message
lib/mldev/version.map +1 -0
@@ -7,6 +7,7 @@ EXPERIMENTAL { rte_ml_dev_info_get; rte_ml_dev_is_valid_dev; rte_ml_dev_logtype; + rte_ml_dev_queue_pair_setup; rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stop;
Signature · 1 line
2.39.1
PATCH v2 5/12 mldev: support handling ML models
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added RTE functions to handle ML models. These APIs can load, unload, start, and stop an ML model. Additional APIs to update model parameters and get model information are added.
--- lib/mldev/rte_mldev.c | 123 +++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 122 ++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 6 ++ 3 files changed, 251 insertions(+)
lib/mldev/rte_mldev.c +123 -0
@@ -342,4 +342,127 @@ rte_ml_dev_queue_pair_setup(int16_t dev_id, uint16_t queue_pair_id,return (*dev->dev_ops->dev_queue_pair_setup)(dev, queue_pair_id, qp_conf, socket_id); } +int +rte_ml_model_load (int16_t dev_id,struct rte_ml_model_params *params,uint16_t *model_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_load ==NULL ) +return -ENOTSUP ; + +if (params ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, params cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (model_id ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, model_id cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->model_load)(dev, params, model_id); +} + +int +rte_ml_model_unload (int16_t dev_id,uint16_t model_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_unload ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->model_unload)(dev, model_id); +} + +int +rte_ml_model_start (int16_t dev_id,uint16_t model_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_start ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->model_start)(dev, model_id); +} + +int +rte_ml_model_stop (int16_t dev_id,uint16_t model_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_stop ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->model_stop)(dev, model_id); +} + +int +rte_ml_model_info_get (int16_t dev_id,uint16_t model_id,struct rte_ml_model_info *model_info) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_info_get ==NULL ) +return -ENOTSUP ; + +if (model_info ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, model_id %u, model_info cannot be NULL\n" , dev_id, + model_id); +return -EINVAL ; + } + +return (*dev->dev_ops->model_info_get)(dev, model_id, model_info); +} + +int +rte_ml_model_params_update (int16_t dev_id,uint16_t model_id,void *buffer) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_params_update ==NULL ) +return -ENOTSUP ; + +if (buffer ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, buffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->model_params_update)(dev, model_id, buffer); +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev_core.h +122 -0
134 lines not on this page · raw message
lib/mldev/version.map +6 -0
@@ -11,6 +11,12 @@ EXPERIMENTAL { rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stop; + rte_ml_model_info_get; + rte_ml_model_load; + rte_ml_model_params_update; + rte_ml_model_start; + rte_ml_model_stop; + rte_ml_model_unload; local: *; };
Signature · 1 line
2.39.1
PATCH v2 6/12 mldev: support input and output data handling
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added library functions to handle model input and output data. The APIs can be used to get the size of I/O buffers, quantize input data and dequantize output data.
--- lib/mldev/rte_mldev.c | 94 ++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 106 +++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 4 ++ 3 files changed, 204 insertions(+)
lib/mldev/rte_mldev.c +94 -0
@@ -465,4 +465,98 @@ rte_ml_model_params_update(int16_t dev_id, uint16_t model_id, void *buffer)return (*dev->dev_ops->model_params_update)(dev, model_id, buffer); } +int +rte_ml_io_input_size_get (int16_t dev_id,uint16_t model_id,uint32_t nb_batches, +uint64_t *input_qsize,uint64_t *input_dsize) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->io_input_size_get ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->io_input_size_get)(dev, model_id, nb_batches, input_qsize, + input_dsize); +} + +int +rte_ml_io_output_size_get (int16_t dev_id,uint16_t model_id,uint32_t nb_batches, +uint64_t *output_qsize,uint64_t *output_dsize) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->io_output_size_get ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->io_output_size_get)(dev, model_id, nb_batches, output_qsize, + output_dsize); +} + +int +rte_ml_io_quantize (int16_t dev_id,uint16_t model_id,uint16_t nb_batches,void *dbuffer, +void *qbuffer) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->io_quantize ==NULL ) +return -ENOTSUP ; + +if (dbuffer ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, dbuffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (qbuffer ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, qbuffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->io_quantize)(dev, model_id, nb_batches, dbuffer, qbuffer); +} + +int +rte_ml_io_dequantize (int16_t dev_id,uint16_t model_id,uint16_t nb_batches,void *qbuffer, +void *dbuffer) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->io_dequantize ==NULL ) +return -ENOTSUP ; + +if (qbuffer ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, qbuffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (dbuffer ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, dbuffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->io_dequantize)(dev, model_id, nb_batches, qbuffer, dbuffer); +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev_core.h +106 -0
118 lines not on this page · raw message
lib/mldev/version.map +4 -0
@@ -11,6 +11,10 @@ EXPERIMENTAL { rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stop; + rte_ml_io_dequantize; + rte_ml_io_input_size_get; + rte_ml_io_output_size_get; + rte_ml_io_quantize; rte_ml_model_info_get; rte_ml_model_load; rte_ml_model_params_update;
Signature · 1 line
2.39.1
PATCH v2 7/12 mldev: support ML op pool and ops
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added library functions to create and free ML op pool. Create function allocates new ML op pool and initializes ML ops to their defaults.
--- lib/mldev/rte_mldev.c | 69 +++++++++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 2 ++ 2 files changed, 71 insertions(+)
lib/mldev/rte_mldev.c +69 -0
@@ -11,6 +11,17 @@ static struct rte_ml_dev ml_devices[RTE_MLDEV_MAX_DEVS];static struct rte_ml_dev_global ml_dev_globals = { .devs = ml_devices, .data = {NULL }, .nb_devs =0 , .max_devs =RTE_MLDEV_MAX_DEVS }; +/* +* Private data structure of an operation pool. +* +* A structure that contains ml op_pool specific data that is +* appended after the mempool structure (in private data). +*/ +struct rte_ml_op_pool_private { +uint16_t user_size; +/*< Size of private user data with each operation. */ +}; +struct rte_ml_dev *rte_ml_dev_pmd_get_dev (int16_t dev_id) {
@@ -559,4 +570,62 @@ rte_ml_io_dequantize(int16_t dev_id, uint16_t model_id, uint16_t nb_batches, voireturn (*dev->dev_ops->io_dequantize)(dev, model_id, nb_batches, qbuffer, dbuffer); } +/** Initialise rte_ml_op mempool element */ +static void +ml_op_init(struct rte_mempool *mempool, __rte_unused void *opaque_arg, void *_op_data, + __rte_unused unsigned int i) +{ +struct rte_ml_op *op = _op_data; + +memset (_op_data,0 , mempool->elt_size); + op->status =RTE_ML_OP_STATUS_NOT_PROCESSED ; + op->mempool = mempool; +} + +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) +{ +struct rte_ml_op_pool_private *priv; +struct rte_mempool *mp; +unsigned int elt_size; + +/* lookup mempool in case already allocated */ + mp =rte_mempool_lookup (name); + elt_size =sizeof (struct rte_ml_op ) + user_size; + +if (mp !=NULL ) { + priv = (struct rte_ml_op_pool_private *)rte_mempool_get_priv (mp); +if (mp->elt_size != elt_size || mp->cache_size < cache_size || mp->size < nb_elts || + priv->user_size < user_size) { + mp =NULL ; +RTE_MLDEV_LOG (ERR , +"Mempool %s already exists but with incompatible parameters" , + name); +return NULL ; + } +return mp; + } + + mp =rte_mempool_create (name, nb_elts, elt_size, cache_size, +sizeof (struct rte_ml_op_pool_private ),NULL ,NULL , ml_op_init,NULL , + socket_id,0 ); +if (mp ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Failed to create mempool %s" , name); +return NULL ; + } + + priv = (struct rte_ml_op_pool_private *)rte_mempool_get_priv (mp); + priv->user_size = user_size; + +return mp; +} + +void +rte_ml_op_pool_free (struct rte_mempool *mempool) +{ +if (mempool !=NULL ) +rte_mempool_free (mempool); +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/version.map +2 -0
@@ -21,6 +21,8 @@ EXPERIMENTAL { rte_ml_model_start; rte_ml_model_stop; rte_ml_model_unload; + rte_ml_op_pool_create; + rte_ml_op_pool_free; local: *; };
Signature · 1 line
2.39.1
PATCH v2 8/12 mldev: support inference enqueue and dequeue
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added implementations of fast-path functions to enqueue and dequeue ML requests from an ML device queue-pair.
--- lib/mldev/rte_mldev.c | 76 ++++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 46 +++++++++++++++++++++++ lib/mldev/rte_mldev_pmd.h | 2 + lib/mldev/version.map | 2 + 4 files changed, 126 insertions(+)
lib/mldev/rte_mldev.c +76 -0
@@ -2,6 +2,7 @@* Copyright (c) 2022 Marvell. */ +#include <rte_errno.h> #include <rte_log.h> #include <rte_mldev.h> #include <rte_mldev_pmd.h>
@@ -107,6 +108,9 @@ rte_ml_dev_pmd_allocate(const char *name, uint8_t socket_id) ml_dev_globals.nb_devs++; } + dev->enqueue_burst =NULL ; + dev->dequeue_burst =NULL ; +return dev; }
@@ -628,4 +632,76 @@ rte_ml_op_pool_free(struct rte_mempool *mempool)rte_mempool_free (mempool); } +uint16_t +rte_ml_enqueue_burst (int16_t dev_id,uint16_t qp_id,struct rte_ml_op **ops,uint16_t nb_ops) +{ +struct rte_ml_dev *dev; + +#ifdef RTE_LIBRTE_ML_DEV_DEBUG +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); + rte_errno = -EINVAL ; +return 0 ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->enqueue_burst ==NULL ) { + rte_errno = -ENOTSUP ; +return 0 ; + } + +if (ops ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, ops cannot be NULL\n" , dev_id); + rte_errno = -EINVAL ; +return 0 ; + } + +if (qp_id >= dev->data->nb_queue_pairs) { +RTE_MLDEV_LOG (ERR ,"Invalid qp_id %u\n" , qp_id); + rte_errno = -EINVAL ; +return 0 ; + } +#else + dev =rte_ml_dev_pmd_get_dev (dev_id); +#endif + +return (*dev->enqueue_burst)(dev, qp_id, ops, nb_ops); +} + +uint16_t +rte_ml_dequeue_burst (int16_t dev_id,uint16_t qp_id,struct rte_ml_op **ops,uint16_t nb_ops) +{ +struct rte_ml_dev *dev; + +#ifdef RTE_LIBRTE_ML_DEV_DEBUG +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); + rte_errno = -EINVAL ; +return 0 ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dequeue_burst ==NULL ) { + rte_errno = -ENOTSUP ; +return 0 ; + } + +if (ops ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, ops cannot be NULL\n" , dev_id); + rte_errno = -EINVAL ; +return 0 ; + } + +if (qp_id >= dev->data->nb_queue_pairs) { +RTE_MLDEV_LOG (ERR ,"Invalid qp_id %u\n" , qp_id); + rte_errno = -EINVAL ; +return 0 ; + } +#else + dev =rte_ml_dev_pmd_get_dev (dev_id); +#endif + +return (*dev->dequeue_burst)(dev, qp_id, ops, nb_ops); +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev_core.h +46 -0
58 lines not on this page · raw message
lib/mldev/rte_mldev_pmd.h +2 -0
@@ -40,6 +40,8 @@ struct rte_ml_dev_pmd_init_params {uint64_t private_data_size; }; +struct rte_ml_dev ; +/** * @internal *
lib/mldev/version.map +2 -0
@@ -1,6 +1,7 @@ EXPERIMENTAL { global: + rte_ml_dequeue_burst; rte_ml_dev_close; rte_ml_dev_configure; rte_ml_dev_count;
@@ -11,6 +12,7 @@ EXPERIMENTAL { rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stop; + rte_ml_enqueue_burst; rte_ml_io_dequantize; rte_ml_io_input_size_get; rte_ml_io_output_size_get;
Signature · 1 line
2.39.1
PATCH v2 9/12 mldev: support device statistics
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added functions to get and reset device stats. Device stats include number of requests enqueued, dequeued and errors. Added function prototypes to used by driver implementations.
--- lib/mldev/rte_mldev.c | 40 ++++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 32 ++++++++++++++++++++++++++++++ lib/mldev/version.map | 2 ++ 3 files changed, 74 insertions(+)
lib/mldev/rte_mldev.c +40 -0
@@ -357,6 +357,46 @@ rte_ml_dev_queue_pair_setup(int16_t dev_id, uint16_t queue_pair_id,return (*dev->dev_ops->dev_queue_pair_setup)(dev, queue_pair_id, qp_conf, socket_id); } +int +rte_ml_dev_stats_get (int16_t dev_id,struct rte_ml_dev_stats *stats) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_stats_get ==NULL ) +return -ENOTSUP ; + +if (stats ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, stats cannot be NULL\n" , dev_id); +return -EINVAL ; + } +memset (stats,0 ,sizeof (struct rte_ml_dev_stats )); + +return (*dev->dev_ops->dev_stats_get)(dev, stats); +} + +void +rte_ml_dev_stats_reset (int16_t dev_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_stats_reset ==NULL ) +return ; + + (*dev->dev_ops->dev_stats_reset)(dev); +} +int rte_ml_model_load (int16_t dev_id,struct rte_ml_model_params *params,uint16_t *model_id) {
lib/mldev/rte_mldev_core.h +32 -0
@@ -191,6 +191,32 @@ typedef int (*mldev_queue_pair_setup_t)(struct rte_ml_dev *dev, uint16_t queue_p*/ typedef int (*mldev_queue_pair_release_t )(struct rte_ml_dev *dev,uint16_t queue_pair_id); +/** +* @internal +* +* Function used to get device statistics. +* +* @param dev +* ML device pointer. +* @param stats +* Pointer to ML device stats structure to update. +* +* @return +* - 0 on success. +* - < 0, error on failure. +*/ +typedef int (*mldev_stats_get_t )(struct rte_ml_dev *dev,struct rte_ml_dev_stats *stats); + +/** +* @internal +* +* Function used to reset device statistics. +* +* @param dev +* ML device pointer. +*/ +typedef void (*mldev_stats_reset_t )(struct rte_ml_dev *dev); +/** * @internal *
@@ -416,6 +442,12 @@ struct rte_ml_dev_ops {/** Release a device queue pair. */ mldev_queue_pair_release_t dev_queue_pair_release; +/** Get device statistics. */ +mldev_stats_get_t dev_stats_get; + +/** Reset device statistics. */ +mldev_stats_reset_t dev_stats_reset; +/** Load an ML model. */ mldev_model_load_t model_load;
lib/mldev/version.map +2 -0
@@ -11,6 +11,8 @@ EXPERIMENTAL { rte_ml_dev_queue_pair_setup; rte_ml_dev_socket_id; rte_ml_dev_start; + rte_ml_dev_stats_get; + rte_ml_dev_stats_reset; rte_ml_dev_stop; rte_ml_enqueue_burst; rte_ml_io_dequantize;
Signature · 1 line
2.39.1
PATCH v2 10/12 mldev: support device extended statistics
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added functions to handle device extended stats. xstats supported are driver specific and can include stats specific to ML device or ML model and I/O. Added prototypes for functions to be called by the device drivers.
--- lib/mldev/rte_mldev.c | 88 ++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 93 ++++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 4 ++ 3 files changed, 185 insertions(+)
lib/mldev/rte_mldev.c +88 -0
@@ -397,6 +397,94 @@ rte_ml_dev_stats_reset(int16_t dev_id) (*dev->dev_ops->dev_stats_reset)(dev); } +int +rte_ml_dev_xstats_names_get (int16_t dev_id,struct rte_ml_dev_xstats_map *xstats_map,uint32_t size) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_xstats_names_get ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->dev_xstats_names_get)(dev, xstats_map, size); +} + +int +rte_ml_dev_xstats_by_name_get (int16_t dev_id,const char *name,uint16_t *stat_id,uint64_t *value) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_xstats_by_name_get ==NULL ) +return -ENOTSUP ; + +if (name ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, name cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (value ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, value cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->dev_xstats_by_name_get)(dev, name, stat_id, value); +} + +int +rte_ml_dev_xstats_get (int16_t dev_id,const uint16_t *stat_ids,uint64_t *values,uint16_t nb_ids) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_xstats_get ==NULL ) +return -ENOTSUP ; + +if (stat_ids ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, stat_ids cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (values ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, values cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->dev_xstats_get)(dev, stat_ids, values, nb_ids); +} + +int +rte_ml_dev_xstats_reset (int16_t dev_id,const uint16_t *stat_ids,uint16_t nb_ids) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_xstats_reset ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->dev_xstats_reset)(dev, stat_ids, nb_ids); +} +int rte_ml_model_load (int16_t dev_id,struct rte_ml_model_params *params,uint16_t *model_id) {
lib/mldev/rte_mldev_core.h +93 -0
105 lines not on this page · raw message
lib/mldev/version.map +4 -0
@@ -14,6 +14,10 @@ EXPERIMENTAL { rte_ml_dev_stats_get; rte_ml_dev_stats_reset; rte_ml_dev_stop; + rte_ml_dev_xstats_by_name_get; + rte_ml_dev_xstats_get; + rte_ml_dev_xstats_names_get; + rte_ml_dev_xstats_reset; rte_ml_enqueue_burst; rte_ml_io_dequantize; rte_ml_io_input_size_get;
Signature · 1 line
2.39.1
PATCH v2 11/12 mldev: support to retrieve error information
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added functions to get error information for an ML op. This information can include both drive specific error message and error code.
--- lib/mldev/rte_mldev.c | 31 +++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 22 ++++++++++++++++++++++ lib/mldev/version.map | 1 + 3 files changed, 54 insertions(+)
lib/mldev/rte_mldev.c +31 -0
@@ -832,4 +832,35 @@ rte_ml_dequeue_burst(int16_t dev_id, uint16_t qp_id, struct rte_ml_op **ops, uinreturn (*dev->dequeue_burst)(dev, qp_id, ops, nb_ops); } +int +rte_ml_op_error_get (int16_t dev_id,struct rte_ml_op *op,struct rte_ml_op_error *error) +{ +struct rte_ml_dev *dev; + +#ifdef RTE_LIBRTE_ML_DEV_DEBUG +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->op_error_get ==NULL ) +return -ENOTSUP ; + +if (op ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, op cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (error ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, error cannot be NULL\n" , dev_id); +return -EINVAL ; + } +#else + dev =rte_ml_dev_pmd_get_dev (dev_id); +#endif + +return (*dev->op_error_get)(dev, op, error); +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev_core.h +22 -0
@@ -73,6 +73,25 @@ typedef uint16_t (*mldev_enqueue_t)(struct rte_ml_dev *dev, uint16_t qp_id, strutypedef uint16_t (*mldev_dequeue_t )(struct rte_ml_dev *dev,uint16_t qp_id,struct rte_ml_op **ops,uint16_t nb_ops); +/** +* @internal +* +* Get error information for an Op. +* +* @param dev +* ML device pointer. +* @param op +* ML Op handle. +* @param error +* Pointer to error structure. +* +* @return +* - 0 on success. +* - <0, error on failure. +*/ +typedef int (*mldev_op_error_get_t )(struct rte_ml_dev *dev,struct rte_ml_op *op, +struct rte_ml_op_error *error); +/** * Definitions of all functions exported by a driver through the generic structure of type * *ml_dev_ops* supplied in the *rte_ml_dev* structure associated with a device.
@@ -622,6 +641,9 @@ struct rte_ml_dev {/** Pointer to PMD dequeue function. */ mldev_dequeue_t dequeue_burst; +/** Pointer to PMD Op error get function. */ +mldev_op_error_get_t op_error_get; +/** Pointer to device data. */ struct rte_ml_dev_data *data;
lib/mldev/version.map +1 -0
@@ -29,6 +29,7 @@ EXPERIMENTAL { rte_ml_model_start; rte_ml_model_stop; rte_ml_model_unload; + rte_ml_op_error_get; rte_ml_op_pool_create; rte_ml_op_pool_free;
Signature · 1 line
2.39.1
PATCH v2 12/12 mldev: support to get debug info and test device
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added functions for ML device debug APIs. The APIs
are used to dump ML device debug information and to run selftest.
--- lib/mldev/rte_mldev.c | 39 ++++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 37 ++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 2 ++ 3 files changed, 78 insertions(+)
lib/mldev/rte_mldev.c +39 -0
@@ -485,6 +485,45 @@ rte_ml_dev_xstats_reset(int16_t dev_id, const uint16_t *stat_ids, uint16_t nb_idreturn (*dev->dev_ops->dev_xstats_reset)(dev, stat_ids, nb_ids); } +int +rte_ml_dev_dump (int16_t dev_id,FILE *fd) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_dump ==NULL ) +return -ENOTSUP ; + +if (fd ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, file descriptor cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->dev_dump)(dev, fd); +} + +int +rte_ml_dev_selftest (int16_t dev_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_selftest ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->dev_selftest)(dev); +} +int rte_ml_model_load (int16_t dev_id,struct rte_ml_model_params *params,uint16_t *model_id) {
lib/mldev/rte_mldev_core.h +37 -0
@@ -317,6 +317,37 @@ typedef int (*mldev_xstats_get_t)(struct rte_ml_dev *dev, const uint16_t *stat_itypedef int (*mldev_xstats_reset_t )(struct rte_ml_dev *dev,const uint16_t *stat_ids,uint16_t nb_ids); +/** +* @internal +* +* Function used to dump ML device debug info. +* +* @param dev +* ML device pointer. +* @param fd +* File descriptor to dump the debug info. +* +* @return +* - 0 on success. +* - < 0, error code on failure. +*/ + +typedef int (*mldev_dump_t )(struct rte_ml_dev *dev,FILE *fd); + +/** +* @internal +* +* Function used for selftest of ML device. +* +* @param dev +* ML device pointer. +* +* @return +* - 0 on success. +* - < 0, error on failure. +*/ +typedef int (*mldev_selftest_t )(struct rte_ml_dev *dev); +/** * @internal *
@@ -560,6 +591,12 @@ struct rte_ml_dev_ops {/** Reset extended stats of the device. */ mldev_xstats_reset_t dev_xstats_reset; +/** Dump ML device debug info. */ +mldev_dump_t dev_dump; + +/** Dump ML device debug info. */ +mldev_selftest_t dev_selftest; +/** Load an ML model. */ mldev_model_load_t model_load;
lib/mldev/version.map +2 -0
@@ -5,10 +5,12 @@ EXPERIMENTAL { rte_ml_dev_close; rte_ml_dev_configure; rte_ml_dev_count; + rte_ml_dev_dump; rte_ml_dev_info_get; rte_ml_dev_is_valid_dev; rte_ml_dev_logtype; rte_ml_dev_queue_pair_setup; + rte_ml_dev_selftest; rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stats_get;
Signature · 1 line
2.39.1
v3 cover mldev: introduce machine learning device library
In reply to [email protected]From: Jerin Jacob <[email protected]>
Machine learning inference library
==================================
Definition of machine learning inference
----------------------------------------
Inference in machine learning is the process of making an output prediction based on new input data using a pre-trained machine learning model.
The scope of the RFC would include only inferencing with pre-trained machine learning models, training and building/compiling the ML models is out of scope for this RFC or DPDK mldev API. Use existing machine learning compiler frameworks for model creation.
Motivation for the new library
------------------------------
Multiple semiconductor vendors are offering accelerator products such as DPU (often called Smart-NIC), FPGA, GPU, etc., which have ML inferencing capabilities integrated as part of the product. Use of ML inferencing is increasing in the domain of packet processing for flow classification, intrusion, malware and anomaly detection.
Lack of inferencing support through DPDK APIs will involve complexities and increased latency from moving data across frameworks (i.e, dataplane to non dataplane ML frameworks and vice-versa). Having a standardized DPDK APIs for ML inferencing would enable the dataplane solutions to harness the benefit of inline inferencing supported by the hardware.
Contents
---------------
A) API specification for:
1) Discovery of ML capabilities (e.g., device specific features) in a vendor independent fashion
2) Definition of functions to handle ML devices, which includes probing, initialization and termination of the devices.
3) Definition of functions to handle ML models used to perform inference operations.
4) Definition of function to handle quantize and dequantize operations
B) Common code for above specification
rfc..v1:
- Added programmer guide documentation
- Added implementation for common code
v2..v1:
- Moved dynamic log (Stephen)
- model id to uint16_t from int16t_t (Stephen)
- added release note updates
v3..v2:
- Introduced rte_ml_dev_init() similar to rte_gpu_init() (Stephen, Thomas)
- In struct rte_ml_dev_data, removed reserved[3] and __rte_cache_aligned.
Also, moved name field to the end(Stephen)
Machine learning library framework
----------------------------------
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()
| +-------------+ |<------- 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 ML device API for running inferences using a pre-trained ML model.
ML Model: An ML model is an algorithm trained over a dataset. A model consists of procedure/algorithm and data/pattern required to make predictions on live data. Once the model is created and trained outside of the DPDK scope, the model can be loaded via rte_ml_model_load() and then start it using rte_ml_model_start() API. The rte_ml_model_params_update() can be used to update the model parameters such as weight and bias without unloading the model using rte_ml_model_unload().
ML Inference: ML inference is the process of feeding data to the model via rte_ml_enqueue_burst() API and use rte_ml_dequeue_burst() API to get the calculated outputs/predictions from the started model.
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 setup a device designated by its device identifier must be invoked in the following order:
- 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. Application needs to invoke the ML model API in the following order before queueing inference jobs.
- rte_ml_model_load()
- rte_ml_model_start()
The rte_ml_model_info() API is provided to retrieve the information related to the model. The information would include the shape and type of input and output required for the inference.
Data quantization and dequantization is one of the main aspects in ML domain. This involves conversion of 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.
Two utility APIs rte_ml_io_input_size_get() and rte_ml_io_output_size_get() can used to get the size of quantized and de-quantized multi-batch input and output buffers.
User can optionally update the model parameters with rte_ml_model_params_update() after invoking rte_ml_model_stop() API on a given model ID.
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 application must stop the device using rte_ml_dev_stop() API. Likewise, if model parameters need to be updated then the application must call rte_ml_model_stop() followed by 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.
Once the device is in the start state after invoking rte_ml_dev_start() API and the model is in start state after invoking rte_ml_model_start() API, then the application can call rte_ml_enqueue() and rte_ml_dequeue() API on the destined device and model ID.
Finally, an application can close an ML device by invoking the rte_ml_dev_close() function.
Typical application utilisation of the ML API will follow the following programming flow.
- rte_ml_dev_configure()
- rte_ml_dev_queue_pair_setup()
- rte_ml_model_load()
- rte_ml_model_start()
- rte_ml_model_info()
- rte_ml_dev_start()
- 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 to not be 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 same queue pair. Of course, this function can be invoked in parallel by different logical core on different queue pair.
It is the responsibility of the user application to enforce this rule.
Example application usage for ML inferencing
--------------------------------------------
This example application is to demonstrate the programming model of ML device library. This example omits the error checks to simplify the application. This example also assumes that the input data received is quantized and output expected is also quantized. In order to handle non-quantized inputs and outputs, users can invoke rte_ml_io_quantize() or rte_ml_io_dequantize() for data type conversions.
#define ML_MODEL_NAME "model"
#define IO_MZ "io_mz"
struct app_ctx {
char model_file[PATH_MAX];
char inp_file[PATH_MAX];
char out_file[PATH_MAX];
struct rte_ml_model_params params;
struct rte_ml_model_info info;
uint16_t id;
uint64_t input_size;
uint64_t output_size;
uint8_t *input_buffer;
uint8_t *output_buffer;
} __rte_cache_aligned;struct app_ctx ctx;
static intparse_args(int argc, char **argv)
{
int opt, option_index;
static struct option lgopts[] = {{"model", required_argument, NULL, 'm'},
{"input", required_argument, NULL, 'i'},
{"output", required_argument, NULL, 'o'},
{NULL, 0, NULL, 0}};
while ((opt = getopt_long(argc, argv, "m:i:o:", lgopts, &option_index)) != EOF)
switch (opt) {
case 'm':
strncpy(ctx.model_file, optarg, PATH_MAX - 1);
break;
case 'i':
strncpy(ctx.inp_file, optarg, PATH_MAX - 1);
break;
case 'o':
strncpy(ctx.out_file, optarg, PATH_MAX - 1);
break;
default:
return -1;
}
return 0;
}intmain(int argc, char **argv)
{
struct rte_ml_dev_qp_conf qp_conf;
struct rte_ml_dev_config config;
struct rte_ml_dev_info dev_info;
const struct rte_memzone *mz;
struct rte_mempool *op_pool;
struct rte_ml_op *op_enq;
struct rte_ml_op *op_deq;
FILE *fp;
int rc;
/* Initialize EAL */
rc = rte_eal_init(argc, argv);
if (rc < 0)
rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n");
argc -= rc;
argv += rc;
/* Parse application arguments (after the EAL args) */
if (parse_args(argc, argv) < 0)
rte_exit(EXIT_FAILURE, "Invalid application arguments\n");
/* Step 1: Check for ML devices */
if (rte_ml_dev_count() <= 0)
rte_exit(EXIT_FAILURE, "Failed to find ML devices\n");
/* Step 2: Get device info */
if (rte_ml_dev_info_get(0, &dev_info) != 0)
rte_exit(EXIT_FAILURE, "Failed to get device info\n");
/* Step 3: Configure ML device, use device 0 */
config.socket_id = rte_ml_dev_socket_id(0);
config.max_nb_models = dev_info.max_models;
config.nb_queue_pairs = dev_info.max_queue_pairs;
if (rte_ml_dev_configure(0, &config) != 0)
rte_exit(EXIT_FAILURE, "Device configuration failed\n");
/* Step 4: Setup queue pairs, used qp_id = 0 */
qp_conf.nb_desc = 1;
if (rte_ml_dev_queue_pair_setup(0, 0, &qp_conf, config.socket_id) != 0)
rte_exit(EXIT_FAILURE, "Queue-pair setup failed\n");
/* Step 5: Start device */
if (rte_ml_dev_start(0) != 0)
rte_exit(EXIT_FAILURE, "Device start failed\n");
/* Step 6: Read model data and update load params structure */
fp = fopen(ctx.model_file, "r+");
if (fp == NULL)
rte_exit(EXIT_FAILURE, "Failed to open model file\n");
fseek(fp, 0, SEEK_END);
ctx.params.size = ftell(fp);
fseek(fp, 0, SEEK_SET);
ctx.params.addr = malloc(ctx.params.size);
if (fread(ctx.params.addr, 1, ctx.params.size, fp) != ctx.params.size){
fclose(fp);
rte_exit(EXIT_FAILURE, "Failed to read model\n");
}
fclose(fp);
strcpy(ctx.params.name, ML_MODEL_NAME);
/* Step 7: Load the model */
if (rte_ml_model_load(0, &ctx.params, &ctx.id) != 0)
rte_exit(EXIT_FAILURE, "Failed to load model\n");
free(ctx.params.addr);
/* Step 8: Start the model */
if (rte_ml_model_start(0, ctx.id) != 0)
rte_exit(EXIT_FAILURE, "Failed to start model\n");
/* Step 9: Allocate buffers for quantized input and output */
/* Get model information */
if (rte_ml_model_info_get(0, ctx.id, &ctx.info) != 0)
rte_exit(EXIT_FAILURE, "Failed to get model info\n");
/* Get the buffer size for input and output */
rte_ml_io_input_size_get(0, ctx.id, ctx.info.batch_size, &ctx.input_size, NULL);
rte_ml_io_output_size_get(0, ctx.id, ctx.info.batch_size, &ctx.output_size, NULL);
mz = rte_memzone_reserve(IO_MZ, ctx.input_size + ctx.output_size, config.socket_id, 0);
if (mz == NULL)
rte_exit(EXIT_FAILURE, "Failed to create IO memzone\n");
ctx.input_buffer = mz->addr;
ctx.output_buffer = ctx.input_buffer + ctx.input_size;
/* Step 10: Fill the input data */
fp = fopen(ctx.inp_file, "r+");
if (fp == NULL)
rte_exit(EXIT_FAILURE, "Failed to open input file\n");
if (fread(ctx.input_buffer, 1, ctx.input_size, fp) != ctx.input_size) {
fclose(fp);
rte_exit(EXIT_FAILURE, "Failed to read input file\n");
}
fclose(fp);
/* Step 11: Create ML op mempool */
op_pool = rte_ml_op_pool_create("ml_op_pool", 1, 0, 0, config.socket_id);
if (op_pool == NULL)
rte_exit(EXIT_FAILURE, "Failed to create op pool\n");
/* Step 12: Form an ML op */
rte_mempool_get_bulk(op_pool, (void *)op_enq, 1);
op_enq->model_id = ctx.id;
op_enq->nb_batches = ctx.info.batch_size;
op_enq->mempool = op_pool;
op_enq->input.addr = ctx.input_buffer;
op_enq->input.length = ctx.input_size;
op_enq->input.next = NULL;
op_enq->output.addr = ctx.output_buffer;
op_enq->output.length = ctx.output_size;
op_enq->output.next = NULL;
/* Step 13: Enqueue jobs */
rte_ml_enqueue_burst(0, 0, &op_enq, 1);
/* Step 14: Dequeue jobs and release op pool */
while (rte_ml_dequeue_burst(0, 0, &op_deq, 1) != 1)
;
/* Step 15: Write output */
fp = fopen(ctx.out_file, "w+");
if (fp == NULL)
rte_exit(EXIT_FAILURE, "Failed to open output file\n");
fwrite(ctx.output_buffer, 1, ctx.output_size, fp);
fclose(fp);
/* Step 16: Clean up */
/* Stop ML model */
rte_ml_model_stop(0, ctx.id);
/* Unload ML model */
rte_ml_model_unload(0, ctx.id);
/* Free input/output memory */
rte_memzone_free(rte_memzone_lookup(IO_MZ));
/* Free the ml op back to pool */
rte_mempool_put_bulk(op_pool, (void *)op_deq, 1);
/* Free ml op pool */
rte_mempool_free(op_pool);
/* Stop the device */
rte_ml_dev_stop(0);
rte_ml_dev_close(0);
rte_eal_cleanup();
return 0;
}Jerin Jacob (1):
mldev: introduce machine learning device library
Srikanth Yalavarthi (11):
mldev: support PMD functions for ML device
mldev: support ML device handling functions
mldev: support ML device queue-pair setup
mldev: support handling ML models
mldev: support input and output data handling
mldev: support ML op pool and ops
mldev: support inference enqueue and dequeue
mldev: support device statistics
mldev: support device extended statistics
mldev: support to retrieve error information
mldev: support to get debug info and test device
MAINTAINERS | 5 + doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + doc/guides/prog_guide/img/mldev_flow.svg | 714 ++++++++++++++ doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/mldev.rst | 186 ++++ doc/guides/rel_notes/release_23_03.rst | 5 + lib/meson.build | 1 + lib/mldev/meson.build | 27 + lib/mldev/rte_mldev.c | 947 ++++++++++++++++++ lib/mldev/rte_mldev.h | 1119 ++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 717 ++++++++++++++ lib/mldev/rte_mldev_pmd.c | 62 ++ lib/mldev/rte_mldev_pmd.h | 151 +++ lib/mldev/version.map | 51 + 15 files changed, 3988 insertions(+) create mode 100644 doc/guides/prog_guide/img/mldev_flow.svg create mode 100644 doc/guides/prog_guide/mldev.rst create mode 100644 lib/mldev/meson.build create mode 100644 lib/mldev/rte_mldev.c create mode 100644 lib/mldev/rte_mldev.h create mode 100644 lib/mldev/rte_mldev_core.h create mode 100644 lib/mldev/rte_mldev_pmd.c create mode 100644 lib/mldev/rte_mldev_pmd.h create mode 100644 lib/mldev/version.map
Signature · 1 line
2.39.1
PATCH v3 1/12 mldev: introduce machine learning device library
From: Jerin Jacob <[email protected]>
Add mldev API specification to standardize and use the machine learning device and inference operations in vendor neutral way.
Following operations are abstracted through APIs
- ML device capability probe
- ML device configuration
- ML device queue pair configuration
- ML device state management
- ML device stat/xstat operations
- ML model load/unload/start/stop operations
- ML model information probe
- ML IO operations to find size for input and output buffers
- ML quantize and dequantize operations
- ML ops pool creation and free operations
- ML device enqueue/dequeue fastpath interference operations
Also added programming guide.
--- MAINTAINERS | 5 + doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + doc/guides/prog_guide/img/mldev_flow.svg | 714 ++++++++++++++ doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/mldev.rst | 186 ++++ doc/guides/rel_notes/release_23_03.rst | 5 + lib/meson.build | 1 + lib/mldev/meson.build | 18 + lib/mldev/rte_mldev.c | 8 + lib/mldev/rte_mldev.h | 1119 ++++++++++++++++++++++ lib/mldev/version.map | 7 + 12 files changed, 2066 insertions(+) create mode 100644 doc/guides/prog_guide/img/mldev_flow.svg create mode 100644 doc/guides/prog_guide/mldev.rst create mode 100644 lib/mldev/meson.build create mode 100644 lib/mldev/rte_mldev.c create mode 100644 lib/mldev/rte_mldev.h create mode 100644 lib/mldev/version.map
MAINTAINERS +5 -0
@@ -538,6 +538,11 @@ F: drivers/raw/skeleton/ F: app/test/test_rawdev.c F: doc/guides/prog_guide/rawdev.rst +ML device API - EXPERIMENTAL +M: Srikanth Yalavarthi <[email protected]> +F: lib/mldev/ +F: doc/guides/prog_guide/mldev.rst + Memory Pool Drivers -------------------
doc/api/doxy-api-index.md +1 -0
@@ -22,6 +22,7 @@ The public API headers are grouped by topics: [compress](@ref rte_comp.h), [regexdev](@ref rte_regexdev.h), [dmadev](@ref rte_dmadev.h), + [mldev](@ref rte_mldev.h), [eventdev](@ref rte_eventdev.h), [event_eth_rx_adapter](@ref rte_event_eth_rx_adapter.h), [event_eth_tx_adapter](@ref rte_event_eth_tx_adapter.h),
doc/api/doxy-api.conf.in +1 -0
@@ -57,6 +57,7 @@ INPUT = @TOPDIR@/doc/api/doxy-api-index.md \ @TOPDIR@/lib/mempool \ @TOPDIR@/lib/meter \ @TOPDIR@/lib/metrics \ + @TOPDIR@/lib/mldev \ @TOPDIR@/lib/node \ @TOPDIR@/lib/net \ @TOPDIR@/lib/pcapng \
doc/guides/prog_guide/img/mldev_flow.svg new file +714 -0
714 lines not on this page · raw message
doc/guides/prog_guide/index.rst +1 -0
@@ -30,6 +30,7 @@ Programmer's Guide regexdev dmadev gpudev + mldev rte_security rawdev link_bonding_poll_mode_drv_lib
doc/guides/prog_guide/mldev.rst new file +186 -0
186 lines not on this page · raw message
doc/guides/rel_notes/release_23_03.rst +5 -0
@@ -87,6 +87,11 @@ New Features ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter required for eth_rx, eth_tx, crypto and timer eventdev adapters. +* **Added machine learning inference device library.** + + * Added a machine learning inference device framework for management and provision of + hardware and software machine learning inference devices. + Removed Items -------------
lib/meson.build +1 -0
@@ -63,6 +63,7 @@ libraries = [ 'flow_classify', # flow_classify lib depends on pkt framework table lib 'graph', 'node', + 'mldev', ] optional_libs = [
lib/mldev/meson.build new file +18 -0
@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2022 Marvell. + +sources = files( + 'rte_mldev.c', +) + +headers = files( + 'rte_mldev.h', +) + +deps += ['mempool'] + +if get_option('buildtype').contains('debug') + cflags += [ '-DRTE_LIBRTE_ML_DEV_DEBUG' ] +else + cflags += [ '-URTE_LIBRTE_ML_DEV_DEBUG' ] +endif
lib/mldev/rte_mldev.c new file +8 -0
@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (c) 2022 Marvell. +*/ + +#include <rte_log.h> +#include <rte_mldev.h> + +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev.h new file +1119 -0
1,119 lines not on this page · raw message
lib/mldev/version.map new file +7 -0
@@ -0,0 +1,7 @@ +EXPERIMENTAL { + global: + + rte_ml_dev_logtype; + + local: *; +};
Signature · 1 line
2.39.1
PATCH v3 2/12 mldev: support PMD functions for ML device
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added PMD functions to handle ML devices. The rte_mldev_pmd.* files are for drivers only and should be private to DPDK, and are not installed for application use. Added implementation for rte_ml_dev_init.
--- lib/mldev/meson.build | 9 ++ lib/mldev/rte_mldev.c | 172 +++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 108 +++++++++++++++++++++++ lib/mldev/rte_mldev_pmd.c | 62 +++++++++++++ lib/mldev/rte_mldev_pmd.h | 149 ++++++++++++++++++++++++++++++++ lib/mldev/version.map | 12 +++ 6 files changed, 512 insertions(+) create mode 100644 lib/mldev/rte_mldev_core.h create mode 100644 lib/mldev/rte_mldev_pmd.c create mode 100644 lib/mldev/rte_mldev_pmd.h
lib/mldev/meson.build +9 -0
@@ -2,6 +2,7 @@ # Copyright (c) 2022 Marvell. sources = files( + 'rte_mldev_pmd.c', 'rte_mldev.c', )
@@ -9,6 +10,14 @@ headers = files( 'rte_mldev.h', ) +indirect_headers += files( + 'rte_mldev_core.h', +) + +driver_sdk_headers += files( + 'rte_mldev_pmd.h', +) + deps += ['mempool'] if get_option('buildtype').contains('debug')
lib/mldev/rte_mldev.c +172 -0
179 lines not on this page · raw message
lib/mldev/rte_mldev_core.h new file +108 -0
108 lines not on this page · raw message
lib/mldev/rte_mldev_pmd.c new file +62 -0
62 lines not on this page · raw message
lib/mldev/rte_mldev_pmd.h new file +149 -0
149 lines not on this page · raw message
lib/mldev/version.map +12 -0
@@ -1,7 +1,19 @@ EXPERIMENTAL { global: + rte_ml_dev_init; rte_ml_dev_logtype; local: *; }; + +INTERNAL { + global: + + rte_ml_dev_pmd_allocate; + rte_ml_dev_pmd_create; + rte_ml_dev_pmd_destroy; + rte_ml_dev_pmd_get_dev; + rte_ml_dev_pmd_get_named_dev; + rte_ml_dev_pmd_release; +};
Signature · 1 line
2.39.1
PATCH v3 3/12 mldev: support ML device handling functions
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added ML device handling APIs. These APIs are used to get device information, configure, start, stop and close ML devices. Added function prototypes to PMD layer which are used by the ML driver implementations in the poll mode driver.
--- lib/mldev/rte_mldev.c | 175 +++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 107 +++++++++++++++++++++++ lib/mldev/version.map | 8 ++ 3 files changed, 290 insertions(+)
lib/mldev/rte_mldev.c +175 -0
@@ -177,4 +177,179 @@ rte_ml_dev_init(size_t dev_max)return 0 ; } +uint16_t +rte_ml_dev_count (void ) +{ +return ml_dev_globals.nb_devs; +} + +int +rte_ml_dev_is_valid_dev (int16_t dev_id) +{ +struct rte_ml_dev *dev =NULL ; + +if (dev_id >= ml_dev_globals.max_devs || ml_dev_globals.devs[dev_id].data ==NULL ) +return 0 ; + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (dev->attached !=ML_DEV_ATTACHED ) +return 0 ; +else +return 1 ; +} + +int +rte_ml_dev_socket_id (int16_t dev_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); + +return dev->data->socket_id; +} + +int +rte_ml_dev_info_get (int16_t dev_id,struct rte_ml_dev_info *dev_info) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_info_get ==NULL ) +return -ENOTSUP ; + +if (dev_info ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, dev_info cannot be NULL\n" , dev_id); +return -EINVAL ; + } +memset (dev_info,0 ,sizeof (struct rte_ml_dev_info )); + +return (*dev->dev_ops->dev_info_get)(dev, dev_info); +} + +int +rte_ml_dev_configure (int16_t dev_id,const struct rte_ml_dev_config *config) +{ +struct rte_ml_dev_info dev_info; +struct rte_ml_dev *dev; +int ret; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_configure ==NULL ) +return -ENOTSUP ; + +if (dev->data->dev_started) { +RTE_MLDEV_LOG (ERR ,"Device %d must be stopped to allow configuration" , dev_id); +return -EBUSY ; + } + +if (config ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, config cannot be NULL\n" , dev_id); +return -EINVAL ; + } + + ret =rte_ml_dev_info_get (dev_id, &dev_info); +if (ret <0 ) +return ret; + +if (config->nb_queue_pairs > dev_info.max_queue_pairs) { +RTE_MLDEV_LOG (ERR ,"Device %d num of queues %u > %u\n" , dev_id, + config->nb_queue_pairs, dev_info.max_queue_pairs); +return -EINVAL ; + } + +return (*dev->dev_ops->dev_configure)(dev, config); +} + +int +rte_ml_dev_close (int16_t dev_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_close ==NULL ) +return -ENOTSUP ; + +/* Device must be stopped before it can be closed */ +if (dev->data->dev_started ==1 ) { +RTE_MLDEV_LOG (ERR ,"Device %d must be stopped before closing" , dev_id); +return -EBUSY ; + } + +return (*dev->dev_ops->dev_close)(dev); +} + +int +rte_ml_dev_start (int16_t dev_id) +{ +struct rte_ml_dev *dev; +int ret; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_start ==NULL ) +return -ENOTSUP ; + +if (dev->data->dev_started !=0 ) { +RTE_MLDEV_LOG (ERR ,"Device %d is already started" , dev_id); +return -EBUSY ; + } + + ret = (*dev->dev_ops->dev_start)(dev); +if (ret ==0 ) + dev->data->dev_started =1 ; + +return ret; +} + +int +rte_ml_dev_stop (int16_t dev_id) +{ +struct rte_ml_dev *dev; +int ret; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_stop ==NULL ) +return -ENOTSUP ; + +if (dev->data->dev_started ==0 ) { +RTE_MLDEV_LOG (ERR ,"Device %d is not started" , dev_id); +return -EBUSY ; + } + + ret = (*dev->dev_ops->dev_stop)(dev); +if (ret ==0 ) + dev->data->dev_started =0 ; + +return ret; +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev_core.h +107 -0
119 lines not on this page · raw message
lib/mldev/version.map +8 -0
@@ -1,8 +1,16 @@ EXPERIMENTAL { global: + rte_ml_dev_close; + rte_ml_dev_configure; + rte_ml_dev_count; + rte_ml_dev_info_get; rte_ml_dev_init; + rte_ml_dev_is_valid_dev; rte_ml_dev_logtype; + rte_ml_dev_socket_id; + rte_ml_dev_start; + rte_ml_dev_stop; local: *; };
Signature · 1 line
2.39.1
PATCH v3 4/12 mldev: support ML device queue-pair setup
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added APIs to create a queue-pair attached to ML device. Queue pairs are created with a user specified ID. Added function prototypes to be used by ML drivers for queue pair create and destroy.
--- lib/mldev/rte_mldev.c | 33 ++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 44 ++++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 1 + 3 files changed, 78 insertions(+)
lib/mldev/rte_mldev.c +33 -0
@@ -352,4 +352,37 @@ rte_ml_dev_stop(int16_t dev_id)return ret; } +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) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_queue_pair_setup ==NULL ) +return -ENOTSUP ; + +if (queue_pair_id >= dev->data->nb_queue_pairs) { +RTE_MLDEV_LOG (ERR ,"Invalid queue_pair_id = %d" , queue_pair_id); +return -EINVAL ; + } + +if (qp_conf ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, qp_conf cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (dev->data->dev_started) { +RTE_MLDEV_LOG (ERR ,"Device %d must be stopped to allow configuration" , dev_id); +return -EBUSY ; + } + +return (*dev->dev_ops->dev_queue_pair_setup)(dev, queue_pair_id, qp_conf, socket_id); +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev_core.h +44 -0
56 lines not on this page · raw message
lib/mldev/version.map +1 -0
@@ -8,6 +8,7 @@ EXPERIMENTAL { rte_ml_dev_init; rte_ml_dev_is_valid_dev; rte_ml_dev_logtype; + rte_ml_dev_queue_pair_setup; rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stop;
Signature · 1 line
2.39.1
PATCH v3 5/12 mldev: support handling ML models
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added RTE functions to handle ML models. These APIs can load, unload, start, and stop an ML model. Additional APIs to update model parameters and get model information are added.
--- lib/mldev/rte_mldev.c | 123 +++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 122 ++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 6 ++ 3 files changed, 251 insertions(+)
lib/mldev/rte_mldev.c +123 -0
@@ -385,4 +385,127 @@ rte_ml_dev_queue_pair_setup(int16_t dev_id, uint16_t queue_pair_id,return (*dev->dev_ops->dev_queue_pair_setup)(dev, queue_pair_id, qp_conf, socket_id); } +int +rte_ml_model_load (int16_t dev_id,struct rte_ml_model_params *params,uint16_t *model_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_load ==NULL ) +return -ENOTSUP ; + +if (params ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, params cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (model_id ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, model_id cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->model_load)(dev, params, model_id); +} + +int +rte_ml_model_unload (int16_t dev_id,uint16_t model_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_unload ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->model_unload)(dev, model_id); +} + +int +rte_ml_model_start (int16_t dev_id,uint16_t model_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_start ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->model_start)(dev, model_id); +} + +int +rte_ml_model_stop (int16_t dev_id,uint16_t model_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_stop ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->model_stop)(dev, model_id); +} + +int +rte_ml_model_info_get (int16_t dev_id,uint16_t model_id,struct rte_ml_model_info *model_info) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_info_get ==NULL ) +return -ENOTSUP ; + +if (model_info ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, model_id %u, model_info cannot be NULL\n" , dev_id, + model_id); +return -EINVAL ; + } + +return (*dev->dev_ops->model_info_get)(dev, model_id, model_info); +} + +int +rte_ml_model_params_update (int16_t dev_id,uint16_t model_id,void *buffer) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->model_params_update ==NULL ) +return -ENOTSUP ; + +if (buffer ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, buffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->model_params_update)(dev, model_id, buffer); +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev_core.h +122 -0
134 lines not on this page · raw message
lib/mldev/version.map +6 -0
@@ -12,6 +12,12 @@ EXPERIMENTAL { rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stop; + rte_ml_model_info_get; + rte_ml_model_load; + rte_ml_model_params_update; + rte_ml_model_start; + rte_ml_model_stop; + rte_ml_model_unload; local: *; };
Signature · 1 line
2.39.1
PATCH v3 6/12 mldev: support input and output data handling
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added library functions to handle model input and output data. The APIs can be used to get the size of I/O buffers, quantize input data and dequantize output data.
--- lib/mldev/rte_mldev.c | 94 ++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 106 +++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 4 ++ 3 files changed, 204 insertions(+)
lib/mldev/rte_mldev.c +94 -0
@@ -508,4 +508,98 @@ rte_ml_model_params_update(int16_t dev_id, uint16_t model_id, void *buffer)return (*dev->dev_ops->model_params_update)(dev, model_id, buffer); } +int +rte_ml_io_input_size_get (int16_t dev_id,uint16_t model_id,uint32_t nb_batches, +uint64_t *input_qsize,uint64_t *input_dsize) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->io_input_size_get ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->io_input_size_get)(dev, model_id, nb_batches, input_qsize, + input_dsize); +} + +int +rte_ml_io_output_size_get (int16_t dev_id,uint16_t model_id,uint32_t nb_batches, +uint64_t *output_qsize,uint64_t *output_dsize) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->io_output_size_get ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->io_output_size_get)(dev, model_id, nb_batches, output_qsize, + output_dsize); +} + +int +rte_ml_io_quantize (int16_t dev_id,uint16_t model_id,uint16_t nb_batches,void *dbuffer, +void *qbuffer) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->io_quantize ==NULL ) +return -ENOTSUP ; + +if (dbuffer ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, dbuffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (qbuffer ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, qbuffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->io_quantize)(dev, model_id, nb_batches, dbuffer, qbuffer); +} + +int +rte_ml_io_dequantize (int16_t dev_id,uint16_t model_id,uint16_t nb_batches,void *qbuffer, +void *dbuffer) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->io_dequantize ==NULL ) +return -ENOTSUP ; + +if (qbuffer ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, qbuffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (dbuffer ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, dbuffer cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->io_dequantize)(dev, model_id, nb_batches, qbuffer, dbuffer); +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev_core.h +106 -0
118 lines not on this page · raw message
lib/mldev/version.map +4 -0
@@ -12,6 +12,10 @@ EXPERIMENTAL { rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stop; + rte_ml_io_dequantize; + rte_ml_io_input_size_get; + rte_ml_io_output_size_get; + rte_ml_io_quantize; rte_ml_model_info_get; rte_ml_model_load; rte_ml_model_params_update;
Signature · 1 line
2.39.1
PATCH v3 7/12 mldev: support ML op pool and ops
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added library functions to create and free ML op pool. Create function allocates new ML op pool and initializes ML ops to their defaults.
--- lib/mldev/rte_mldev.c | 69 +++++++++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 2 ++ 2 files changed, 71 insertions(+)
lib/mldev/rte_mldev.c +69 -0
@@ -12,6 +12,17 @@static struct rte_ml_dev_global ml_dev_globals = { .devs =NULL , .data =NULL , .nb_devs =0 , .max_devs =RTE_MLDEV_DEFAULT_MAX }; +/* +* Private data structure of an operation pool. +* +* A structure that contains ml op_pool specific data that is +* appended after the mempool structure (in private data). +*/ +struct rte_ml_op_pool_private { +uint16_t user_size; +/*< Size of private user data with each operation. */ +}; +struct rte_ml_dev *rte_ml_dev_pmd_get_dev (int16_t dev_id) {
@@ -602,4 +613,62 @@ rte_ml_io_dequantize(int16_t dev_id, uint16_t model_id, uint16_t nb_batches, voireturn (*dev->dev_ops->io_dequantize)(dev, model_id, nb_batches, qbuffer, dbuffer); } +/** Initialise rte_ml_op mempool element */ +static void +ml_op_init(struct rte_mempool *mempool, __rte_unused void *opaque_arg, void *_op_data, + __rte_unused unsigned int i) +{ +struct rte_ml_op *op = _op_data; + +memset (_op_data,0 , mempool->elt_size); + op->status =RTE_ML_OP_STATUS_NOT_PROCESSED ; + op->mempool = mempool; +} + +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) +{ +struct rte_ml_op_pool_private *priv; +struct rte_mempool *mp; +unsigned int elt_size; + +/* lookup mempool in case already allocated */ + mp =rte_mempool_lookup (name); + elt_size =sizeof (struct rte_ml_op ) + user_size; + +if (mp !=NULL ) { + priv = (struct rte_ml_op_pool_private *)rte_mempool_get_priv (mp); +if (mp->elt_size != elt_size || mp->cache_size < cache_size || mp->size < nb_elts || + priv->user_size < user_size) { + mp =NULL ; +RTE_MLDEV_LOG (ERR , +"Mempool %s already exists but with incompatible parameters" , + name); +return NULL ; + } +return mp; + } + + mp =rte_mempool_create (name, nb_elts, elt_size, cache_size, +sizeof (struct rte_ml_op_pool_private ),NULL ,NULL , ml_op_init,NULL , + socket_id,0 ); +if (mp ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Failed to create mempool %s" , name); +return NULL ; + } + + priv = (struct rte_ml_op_pool_private *)rte_mempool_get_priv (mp); + priv->user_size = user_size; + +return mp; +} + +void +rte_ml_op_pool_free (struct rte_mempool *mempool) +{ +if (mempool !=NULL ) +rte_mempool_free (mempool); +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/version.map +2 -0
@@ -22,6 +22,8 @@ EXPERIMENTAL { rte_ml_model_start; rte_ml_model_stop; rte_ml_model_unload; + rte_ml_op_pool_create; + rte_ml_op_pool_free; local: *; };
Signature · 1 line
2.39.1
PATCH v3 8/12 mldev: support inference enqueue and dequeue
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added implementations of fast-path functions to enqueue and dequeue ML requests from an ML device queue-pair.
--- lib/mldev/rte_mldev.c | 75 ++++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 46 +++++++++++++++++++++++ lib/mldev/rte_mldev_pmd.h | 2 + lib/mldev/version.map | 2 + 4 files changed, 125 insertions(+)
lib/mldev/rte_mldev.c +75 -0
@@ -114,6 +114,9 @@ rte_ml_dev_pmd_allocate(const char *name, uint8_t socket_id) ml_dev_globals.nb_devs++; } + dev->enqueue_burst =NULL ; + dev->dequeue_burst =NULL ; +return dev; }
@@ -671,4 +674,76 @@ rte_ml_op_pool_free(struct rte_mempool *mempool)rte_mempool_free (mempool); } +uint16_t +rte_ml_enqueue_burst (int16_t dev_id,uint16_t qp_id,struct rte_ml_op **ops,uint16_t nb_ops) +{ +struct rte_ml_dev *dev; + +#ifdef RTE_LIBRTE_ML_DEV_DEBUG +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); + rte_errno = -EINVAL ; +return 0 ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->enqueue_burst ==NULL ) { + rte_errno = -ENOTSUP ; +return 0 ; + } + +if (ops ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, ops cannot be NULL\n" , dev_id); + rte_errno = -EINVAL ; +return 0 ; + } + +if (qp_id >= dev->data->nb_queue_pairs) { +RTE_MLDEV_LOG (ERR ,"Invalid qp_id %u\n" , qp_id); + rte_errno = -EINVAL ; +return 0 ; + } +#else + dev =rte_ml_dev_pmd_get_dev (dev_id); +#endif + +return (*dev->enqueue_burst)(dev, qp_id, ops, nb_ops); +} + +uint16_t +rte_ml_dequeue_burst (int16_t dev_id,uint16_t qp_id,struct rte_ml_op **ops,uint16_t nb_ops) +{ +struct rte_ml_dev *dev; + +#ifdef RTE_LIBRTE_ML_DEV_DEBUG +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); + rte_errno = -EINVAL ; +return 0 ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dequeue_burst ==NULL ) { + rte_errno = -ENOTSUP ; +return 0 ; + } + +if (ops ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, ops cannot be NULL\n" , dev_id); + rte_errno = -EINVAL ; +return 0 ; + } + +if (qp_id >= dev->data->nb_queue_pairs) { +RTE_MLDEV_LOG (ERR ,"Invalid qp_id %u\n" , qp_id); + rte_errno = -EINVAL ; +return 0 ; + } +#else + dev =rte_ml_dev_pmd_get_dev (dev_id); +#endif + +return (*dev->dequeue_burst)(dev, qp_id, ops, nb_ops); +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev_core.h +46 -0
58 lines not on this page · raw message
lib/mldev/rte_mldev_pmd.h +2 -0
@@ -40,6 +40,8 @@ struct rte_ml_dev_pmd_init_params {uint64_t private_data_size; }; +struct rte_ml_dev ; +/** * @internal *
lib/mldev/version.map +2 -0
@@ -1,6 +1,7 @@ EXPERIMENTAL { global: + rte_ml_dequeue_burst; rte_ml_dev_close; rte_ml_dev_configure; rte_ml_dev_count;
@@ -12,6 +13,7 @@ EXPERIMENTAL { rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stop; + rte_ml_enqueue_burst; rte_ml_io_dequantize; rte_ml_io_input_size_get; rte_ml_io_output_size_get;
Signature · 1 line
2.39.1
PATCH v3 9/12 mldev: support device statistics
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added functions to get and reset device stats. Device stats include number of requests enqueued, dequeued and errors. Added function prototypes to used by driver implementations.
--- lib/mldev/rte_mldev.c | 40 ++++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 32 ++++++++++++++++++++++++++++++ lib/mldev/version.map | 2 ++ 3 files changed, 74 insertions(+)
lib/mldev/rte_mldev.c +40 -0
@@ -399,6 +399,46 @@ rte_ml_dev_queue_pair_setup(int16_t dev_id, uint16_t queue_pair_id,return (*dev->dev_ops->dev_queue_pair_setup)(dev, queue_pair_id, qp_conf, socket_id); } +int +rte_ml_dev_stats_get (int16_t dev_id,struct rte_ml_dev_stats *stats) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_stats_get ==NULL ) +return -ENOTSUP ; + +if (stats ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, stats cannot be NULL\n" , dev_id); +return -EINVAL ; + } +memset (stats,0 ,sizeof (struct rte_ml_dev_stats )); + +return (*dev->dev_ops->dev_stats_get)(dev, stats); +} + +void +rte_ml_dev_stats_reset (int16_t dev_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_stats_reset ==NULL ) +return ; + + (*dev->dev_ops->dev_stats_reset)(dev); +} +int rte_ml_model_load (int16_t dev_id,struct rte_ml_model_params *params,uint16_t *model_id) {
lib/mldev/rte_mldev_core.h +32 -0
@@ -191,6 +191,32 @@ typedef int (*mldev_queue_pair_setup_t)(struct rte_ml_dev *dev, uint16_t queue_p*/ typedef int (*mldev_queue_pair_release_t )(struct rte_ml_dev *dev,uint16_t queue_pair_id); +/** +* @internal +* +* Function used to get device statistics. +* +* @param dev +* ML device pointer. +* @param stats +* Pointer to ML device stats structure to update. +* +* @return +* - 0 on success. +* - < 0, error on failure. +*/ +typedef int (*mldev_stats_get_t )(struct rte_ml_dev *dev,struct rte_ml_dev_stats *stats); + +/** +* @internal +* +* Function used to reset device statistics. +* +* @param dev +* ML device pointer. +*/ +typedef void (*mldev_stats_reset_t )(struct rte_ml_dev *dev); +/** * @internal *
@@ -416,6 +442,12 @@ struct rte_ml_dev_ops {/** Release a device queue pair. */ mldev_queue_pair_release_t dev_queue_pair_release; +/** Get device statistics. */ +mldev_stats_get_t dev_stats_get; + +/** Reset device statistics. */ +mldev_stats_reset_t dev_stats_reset; +/** Load an ML model. */ mldev_model_load_t model_load;
lib/mldev/version.map +2 -0
@@ -12,6 +12,8 @@ EXPERIMENTAL { rte_ml_dev_queue_pair_setup; rte_ml_dev_socket_id; rte_ml_dev_start; + rte_ml_dev_stats_get; + rte_ml_dev_stats_reset; rte_ml_dev_stop; rte_ml_enqueue_burst; rte_ml_io_dequantize;
Signature · 1 line
2.39.1
PATCH v3 10/12 mldev: support device extended statistics
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added functions to handle device extended stats. xstats supported are driver specific and can include stats specific to ML device or ML model and I/O. Added prototypes for functions to be called by the device drivers.
--- lib/mldev/rte_mldev.c | 88 ++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 93 ++++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 4 ++ 3 files changed, 185 insertions(+)
lib/mldev/rte_mldev.c +88 -0
@@ -439,6 +439,94 @@ rte_ml_dev_stats_reset(int16_t dev_id) (*dev->dev_ops->dev_stats_reset)(dev); } +int +rte_ml_dev_xstats_names_get (int16_t dev_id,struct rte_ml_dev_xstats_map *xstats_map,uint32_t size) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_xstats_names_get ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->dev_xstats_names_get)(dev, xstats_map, size); +} + +int +rte_ml_dev_xstats_by_name_get (int16_t dev_id,const char *name,uint16_t *stat_id,uint64_t *value) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_xstats_by_name_get ==NULL ) +return -ENOTSUP ; + +if (name ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, name cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (value ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, value cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->dev_xstats_by_name_get)(dev, name, stat_id, value); +} + +int +rte_ml_dev_xstats_get (int16_t dev_id,const uint16_t *stat_ids,uint64_t *values,uint16_t nb_ids) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_xstats_get ==NULL ) +return -ENOTSUP ; + +if (stat_ids ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, stat_ids cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (values ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, values cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->dev_xstats_get)(dev, stat_ids, values, nb_ids); +} + +int +rte_ml_dev_xstats_reset (int16_t dev_id,const uint16_t *stat_ids,uint16_t nb_ids) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_xstats_reset ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->dev_xstats_reset)(dev, stat_ids, nb_ids); +} +int rte_ml_model_load (int16_t dev_id,struct rte_ml_model_params *params,uint16_t *model_id) {
lib/mldev/rte_mldev_core.h +93 -0
105 lines not on this page · raw message
lib/mldev/version.map +4 -0
@@ -15,6 +15,10 @@ EXPERIMENTAL { rte_ml_dev_stats_get; rte_ml_dev_stats_reset; rte_ml_dev_stop; + rte_ml_dev_xstats_by_name_get; + rte_ml_dev_xstats_get; + rte_ml_dev_xstats_names_get; + rte_ml_dev_xstats_reset; rte_ml_enqueue_burst; rte_ml_io_dequantize; rte_ml_io_input_size_get;
Signature · 1 line
2.39.1
PATCH v3 11/12 mldev: support to retrieve error information
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added functions to get error information for an ML op. This information can include both drive specific error message and error code.
--- lib/mldev/rte_mldev.c | 31 +++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 22 ++++++++++++++++++++++ lib/mldev/version.map | 1 + 3 files changed, 54 insertions(+)
lib/mldev/rte_mldev.c +31 -0
@@ -874,4 +874,35 @@ rte_ml_dequeue_burst(int16_t dev_id, uint16_t qp_id, struct rte_ml_op **ops, uinreturn (*dev->dequeue_burst)(dev, qp_id, ops, nb_ops); } +int +rte_ml_op_error_get (int16_t dev_id,struct rte_ml_op *op,struct rte_ml_op_error *error) +{ +struct rte_ml_dev *dev; + +#ifdef RTE_LIBRTE_ML_DEV_DEBUG +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->op_error_get ==NULL ) +return -ENOTSUP ; + +if (op ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, op cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +if (error ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, error cannot be NULL\n" , dev_id); +return -EINVAL ; + } +#else + dev =rte_ml_dev_pmd_get_dev (dev_id); +#endif + +return (*dev->op_error_get)(dev, op, error); +} +RTE_LOG_REGISTER_DEFAULT (rte_ml_dev_logtype,INFO );
lib/mldev/rte_mldev_core.h +22 -0
@@ -73,6 +73,25 @@ typedef uint16_t (*mldev_enqueue_t)(struct rte_ml_dev *dev, uint16_t qp_id, strutypedef uint16_t (*mldev_dequeue_t )(struct rte_ml_dev *dev,uint16_t qp_id,struct rte_ml_op **ops,uint16_t nb_ops); +/** +* @internal +* +* Get error information for an Op. +* +* @param dev +* ML device pointer. +* @param op +* ML Op handle. +* @param error +* Pointer to error structure. +* +* @return +* - 0 on success. +* - <0, error on failure. +*/ +typedef int (*mldev_op_error_get_t )(struct rte_ml_dev *dev,struct rte_ml_op *op, +struct rte_ml_op_error *error); +/** * Definitions of all functions exported by a driver through the generic structure of type * *ml_dev_ops* supplied in the *rte_ml_dev* structure associated with a device.
@@ -619,6 +638,9 @@ struct rte_ml_dev {/** Pointer to PMD dequeue function. */ mldev_dequeue_t dequeue_burst; +/** Pointer to PMD Op error get function. */ +mldev_op_error_get_t op_error_get; +/** Pointer to device data. */ struct rte_ml_dev_data *data;
lib/mldev/version.map +1 -0
@@ -30,6 +30,7 @@ EXPERIMENTAL { rte_ml_model_start; rte_ml_model_stop; rte_ml_model_unload; + rte_ml_op_error_get; rte_ml_op_pool_create; rte_ml_op_pool_free;
Signature · 1 line
2.39.1
PATCH v3 12/12 mldev: support to get debug info and test device
In reply to [email protected]From: Srikanth Yalavarthi <[email protected]>
Added functions for ML device debug APIs. The APIs
are used to dump ML device debug information and to run selftest.
--- lib/mldev/rte_mldev.c | 39 ++++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 37 ++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 2 ++ 3 files changed, 78 insertions(+)
lib/mldev/rte_mldev.c +39 -0
@@ -527,6 +527,45 @@ rte_ml_dev_xstats_reset(int16_t dev_id, const uint16_t *stat_ids, uint16_t nb_idreturn (*dev->dev_ops->dev_xstats_reset)(dev, stat_ids, nb_ids); } +int +rte_ml_dev_dump (int16_t dev_id,FILE *fd) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_dump ==NULL ) +return -ENOTSUP ; + +if (fd ==NULL ) { +RTE_MLDEV_LOG (ERR ,"Dev %d, file descriptor cannot be NULL\n" , dev_id); +return -EINVAL ; + } + +return (*dev->dev_ops->dev_dump)(dev, fd); +} + +int +rte_ml_dev_selftest (int16_t dev_id) +{ +struct rte_ml_dev *dev; + +if (!rte_ml_dev_is_valid_dev (dev_id)) { +RTE_MLDEV_LOG (ERR ,"Invalid dev_id = %d\n" , dev_id); +return -EINVAL ; + } + + dev =rte_ml_dev_pmd_get_dev (dev_id); +if (*dev->dev_ops->dev_selftest ==NULL ) +return -ENOTSUP ; + +return (*dev->dev_ops->dev_selftest)(dev); +} +int rte_ml_model_load (int16_t dev_id,struct rte_ml_model_params *params,uint16_t *model_id) {
lib/mldev/rte_mldev_core.h +37 -0
@@ -317,6 +317,37 @@ typedef int (*mldev_xstats_get_t)(struct rte_ml_dev *dev, const uint16_t *stat_itypedef int (*mldev_xstats_reset_t )(struct rte_ml_dev *dev,const uint16_t *stat_ids,uint16_t nb_ids); +/** +* @internal +* +* Function used to dump ML device debug info. +* +* @param dev +* ML device pointer. +* @param fd +* File descriptor to dump the debug info. +* +* @return +* - 0 on success. +* - < 0, error code on failure. +*/ + +typedef int (*mldev_dump_t )(struct rte_ml_dev *dev,FILE *fd); + +/** +* @internal +* +* Function used for selftest of ML device. +* +* @param dev +* ML device pointer. +* +* @return +* - 0 on success. +* - < 0, error on failure. +*/ +typedef int (*mldev_selftest_t )(struct rte_ml_dev *dev); +/** * @internal *
@@ -560,6 +591,12 @@ struct rte_ml_dev_ops {/** Reset extended stats of the device. */ mldev_xstats_reset_t dev_xstats_reset; +/** Dump ML device debug info. */ +mldev_dump_t dev_dump; + +/** Dump ML device debug info. */ +mldev_selftest_t dev_selftest; +/** Load an ML model. */ mldev_model_load_t model_load;
lib/mldev/version.map +2 -0
@@ -5,11 +5,13 @@ EXPERIMENTAL { rte_ml_dev_close; rte_ml_dev_configure; rte_ml_dev_count; + rte_ml_dev_dump; rte_ml_dev_info_get; rte_ml_dev_init; rte_ml_dev_is_valid_dev; rte_ml_dev_logtype; rte_ml_dev_queue_pair_setup; + rte_ml_dev_selftest; rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stats_get;
Signature · 1 line
2.39.1
Quoted 2 lines · On 2/7/2023 3:13 PM, [email protected] wrote:
From: Jerin Jacob <[email protected]>
Hi Jerin,
Please find some comments/questions gathered with the help of some collegues.
Quoted 12 lines
Machine learning inference library
==================================Definition of machine learning inference
----------------------------------------
Inference in machine learning is the process of making an output prediction based on new input data using a pre-trained machine learning model.The scope of the RFC would include only inferencing with pre-trained machine learning models, training and building/compiling the ML models is out of scope for this RFC or DPDK mldev API. Use existing machine learning compiler frameworks for model creation.
Quoted 7 lines
Motivation for the new library
------------------------------
Multiple semiconductor vendors are offering accelerator products such as DPU (often called Smart-NIC), FPGA, GPU, etc., which have ML inferencing capabilities integrated as part of the product. Use of ML inferencing is increasing in the domain of packet processing for flow classification, intrusion, malware and anomaly detection.
Agree on this need.
Quoted 6 lines
Lack of inferencing support through DPDK APIs will involve complexities and increased latency from moving data across frameworks (i.e, dataplane to non dataplane ML frameworks and vice-versa). Having a standardized DPDK APIs for ML inferencing would enable the dataplane solutions to harness the benefit of inline inferencing supported by the hardware.
ack
Quoted 52 lines
Contents
---------------
A) API specification for:1) Discovery of ML capabilities (e.g., device specific features) in a vendor independent fashion
2) Definition of functions to handle ML devices, which includes probing, initialization and termination of the devices.
3) Definition of functions to handle ML models used to perform inference operations.
4) Definition of function to handle quantize and dequantize operationsB) Common code for above specification
rfc..v1:
- Added programmer guide documentation
- Added implementation for common codev2..v1:
- Moved dynamic log (Stephen)
- model id touint16_tfromint16t_t(Stephen)
- added release note updatesv3..v2:
- Introducedrte_ml_dev_init()similar torte_gpu_init()(Stephen, Thomas)
- In structrte_ml_dev_data, removed reserved[3] and__rte_cache_aligned.
Also, moved name field to the end(Stephen)Machine learning library framework
----------------------------------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 | | +--------+
Quoted 9 lines
| +-------------+ |
| +-------------+ |<------- rte_ml_model_load()
| | Model .. | |-------> rte_ml_model_info()
| +-------------+ |<------- rte_ml_model_start()
| +-------------+ |<------- rte_ml_model_stop()
| | Model N | |<------- rte_ml_model_params_update()
| +-------------+ |<------- rte_ml_model_unload()
+-----------------+Should model load/unload, params_update be part of dpdk, or dpdk can assume these are already in place. For FPGA both options works, what is the benefit to have these APIs part of DPDK? What are usecases for other architectures?
Is multiple active models at same time supported?
For FPGA case multiple models may exist at same time, it would be good to have a way to select the model to use, like a handle for model that API accepts.
Similarly a handle for model may help chaining models, possibly with help of additional APIs to define the chaining.
Quoted 3 lines
ML Device: A hardware or software-based implementation of ML device API for running inferences using a pre-trained ML model.
Can this device consume multiple queues in parallel?
Quoted 25 lines
ML Model: An ML model is an algorithm trained over a dataset. A model consists of procedure/algorithm and data/pattern required to make predictions on live data. Once the model is created and trained outside of the DPDK scope, the model can be loaded via
rte_ml_model_load()and then start it usingrte_ml_model_start()API. Therte_ml_model_params_update()can be used to update the model parameters such as weight and bias without unloading the model usingrte_ml_model_unload().ML Inference: ML inference is the process of feeding data to the model via
rte_ml_enqueue_burst()API and userte_ml_dequeue_burst()API to get the calculated outputs/predictions from the started model.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 setup a device designated by its device identifier must be invoked in the following order:
-
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. Application needs to invoke the ML model API in the following order before queueing inference jobs.
Quoted 6 lines
-
rte_ml_model_load()
-rte_ml_model_start()The
rte_ml_model_info()API is provided to retrieve the information related to the model. The information would include the shape and type of input and output required for the inference.
It seems there is a sandardization effort for model description, called ONNX (https://onnx.ai/), supported by many vendors.
Does it make sense that 'rte_ml_model_info()' describes data, and perhaps model itself too, using onnx format?
Quoted 8 lines
Data quantization and dequantization is one of the main aspects in ML domain. This involves conversion of 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 throughrte_ml_io_dequantize(). These APIs have the capability to handle input and output buffers holding data for multiple batches.
Two utility APIsrte_ml_io_input_size_get()andrte_ml_io_output_size_get()can used to get the size of quantized and de-quantized multi-batch input and output buffers.
It seems quantize and dequantize can be part of model and optimized during training, can you please some information HW architecture that needs these APIs?
Does it make sense to have quantize/dequantize as a capability, like in case HW has specific support for it this can be used, else host can provide this functionality.
Quoted 22 lines
User can optionally update the model parameters with
rte_ml_model_params_update()after invokingrte_ml_model_stop()API on a given model ID.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()orrte_ml_dev_queue_pair_setup()), then application must stop the device usingrte_ml_dev_stop()API. Likewise, if model parameters need to be updated then the application must callrte_ml_model_stop()followed byrte_ml_model_params_update()API for the given model. The application does not need to callrte_ml_dev_stop()API for any model re-configuration such asrte_ml_model_params_update(),rte_ml_model_unload()etc.Once the device is in the start state after invoking
rte_ml_dev_start()API and the model is in start state after invokingrte_ml_model_start()API, then the application can callrte_ml_enqueue()andrte_ml_dequeue()API on the destined device and model ID.Finally, an application can close an ML device by invoking the
rte_ml_dev_close()function.Typical application utilisation of the ML API will follow the following programming flow.
Quoted 13 lines
-
rte_ml_dev_configure()
-rte_ml_dev_queue_pair_setup()
-rte_ml_model_load()
-rte_ml_model_start()
-rte_ml_model_info()
-rte_ml_dev_start()
-rte_ml_enqueue_burst()
-rte_ml_dequeue_burst()
-rte_ml_model_stop()
-rte_ml_model_unload()
-rte_ml_dev_stop()
-rte_ml_dev_close()
is a 'reset()' API needed?
Quoted 258 lines
Regarding multi-threading, by default, all the functions of the ML Device API exported by a PMD are lock-free functions which assume to not be 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 same queue pair. Of course, this function can be invoked in parallel by different logical core on different queue pair.
It is the responsibility of the user application to enforce this rule.Example application usage for ML inferencing
--------------------------------------------
This example application is to demonstrate the programming model of ML device library. This example omits the error checks to simplify the application. This example also assumes that the input data received is quantized and output expected is also quantized. In order to handle non-quantized inputs and outputs, users can invokerte_ml_io_quantize()orrte_ml_io_dequantize()for data type conversions.#define
ML_MODEL_NAME"model"
#defineIO_MZ"io_mz"struct app_ctx { char model_file[PATH_MAX]; char inp_file[PATH_MAX]; char out_file[PATH_MAX]; struct rte_ml_model_params params; struct rte_ml_model_info info; uint16_t id; uint64_t input_size; uint64_t output_size; uint8_t *input_buffer; uint8_t *output_buffer; } __rte_cache_aligned;struct
app_ctxctx;static int
parse_args(int argc, char **argv){ int opt, option_index; static struct option lgopts[] = {{"model", required_argument, NULL, 'm'}, {"input", required_argument, NULL, 'i'}, {"output", required_argument, NULL, 'o'}, {NULL, 0, NULL, 0}}; while ((opt = getopt_long(argc, argv, "m:i:o:", lgopts, &option_index)) != EOF) switch (opt) { case 'm': strncpy(ctx.model_file, optarg, PATH_MAX - 1); break; case 'i': strncpy(ctx.inp_file, optarg, PATH_MAX - 1); break; case 'o': strncpy(ctx.out_file, optarg, PATH_MAX - 1); break; default: return -1; } return 0; }int
main(int argc, char **argv){ struct rte_ml_dev_qp_conf qp_conf; struct rte_ml_dev_config config; struct rte_ml_dev_info dev_info; const struct rte_memzone *mz; struct rte_mempool *op_pool; struct rte_ml_op *op_enq; struct rte_ml_op *op_deq; FILE *fp; int rc; /* Initialize EAL */ rc = rte_eal_init(argc, argv); if (rc < 0) rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n"); argc -= rc; argv += rc; /* Parse application arguments (after the EAL args) */ if (parse_args(argc, argv) < 0) rte_exit(EXIT_FAILURE, "Invalid application arguments\n"); /* Step 1: Check for ML devices */ if (rte_ml_dev_count() <= 0) rte_exit(EXIT_FAILURE, "Failed to find ML devices\n"); /* Step 2: Get device info */ if (rte_ml_dev_info_get(0, &dev_info) != 0) rte_exit(EXIT_FAILURE, "Failed to get device info\n"); /* Step 3: Configure ML device, use device 0 */ config.socket_id = rte_ml_dev_socket_id(0); config.max_nb_models = dev_info.max_models; config.nb_queue_pairs = dev_info.max_queue_pairs; if (rte_ml_dev_configure(0, &config) != 0) rte_exit(EXIT_FAILURE, "Device configuration failed\n"); /* Step 4: Setup queue pairs, used qp_id = 0 */ qp_conf.nb_desc = 1; if (rte_ml_dev_queue_pair_setup(0, 0, &qp_conf, config.socket_id) != 0) rte_exit(EXIT_FAILURE, "Queue-pair setup failed\n"); /* Step 5: Start device */ if (rte_ml_dev_start(0) != 0) rte_exit(EXIT_FAILURE, "Device start failed\n"); /* Step 6: Read model data and update load params structure */ fp = fopen(ctx.model_file, "r+"); if (fp == NULL) rte_exit(EXIT_FAILURE, "Failed to open model file\n"); fseek(fp, 0, SEEK_END); ctx.params.size = ftell(fp); fseek(fp, 0, SEEK_SET); ctx.params.addr = malloc(ctx.params.size); if (fread(ctx.params.addr, 1, ctx.params.size, fp) != ctx.params.size){ fclose(fp); rte_exit(EXIT_FAILURE, "Failed to read model\n"); } fclose(fp); strcpy(ctx.params.name, ML_MODEL_NAME); /* Step 7: Load the model */ if (rte_ml_model_load(0, &ctx.params, &ctx.id) != 0) rte_exit(EXIT_FAILURE, "Failed to load model\n"); free(ctx.params.addr); /* Step 8: Start the model */ if (rte_ml_model_start(0, ctx.id) != 0) rte_exit(EXIT_FAILURE, "Failed to start model\n"); /* Step 9: Allocate buffers for quantized input and output */ /* Get model information */ if (rte_ml_model_info_get(0, ctx.id, &ctx.info) != 0) rte_exit(EXIT_FAILURE, "Failed to get model info\n"); /* Get the buffer size for input and output */ rte_ml_io_input_size_get(0, ctx.id, ctx.info.batch_size, &ctx.input_size, NULL); rte_ml_io_output_size_get(0, ctx.id, ctx.info.batch_size, &ctx.output_size, NULL); mz = rte_memzone_reserve(IO_MZ, ctx.input_size + ctx.output_size, config.socket_id, 0); if (mz == NULL) rte_exit(EXIT_FAILURE, "Failed to create IO memzone\n"); ctx.input_buffer = mz->addr; ctx.output_buffer = ctx.input_buffer + ctx.input_size; /* Step 10: Fill the input data */ fp = fopen(ctx.inp_file, "r+"); if (fp == NULL) rte_exit(EXIT_FAILURE, "Failed to open input file\n"); if (fread(ctx.input_buffer, 1, ctx.input_size, fp) != ctx.input_size) { fclose(fp); rte_exit(EXIT_FAILURE, "Failed to read input file\n"); } fclose(fp); /* Step 11: Create ML op mempool */ op_pool = rte_ml_op_pool_create("ml_op_pool", 1, 0, 0, config.socket_id); if (op_pool == NULL) rte_exit(EXIT_FAILURE, "Failed to create op pool\n"); /* Step 12: Form an ML op */ rte_mempool_get_bulk(op_pool, (void *)op_enq, 1); op_enq->model_id = ctx.id; op_enq->nb_batches = ctx.info.batch_size; op_enq->mempool = op_pool; op_enq->input.addr = ctx.input_buffer; op_enq->input.length = ctx.input_size; op_enq->input.next = NULL; op_enq->output.addr = ctx.output_buffer; op_enq->output.length = ctx.output_size; op_enq->output.next = NULL; /* Step 13: Enqueue jobs */ rte_ml_enqueue_burst(0, 0, &op_enq, 1); /* Step 14: Dequeue jobs and release op pool */ while (rte_ml_dequeue_burst(0, 0, &op_deq, 1) != 1) ; /* Step 15: Write output */ fp = fopen(ctx.out_file, "w+"); if (fp == NULL) rte_exit(EXIT_FAILURE, "Failed to open output file\n"); fwrite(ctx.output_buffer, 1, ctx.output_size, fp); fclose(fp); /* Step 16: Clean up */ /* Stop ML model */ rte_ml_model_stop(0, ctx.id); /* Unload ML model */ rte_ml_model_unload(0, ctx.id); /* Free input/output memory */ rte_memzone_free(rte_memzone_lookup(IO_MZ)); /* Free the ml op back to pool */ rte_mempool_put_bulk(op_pool, (void *)op_deq, 1); /* Free ml op pool */ rte_mempool_free(op_pool); /* Stop the device */ rte_ml_dev_stop(0); rte_ml_dev_close(0); rte_eal_cleanup(); return 0; }Jerin Jacob (1):
mldev: introduce machine learning device librarySrikanth Yalavarthi (11):
mldev: support PMD functions for ML device
mldev: support ML device handling functions
mldev: support ML device queue-pair setup
mldev: support handling ML models
mldev: support input and output data handling
mldev: support ML op pool and ops
mldev: support inference enqueue and dequeue
mldev: support device statistics
mldev: support device extended statistics
mldev: support to retrieve error information
mldev: support to get debug info and test deviceMAINTAINERS | 5 + doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + doc/guides/prog_guide/img/mldev_flow.svg | 714 ++++++++++++++ doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/mldev.rst | 186 ++++ doc/guides/rel_notes/release_23_03.rst | 5 + lib/meson.build | 1 + lib/mldev/meson.build | 27 + lib/mldev/rte_mldev.c | 947 ++++++++++++++++++ lib/mldev/rte_mldev.h | 1119 ++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 717 ++++++++++++++ lib/mldev/rte_mldev_pmd.c | 62 ++ lib/mldev/rte_mldev_pmd.h | 151 +++ lib/mldev/version.map | 51 + 15 files changed, 3988 insertions(+) create mode 100644 doc/guides/prog_guide/img/mldev_flow.svg create mode 100644 doc/guides/prog_guide/mldev.rst create mode 100644 lib/mldev/meson.build create mode 100644 lib/mldev/rte_mldev.c create mode 100644 lib/mldev/rte_mldev.h create mode 100644 lib/mldev/rte_mldev_core.h create mode 100644 lib/mldev/rte_mldev_pmd.c create mode 100644 lib/mldev/rte_mldev_pmd.h create mode 100644 lib/mldev/version.map
Quoted 9 lines · Ferruh Yigit
Quoted 2 lines · On 2/7/2023 3:13 PM, [email protected] wrote:
From: Jerin Jacob <[email protected]>
Hi Jerin,
Please find some comments/questions gathered with the help of some collegues.
Thanks Ferruh for the review.
Quoted 95 lines
Quoted 13 lines
Machine learning inference library
==================================Definition of machine learning inference
----------------------------------------
Inference in machine learning is the process of making an output prediction based on new input data using a pre-trained machine learning model.The scope of the RFC would include only inferencing with pre-trained machine learning models, training and building/compiling the ML models is out of scope for this RFC or DPDK mldev API. Use existing machine learning compiler frameworks for model creation.
Quoted 7 lines
Motivation for the new library
------------------------------
Multiple semiconductor vendors are offering accelerator products such as DPU (often called Smart-NIC), FPGA, GPU, etc., which have ML inferencing capabilities integrated as part of the product. Use of ML inferencing is increasing in the domain of packet processing for flow classification, intrusion, malware and anomaly detection.Agree on this need.
Quoted 6 lines
Lack of inferencing support through DPDK APIs will involve complexities and increased latency from moving data across frameworks (i.e, dataplane to non dataplane ML frameworks and vice-versa). Having a standardized DPDK APIs for ML inferencing would enable the dataplane solutions to harness the benefit of inline inferencing supported by the hardware.
ack
Quoted 52 lines
Contents
---------------
A) API specification for:1) Discovery of ML capabilities (e.g., device specific features) in a vendor independent fashion
2) Definition of functions to handle ML devices, which includes probing, initialization and termination of the devices.
3) Definition of functions to handle ML models used to perform inference operations.
4) Definition of function to handle quantize and dequantize operationsB) Common code for above specification
rfc..v1:
- Added programmer guide documentation
- Added implementation for common codev2..v1:
- Moved dynamic log (Stephen)
- model id touint16_tfromint16t_t(Stephen)
- added release note updatesv3..v2:
- Introducedrte_ml_dev_init()similar torte_gpu_init()(Stephen, Thomas)
- In structrte_ml_dev_data, removed reserved[3] and__rte_cache_aligned.
Also, moved name field to the end(Stephen)Machine learning library framework
----------------------------------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 | | +--------+Quoted 9 lines
| +-------------+ | | +-------------+ |<------- rte_ml_model_load() | | Model .. | |-------> rte_ml_model_info() | +-------------+ |<------- rte_ml_model_start() | +-------------+ |<------- rte_ml_model_stop() | | Model N | |<------- rte_ml_model_params_update() | +-------------+ |<------- rte_ml_model_unload() +-----------------+
Quoted 2 lines
Should model load/unload,
params_updatebe part of dpdk, or dpdk can assume these are already in place.
The driver hooks can be NOPs if the model is already loaded or fixed model FPGA solutions.
Probably we can add parameter info_get() in case if someone think user needs to be aware of it.
Currently its an experimental API, when such device comes we can extent the rte_ml_dev_infostructure if/as needed.
Quoted 2 lines
For FPGA both options works, what is
the benefit to have these APIs part of DPDK?
Support for runtime load/unload model if ml devices supports it. Also it has some bearing on data-path as inference needs to be stopped if one need to unload the model.
Quoted 1 line
What are usecases for other architectures?
When a device supports max N models (rte_ml_dev_info::max_models), a user can replace unused model at runtime when the max number model are reached.
Quoted 8 lines
Is multiple active models at same time supported?
For FPGA case multiple models may exist at same time, it would be good to have a way to select the model to use, like a handle for model that API accepts.
Similarly a handle for model may help chaining models, possibly with help of additional APIs to define the chaining.
Yes, multiple active models are supported simultaneously. Each model loaded would have unique model_id assigned by the driver which can be used as a handle, while queuing inference requests or doing slow-path operations.
Quoted 6 lines
Quoted 4 lines
ML Device: A hardware or software-based implementation of ML device API for running inferences using a pre-trained ML model.
Can this device consume multiple queues in parallel?
Yes, spec doesn't impose any restrictions on the number of queues that can be consumed by the device.
Actual number of queues permitted is dependent on the device. see rte_ml_dev_info:max_queue_pairs
Quoted 33 lines
Quoted 26 lines
ML Model: An ML model is an algorithm trained over a dataset. A model consists of procedure/algorithm and data/pattern required to make predictions on live data. Once the model is created and trained outside of the DPDK scope, the model can be loaded via
rte_ml_model_load()and then start it usingrte_ml_model_start()API. Therte_ml_model_params_update()can be used to update the model parameters such as weight and bias without unloading the model usingrte_ml_model_unload().ML Inference: ML inference is the process of feeding data to the model via
rte_ml_enqueue_burst()API and userte_ml_dequeue_burst()API to get the calculated outputs/predictions from the started model.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 setup a device designated by its device identifier must be invoked in the following order:
-
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. Application needs to invoke the ML model API in the following order before queueing inference jobs.
Quoted 6 lines
-
rte_ml_model_load()
-rte_ml_model_start()The
rte_ml_model_info()API is provided to retrieve the information related to the model. The information would include the shape and type of input and output required for the inference.
Quoted 5 lines
It seems there is a sandardization effort for model description, called ONNX (https://onnx.ai/), supported by many vendors.
Does it make sense that '
rte_ml_model_info()' describes data, and perhaps model itself too, using onnx format?
ONNX format is presents higher number of details, which may not be required from a dataplane point-of-view.
We have proposed a rte_ml_model_info struct with the most important fields that required. This structure can be expanded further as required.
Quoted 11 lines
Quoted 9 lines
Data quantization and dequantization is one of the main aspects in ML domain. This involves conversion of 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 throughrte_ml_io_dequantize(). These APIs have the capability to handle input and output buffers holding data for multiple batches.
Two utility APIsrte_ml_io_input_size_get()andrte_ml_io_output_size_get()can used to get the size of quantized and de-quantized multi-batch input and output buffers.
Quoted 3 lines
It seems quantize and dequantize can be part of model and optimized during training, can you please some information HW architecture that needs these APIs?
Marvell HW engines don't support quantization/dequantization in HW and the same has to be done by software on ARM64/x64 cores.
The same applies for SW based mldevices.
So it can NOP for the device which already supports it or we can introduce the capability
when such drivers getting added to DPDK. No issue in updating the API when new driver comes.
Quoted 4 lines
Does it make sense to have quantize/dequantize as a capability, like in case HW has specific support for it this can be used, else host can provide this functionality.
We tried to keep the APIs minimal in the initial version. Yes. quantize/dequantize capability can be part of these device capabilities when such devices added.
Quoted 37 lines
Quoted 23 lines
User can optionally update the model parameters with
rte_ml_model_params_update()after invokingrte_ml_model_stop()API on a given model ID.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()orrte_ml_dev_queue_pair_setup()), then application must stop the device usingrte_ml_dev_stop()API. Likewise, if model parameters need to be updated then the application must callrte_ml_model_stop()followed byrte_ml_model_params_update()API for the given model. The application does not need to callrte_ml_dev_stop()API for any model re-configuration such asrte_ml_model_params_update(),rte_ml_model_unload()etc.Once the device is in the start state after invoking
rte_ml_dev_start()API and the model is in start state after invokingrte_ml_model_start()API, then the application can callrte_ml_enqueue()andrte_ml_dequeue()API on the destined device and model ID.Finally, an application can close an ML device by invoking the
rte_ml_dev_close()function.Typical application utilisation of the ML API will follow the following programming flow.
Quoted 13 lines
-
rte_ml_dev_configure()
-rte_ml_dev_queue_pair_setup()
-rte_ml_model_load()
-rte_ml_model_start()
-rte_ml_model_info()
-rte_ml_dev_start()
-rte_ml_enqueue_burst()
-rte_ml_dequeue_burst()
-rte_ml_model_stop()
-rte_ml_model_unload()
-rte_ml_dev_stop()
-rte_ml_dev_close()
Quoted 1 line
is a '
reset()' API needed?
We can add in future, if a specific HW needs/supports it. Keeping
bare minium for first version.
Quoted 260 lines
Quoted 259 lines
Regarding multi-threading, by default, all the functions of the ML Device API exported by a PMD are lock-free functions which assume to not be 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 same queue pair. Of course, this function can be invoked in parallel by different logical core on different queue pair.
It is the responsibility of the user application to enforce this rule.Example application usage for ML inferencing
--------------------------------------------
This example application is to demonstrate the programming model of ML device library. This example omits the error checks to simplify the application. This example also assumes that the input data received is quantized and output expected is also quantized. In order to handle non-quantized inputs and outputs, users can invokerte_ml_io_quantize()orrte_ml_io_dequantize()for data type conversions.#define
ML_MODEL_NAME"model"
#defineIO_MZ"io_mz"struct app_ctx { char model_file[PATH_MAX]; char inp_file[PATH_MAX]; char out_file[PATH_MAX]; struct rte_ml_model_params params; struct rte_ml_model_info info; uint16_t id; uint64_t input_size; uint64_t output_size; uint8_t *input_buffer; uint8_t *output_buffer; } __rte_cache_aligned;struct
app_ctxctx;static int
parse_args(int argc, char **argv){ int opt, option_index; static struct option lgopts[] = {{"model", required_argument, NULL, 'm'}, {"input", required_argument, NULL, 'i'}, {"output", required_argument, NULL, 'o'}, {NULL, 0, NULL, 0}}; while ((opt = getopt_long(argc, argv, "m:i:o:", lgopts, &option_index)) != EOF) switch (opt) { case 'm': strncpy(ctx.model_file, optarg, PATH_MAX - 1); break; case 'i': strncpy(ctx.inp_file, optarg, PATH_MAX - 1); break; case 'o': strncpy(ctx.out_file, optarg, PATH_MAX - 1); break; default: return -1; } return 0; }int
main(int argc, char **argv){ struct rte_ml_dev_qp_conf qp_conf; struct rte_ml_dev_config config; struct rte_ml_dev_info dev_info; const struct rte_memzone *mz; struct rte_mempool *op_pool; struct rte_ml_op *op_enq; struct rte_ml_op *op_deq; FILE *fp; int rc; /* Initialize EAL */ rc = rte_eal_init(argc, argv); if (rc < 0) rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n"); argc -= rc; argv += rc; /* Parse application arguments (after the EAL args) */ if (parse_args(argc, argv) < 0) rte_exit(EXIT_FAILURE, "Invalid application arguments\n"); /* Step 1: Check for ML devices */ if (rte_ml_dev_count() <= 0) rte_exit(EXIT_FAILURE, "Failed to find ML devices\n"); /* Step 2: Get device info */ if (rte_ml_dev_info_get(0, &dev_info) != 0) rte_exit(EXIT_FAILURE, "Failed to get device info\n"); /* Step 3: Configure ML device, use device 0 */ config.socket_id = rte_ml_dev_socket_id(0); config.max_nb_models = dev_info.max_models; config.nb_queue_pairs = dev_info.max_queue_pairs; if (rte_ml_dev_configure(0, &config) != 0) rte_exit(EXIT_FAILURE, "Device configuration failed\n"); /* Step 4: Setup queue pairs, used qp_id = 0 */ qp_conf.nb_desc = 1; if (rte_ml_dev_queue_pair_setup(0, 0, &qp_conf, config.socket_id) != 0) rte_exit(EXIT_FAILURE, "Queue-pair setup failed\n"); /* Step 5: Start device */ if (rte_ml_dev_start(0) != 0) rte_exit(EXIT_FAILURE, "Device start failed\n"); /* Step 6: Read model data and update load params structure */ fp = fopen(ctx.model_file, "r+"); if (fp == NULL) rte_exit(EXIT_FAILURE, "Failed to open model file\n"); fseek(fp, 0, SEEK_END); ctx.params.size = ftell(fp); fseek(fp, 0, SEEK_SET); ctx.params.addr = malloc(ctx.params.size); if (fread(ctx.params.addr, 1, ctx.params.size, fp) != ctx.params.size){ fclose(fp); rte_exit(EXIT_FAILURE, "Failed to read model\n"); } fclose(fp); strcpy(ctx.params.name, ML_MODEL_NAME); /* Step 7: Load the model */ if (rte_ml_model_load(0, &ctx.params, &ctx.id) != 0) rte_exit(EXIT_FAILURE, "Failed to load model\n"); free(ctx.params.addr); /* Step 8: Start the model */ if (rte_ml_model_start(0, ctx.id) != 0) rte_exit(EXIT_FAILURE, "Failed to start model\n"); /* Step 9: Allocate buffers for quantized input and output */ /* Get model information */ if (rte_ml_model_info_get(0, ctx.id, &ctx.info) != 0) rte_exit(EXIT_FAILURE, "Failed to get model info\n"); /* Get the buffer size for input and output */ rte_ml_io_input_size_get(0, ctx.id, ctx.info.batch_size, &ctx.input_size, NULL); rte_ml_io_output_size_get(0, ctx.id, ctx.info.batch_size, &ctx.output_size, NULL); mz = rte_memzone_reserve(IO_MZ, ctx.input_size + ctx.output_size, config.socket_id, 0); if (mz == NULL) rte_exit(EXIT_FAILURE, "Failed to create IO memzone\n"); ctx.input_buffer = mz->addr; ctx.output_buffer = ctx.input_buffer + ctx.input_size; /* Step 10: Fill the input data */ fp = fopen(ctx.inp_file, "r+"); if (fp == NULL) rte_exit(EXIT_FAILURE, "Failed to open input file\n"); if (fread(ctx.input_buffer, 1, ctx.input_size, fp) != ctx.input_size) { fclose(fp); rte_exit(EXIT_FAILURE, "Failed to read input file\n"); } fclose(fp); /* Step 11: Create ML op mempool */ op_pool = rte_ml_op_pool_create("ml_op_pool", 1, 0, 0, config.socket_id); if (op_pool == NULL) rte_exit(EXIT_FAILURE, "Failed to create op pool\n"); /* Step 12: Form an ML op */ rte_mempool_get_bulk(op_pool, (void *)op_enq, 1); op_enq->model_id = ctx.id; op_enq->nb_batches = ctx.info.batch_size; op_enq->mempool = op_pool; op_enq->input.addr = ctx.input_buffer; op_enq->input.length = ctx.input_size; op_enq->input.next = NULL; op_enq->output.addr = ctx.output_buffer; op_enq->output.length = ctx.output_size; op_enq->output.next = NULL; /* Step 13: Enqueue jobs */ rte_ml_enqueue_burst(0, 0, &op_enq, 1); /* Step 14: Dequeue jobs and release op pool */ while (rte_ml_dequeue_burst(0, 0, &op_deq, 1) != 1) ; /* Step 15: Write output */ fp = fopen(ctx.out_file, "w+"); if (fp == NULL) rte_exit(EXIT_FAILURE, "Failed to open output file\n"); fwrite(ctx.output_buffer, 1, ctx.output_size, fp); fclose(fp); /* Step 16: Clean up */ /* Stop ML model */ rte_ml_model_stop(0, ctx.id); /* Unload ML model */ rte_ml_model_unload(0, ctx.id); /* Free input/output memory */ rte_memzone_free(rte_memzone_lookup(IO_MZ)); /* Free the ml op back to pool */ rte_mempool_put_bulk(op_pool, (void *)op_deq, 1); /* Free ml op pool */ rte_mempool_free(op_pool); /* Stop the device */ rte_ml_dev_stop(0); rte_ml_dev_close(0); rte_eal_cleanup(); return 0; }Jerin Jacob (1):
mldev: introduce machine learning device librarySrikanth Yalavarthi (11):
mldev: support PMD functions for ML device
mldev: support ML device handling functions
mldev: support ML device queue-pair setup
mldev: support handling ML models
mldev: support input and output data handling
mldev: support ML op pool and ops
mldev: support inference enqueue and dequeue
mldev: support device statistics
mldev: support device extended statistics
mldev: support to retrieve error information
mldev: support to get debug info and test deviceMAINTAINERS | 5 + doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + doc/guides/prog_guide/img/mldev_flow.svg | 714 ++++++++++++++ doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/mldev.rst | 186 ++++ doc/guides/rel_notes/release_23_03.rst | 5 + lib/meson.build | 1 + lib/mldev/meson.build | 27 + lib/mldev/rte_mldev.c | 947 ++++++++++++++++++ lib/mldev/rte_mldev.h | 1119 ++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 717 ++++++++++++++ lib/mldev/rte_mldev_pmd.c | 62 ++ lib/mldev/rte_mldev_pmd.h | 151 +++ lib/mldev/version.map | 51 + 15 files changed, 3988 insertions(+) create mode 100644 doc/guides/prog_guide/img/mldev_flow.svg create mode 100644 doc/guides/prog_guide/mldev.rst create mode 100644 lib/mldev/meson.build create mode 100644 lib/mldev/rte_mldev.c create mode 100644 lib/mldev/rte_mldev.h create mode 100644 lib/mldev/rte_mldev_core.h create mode 100644 lib/mldev/rte_mldev_pmd.c create mode 100644 lib/mldev/rte_mldev_pmd.h create mode 100644 lib/mldev/version.map
07/02/2023 16:13, [email protected]:
Quoted 15 lines
Jerin Jacob (1):
mldev: introduce machine learning device librarySrikanth Yalavarthi (11):
mldev: support PMD functions for ML device
mldev: support ML device handling functions
mldev: support ML device queue-pair setup
mldev: support handling ML models
mldev: support input and output data handling
mldev: support ML op pool and ops
mldev: support inference enqueue and dequeue
mldev: support device statistics
mldev: support device extended statistics
mldev: support to retrieve error information
mldev: support to get debug info and test device
Applied with few styling improvements for the doc, thanks.
One more library in DPDK :)
Quoted 5 lines · On Wed, 3 Aug 2022 18:58:37 +0530 <[email protected]> wrote:
Roadmap
-------
1) Address the comments for this RFC.
2) Common code for mldev
3) SW mldev driver based on TVM (https://tvm.apache.org/)
Having a SW implementation is important because then it can be covered by tests.
Quoted 4 lines · Stephen Hemminger
On Wed, 3 Aug 2022 18:58:37 +0530
<[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Roadmap
-------
1) Address the comments for this RFC.
2) Common code for mldev
3) SW mldev driver based on TVM (https://tvm.apache.org/)Having a SW implementation is important because then it can be covered by tests.
Yes. That reason for adding TVM based SW driver as item (3).
Is there any other high level or API level comments before proceeding with v1 and implementation.
Or Anyone else interested to review or contribute to this new DPDK device class?
Quoted 15 lines
From: Jerin Jacob [mailto:[email protected]]
Sent: Tuesday, 16 August 2022 15.13Quoted 10 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 3 Aug 2022 18:58:37 +0530 <[email protected]> wrote:
Roadmap
-------
1) Address the comments for this RFC.
2) Common code for mldev
3) SW mldev driver based on TVM (https://tvm.apache.org/)
Quoted 8 lines
Quoted 1 line
Having a SW implementation is important because then it can be
covered
Quoted 1 line
by tests.
Yes. That reason for adding TVM based SW driver as item (3).
Is there any other high level or API level comments before proceeding with v1 and implementation.
Have you seriously considered if the DPDK Project is the best home for this project? I can easily imagine the DPDK development process being a hindrance in many aspects for an evolving AI/ML library. Off the top of my head, it would probably be better off as a separate project, like SPDK.
If all this stuff can be completely omitted at build time, I have no objections.
A small note about naming (not intending to start a flame war, so please feel free to ignore!): I haven't worked seriously with ML/AI since university three decades ago, so I'm quite rusty in the domain. However, I don't see any Machine Learning functions proposed by this API. The library provides an API to an Inference Engine - but nobody says the inference model stems from Machine Learning; it might as well be a hand crafted model. Do you plan to propose APIs for training the models? If not, the name of the library could confuse some potential users.
Quoted 2 lines
Or Anyone else interested to review or contribute to this new DPDK device class?
<snip>
Quoted 21 lines
Quoted 21 lines
From: Jerin Jacob [mailto:[email protected]]
Sent: Tuesday, 16 August 2022 15.13Quoted 11 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 3 Aug 2022 18:58:37 +0530 <[email protected]> wrote:
Roadmap
-------
1) Address the comments for this RFC.
2) Common code for mldev
3) SW mldev driver based on TVM (https://tvm.apache.org/)Having a SW implementation is important because then it can be
covered
Quoted 1 line
by tests.
Yes. That reason for adding TVM based SW driver as item (3).
Quoted 7 lines
Quoted 2 lines
Is there any other high level or API level comments before proceeding with v1 and implementation.
Have you seriously considered if the DPDK Project is the best home for this project? I can easily imagine the DPDK development process being a hindrance in many aspects for an evolving AI/ML library. Off the top of my head, it would probably be better off as a separate project, like SPDK.
There is a lot of talk about using ML in networking workloads. Although, I am not very sure on how the use case looks like. For ex: is the inference engine going to be inline (i.e. the packet goes through the inference engine before coming to the CPU and provide some data (what sort of data?)), look aside (does it require the packets to be sent to the inference engine or is it some other data?), what would be an end to end use case? A sample application using these APIs would be helpful.
IMO, if we need to share the packets with the inference engine, then it fits into DPDK.
As I understand, there are many mature open source projects for ML/inference outside of DPDK. Does it make sense for DPDK to adopt those projects rather than inventing our own?
Quoted 11 lines
If all this stuff can be completely omitted at build time, I have no objections.
A small note about naming (not intending to start a flame war, so please feel free to ignore!): I haven't worked seriously with ML/AI since university three decades ago, so I'm quite rusty in the domain. However, I don't see any Machine Learning functions proposed by this API. The library provides an API to an Inference Engine - but nobody says the inference model stems from Machine Learning; it might as well be a hand crafted model. Do you plan to propose APIs for training the models? If not, the name of the library could confuse some potential users.
I think, at least on the edge devices, we need an inference device as ML requires more cycles/power.
Quoted 3 lines
Quoted 3 lines
Or Anyone else interested to review or contribute to this new DPDK device class?
Quoted 24 lines · Honnappa Nagarahalli
<snip>
Quoted 21 lines
Quoted 21 lines
From: Jerin Jacob [mailto:[email protected]]
Sent: Tuesday, 16 August 2022 15.13Quoted 11 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 3 Aug 2022 18:58:37 +0530 <[email protected]> wrote:
Roadmap
-------
1) Address the comments for this RFC.
2) Common code for mldev
3) SW mldev driver based on TVM (https://tvm.apache.org/)Having a SW implementation is important because then it can be
covered
Quoted 1 line
by tests.
Yes. That reason for adding TVM based SW driver as item (3).
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Is there any other high level or API level comments before proceeding with v1 and implementation.
Have you seriously considered if the DPDK Project is the best home for this project? I can easily imagine the DPDK development process being a hindrance in many aspects for an evolving AI/ML library. Off the top of my head, it would probably be better off as a separate project, like SPDK.
There is a lot of talk about using ML in networking workloads. Although, I am not very sure on how the use case looks like. For ex: is the inference engine going to be inline (i.e. the packet goes through the inference engine before coming to the CPU and provide some data (what sort of data?)), look aside (does it require the packets to be sent to the inference engine or is it some other data?), what would be an end to end use case? A sample application using these APIs would be helpful.
Simple application for the inference usage is added in the cover letter.
Regarding the use cases, There are many like firewall, intrusion detection etc. Most of the use cases are driven by product requirements and SW IP vendors try to keep it to themselves as a product differentiate factor.
That is the prime reason for DPDK scope only for inference where IO is involved. Model creation and training etc will heavily vary based on use case but not the inference model.
Quoted 2 lines
IMO, if we need to share the packets with the inference engine, then it fits into DPDK.
Yes. Yes for networking or ORAN use cases the interface data comes over wire and result can go over wire.
Quoted 2 lines
As I understand, there are many mature open source projects for ML/inference outside of DPDK. Does it make sense for DPDK to adopt those projects rather than inventing our own?
# AI/ML compiler libraries more focused on model creation and training etc (Thats where actual value addition the AI/ML libraries can offer) and
minimal part for inference (It is just added for testing the model) # Considering the inference is the scope of the DPDK. DPDK is ideal place for following reasons
a) Inference scope is very limited.
b) Avoid memcpy of inference data (Use directly from network or other class of device like cryptodev, regexdev)
c) Reuse highspeed IO interface like PCI backed driver etc
d) Integration with other DPDK subsystems like eventdev etc for job completion.
e) Also support more inline offloads by merging two device classes like rte_secuity.
f) Run the inference model from different AI/ML compiler frameworks or abstract the inference usage.
Similar concept is already applied to other DPDK device classes like
1) In Regexdev, The compiler generates the rule database which is out of scope of DPDK. DPDK API just loads the rule database
2) In Gpudev, The GPU kernel etc out of scope of DPDK.DPDK cares about IO interface.
Quoted 18 lines
Quoted 4 lines
If all this stuff can be completely omitted at build time, I have no objections.
Quoted 8 lines
A small note about naming (not intending to start a flame war, so please feel free to ignore!): I haven't worked seriously with ML/AI since university three decades ago, so I'm quite rusty in the domain. However, I don't see any Machine Learning functions proposed by this API. The library provides an API to an Inference Engine - but nobody says the inference model stems from Machine Learning; it might as well be a hand crafted model. Do you plan to propose APIs for training the models? If not, the name of the library could confuse some potential users.
I think, at least on the edge devices, we need an inference device as ML requires more cycles/power.
Quoted 3 lines
Quoted 3 lines
Or Anyone else interested to review or contribute to this new DPDK device class?
17/08/2022 16:53, Jerin Jacob:
Quoted 61 lines
Quoted 24 lines · Honnappa Nagarahalli
<snip>
Quoted 21 lines
Quoted 21 lines
From: Jerin Jacob [mailto:[email protected]]
Sent: Tuesday, 16 August 2022 15.13Quoted 11 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 3 Aug 2022 18:58:37 +0530 <[email protected]> wrote:
Roadmap
-------
1) Address the comments for this RFC.
2) Common code for mldev
3) SW mldev driver based on TVM (https://tvm.apache.org/)Having a SW implementation is important because then it can be
covered
Quoted 1 line
by tests.
Yes. That reason for adding TVM based SW driver as item (3).
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Is there any other high level or API level comments before proceeding with v1 and implementation.
Have you seriously considered if the DPDK Project is the best home for this project? I can easily imagine the DPDK development process being a hindrance in many aspects for an evolving AI/ML library. Off the top of my head, it would probably be better off as a separate project, like SPDK.
There is a lot of talk about using ML in networking workloads. Although, I am not very sure on how the use case looks like. For ex: is the inference engine going to be inline (i.e. the packet goes through the inference engine before coming to the CPU and provide some data (what sort of data?)), look aside (does it require the packets to be sent to the inference engine or is it some other data?), what would be an end to end use case? A sample application using these APIs would be helpful.
Simple application for the inference usage is added in the cover letter.
Regarding the use cases, There are many like firewall, intrusion detection etc. Most of the use cases are driven by product requirements and SW IP vendors try to keep it to themselves as a product differentiate factor.
That is the prime reason for DPDK scope only for inference where IO is involved. Model creation and training etc will heavily vary based on use case but not the inference model.Quoted 2 lines
IMO, if we need to share the packets with the inference engine, then it fits into DPDK.
Yes. Yes for networking or ORAN use cases the interface data comes over wire and result can go over wire.
Quoted 2 lines
As I understand, there are many mature open source projects for ML/inference outside of DPDK. Does it make sense for DPDK to adopt those projects rather than inventing our own?
# AI/ML compiler libraries more focused on model creation and training etc (Thats where actual value addition the AI/ML libraries can offer) and
minimal part for inference (It is just added for testing the model) # Considering the inference is the scope of the DPDK. DPDK is ideal place for following reasons
Quoted 14 lines
a) Inference scope is very limited.
b) Avoid memcpy of inference data (Use directly from network or other class of device like cryptodev, regexdev)
c) Reuse highspeed IO interface like PCI backed driver etc
d) Integration with other DPDK subsystems like eventdev etc for job completion.
e) Also support more inline offloads by merging two device classes likerte_secuity.
f) Run the inference model from different AI/ML compiler frameworks or abstract the inference usage.
Similar concept is already applied to other DPDK device classes like
1) In Regexdev, The compiler generates the rule database which is out of scope of DPDK. DPDK API just loads the rule database
2) In Gpudev, The GPU kernel etc out of scope of DPDK.DPDK cares about IO interface.
I think Honnappa was thinking about linking an existing inference library. What are the similar libraries?
Quoted 78 lines · Thomas Monjalon
17/08/2022 16:53, Jerin Jacob:
Quoted 61 lines
Quoted 24 lines · Honnappa Nagarahalli
<snip>
Quoted 21 lines
Quoted 21 lines
From: Jerin Jacob [mailto:[email protected]]
Sent: Tuesday, 16 August 2022 15.13Quoted 11 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 3 Aug 2022 18:58:37 +0530 <[email protected]> wrote:
Roadmap
-------
1) Address the comments for this RFC.
2) Common code for mldev
3) SW mldev driver based on TVM (https://tvm.apache.org/)Having a SW implementation is important because then it can be
covered
Quoted 1 line
by tests.
Yes. That reason for adding TVM based SW driver as item (3).
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Is there any other high level or API level comments before proceeding with v1 and implementation.
Have you seriously considered if the DPDK Project is the best home for this project? I can easily imagine the DPDK development process being a hindrance in many aspects for an evolving AI/ML library. Off the top of my head, it would probably be better off as a separate project, like SPDK.
There is a lot of talk about using ML in networking workloads. Although, I am not very sure on how the use case looks like. For ex: is the inference engine going to be inline (i.e. the packet goes through the inference engine before coming to the CPU and provide some data (what sort of data?)), look aside (does it require the packets to be sent to the inference engine or is it some other data?), what would be an end to end use case? A sample application using these APIs would be helpful.
Simple application for the inference usage is added in the cover letter.
Regarding the use cases, There are many like firewall, intrusion detection etc. Most of the use cases are driven by product requirements and SW IP vendors try to keep it to themselves as a product differentiate factor.
That is the prime reason for DPDK scope only for inference where IO is involved. Model creation and training etc will heavily vary based on use case but not the inference model.Quoted 2 lines
IMO, if we need to share the packets with the inference engine, then it fits into DPDK.
Yes. Yes for networking or ORAN use cases the interface data comes over wire and result can go over wire.
Quoted 2 lines
As I understand, there are many mature open source projects for ML/inference outside of DPDK. Does it make sense for DPDK to adopt those projects rather than inventing our own?
# AI/ML compiler libraries more focused on model creation and training etc (Thats where actual value addition the AI/ML libraries can offer) and
minimal part for inference (It is just added for testing the model) # Considering the inference is the scope of the DPDK. DPDK is ideal place for following reasonsQuoted 14 lines
a) Inference scope is very limited.
b) Avoid memcpy of inference data (Use directly from network or other class of device like cryptodev, regexdev)
c) Reuse highspeed IO interface like PCI backed driver etc
d) Integration with other DPDK subsystems like eventdev etc for job completion.
e) Also support more inline offloads by merging two device classes likerte_secuity.
f) Run the inference model from different AI/ML compiler frameworks or abstract the inference usage.
Similar concept is already applied to other DPDK device classes like
1) In Regexdev, The compiler generates the rule database which is out of scope of DPDK. DPDK API just loads the rule database
2) In Gpudev, The GPU kernel etc out of scope of DPDK.DPDK cares about IO interface.
Quoted 2 lines
I think Honnappa was thinking about linking an existing inference library. What are the similar libraries?
Not sure. Honnappa can tell if any which meets (a) to (f).
Quoted 2 lines
Quoted 18 lines · Morten Brørup
Quoted 18 lines
From: Jerin Jacob [mailto:[email protected]]
Sent: Tuesday, 16 August 2022 15.13Quoted 11 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 3 Aug 2022 18:58:37 +0530 <[email protected]> wrote:
Roadmap
-------
1) Address the comments for this RFC.
2) Common code for mldev
3) SW mldev driver based on TVM (https://tvm.apache.org/)Having a SW implementation is important because then it can be
covered
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
by tests.
Yes. That reason for adding TVM based SW driver as item (3).
Is there any other high level or API level comments before proceeding with v1 and implementation.
Have you seriously considered if the DPDK Project is the best home for this project? I can easily imagine the DPDK development process being a hindrance in many aspects for an evolving AI/ML library. Off the top of my head, it would probably be better off as a separate project, like SPDK.
Yes. The reasons are following
# AI/ML compiler libraries more focused on model creation and training etc (Thats where actual value addition the AI/ML libraries can offer) and minimal part for interference(It is just added for testing the model)
# Considering the inference is the scope of the DPDK. DPDK is ideal place for following reasons
a) Inference scope is very limited.
b) Avoid memcpy of interference data (Use directly from network or other class of device like cryptodev, regexdev)
c) Reuse highspeed IO interface like PCI backed driver etc
d) Integration with other DPDK subsystems like eventdev etc for job completion.
e) Also support more inline offloads by merging two device classes like rte_secuity.
f) Run the inference model from different AI/ML compiler frameworks or abstract the inference usage.
Similar concept is already applied to other DPDK device classes like
1) In Regexdev, The compiler generates the rule database which is out of scope of DPDK. DPDK API just loads the rule database
2) In Gpudev, The GPU kernel etc out of scope of DPDK.DPDK cares about IO interface.
Quoted 1 line
If all this stuff can be completely omitted at build time, I have no objections.
Yes, It can be completely omitted at build time. Also no plan to integrate to testpmd and other existing application. Planning to add only app/test-mldev application.
Quoted 2 lines
A small note about naming (not intending to start a flame war, so please feel free to ignore!): I haven't worked seriously with ML/AI since university three decades ago, so I'm quite rusty in the domain. However, I don't see any Machine Learning functions proposed by this API. The library provides an API to an Inference Engine - but nobody says the inference model stems from Machine Learning; it might as well be a hand crafted model. Do you plan to propose APIs for training the models? If not, the name of the library could confuse some potential users.
No, scope is only inference and it is documented in the programing guide and API header file. I am trying to keep name similar to regexdev, gpudev etc which have similar scope. But I am open to other shortname/name if you have something in mind.
Quoted 4 lines
Quoted 3 lines
Or Anyone else interested to review or contribute to this new DPDK device class?
Quoted 46 lines
From: Jerin Jacob [mailto:[email protected]]
Sent: Wednesday, 17 August 2022 07.37Quoted 16 lines · Morten Brørup
Quoted 16 lines
From: Jerin Jacob [mailto:[email protected]]
Sent: Tuesday, 16 August 2022 15.13Quoted 10 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 3 Aug 2022 18:58:37 +0530 <[email protected]> wrote:
Roadmap
-------
1) Address the comments for this RFC.
2) Common code for mldev
3) SW mldev driver based on TVM (https://tvm.apache.org/)Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Having a SW implementation is important because then it can be
covered
Quoted 1 line
by tests.
Yes. That reason for adding TVM based SW driver as item (3).
Is there any other high level or API level comments before
proceeding
Quoted 3 lines
Quoted 1 line
with v1 and implementation.
Have you seriously considered if the DPDK Project is the best home
for this project? I can easily imagine the DPDK development process being a hindrance in many aspects for an evolving AI/ML library. Off the top of my head, it would probably be better off as a separate project, like SPDK.
Yes. The reasons are following
# AI/ML compiler libraries more focused on model creation and training etc (Thats where actual value addition the AI/ML libraries can offer) and minimal part for interference(It is just added for testing the model)
# Considering the inference is the scope of the DPDK. DPDK is ideal place for following reasons
Quoted 15 lines
a) Inference scope is very limited.
b) Avoid memcpy of interference data (Use directly from network or other class of device like cryptodev, regexdev)
c) Reuse highspeed IO interface like PCI backed driver etc
d) Integration with other DPDK subsystems like eventdev etc for job completion.
e) Also support more inline offloads by merging two device classes likerte_secuity.
f) Run the inference model from different AI/ML compiler frameworks or abstract the inference usage.
Similar concept is already applied to other DPDK device classes like
1) In Regexdev, The compiler generates the rule database which is out of scope of DPDK. DPDK API just loads the rule database
2) In Gpudev, The GPU kernel etc out of scope of DPDK.DPDK cares about IO interface.
Thank you for the detailed reply, Jerin.
These are good reasons for adding the new device class to the DPDK project - especially the Regexdev comparison got me convinced.
Quoted 5 lines
Quoted 2 lines
If all this stuff can be completely omitted at build time, I have no
objections.
Yes, It can be completely omitted at build time.
Perfect.
Quoted 3 lines
Also no plan to
integrate to testpmd and other existing application. Planning to add only app/test-mldev application.
+1 to that
Quoted 12 lines
Quoted 3 lines
A small note about naming (not intending to start a flame war, so
please feel free to ignore!): I haven't worked seriously with ML/AI since university three decades ago, so I'm quite rusty in the domain. However, I don't see any Machine Learning functions proposed by this API. The library provides an API to an Inference Engine - but nobody says the inference model stems from Machine Learning; it might as well be a hand crafted model. Do you plan to propose APIs for training the models? If not, the name of the library could confuse some potential users.
Quoted 4 lines
No, scope is only inference and it is documented in the programing guide and API header file. I am trying to keep name similar to regexdev, gpudev etc which have similar scope. But I am open to other shortname/name if you have something in mind.
The AI(Artificial Intelligence)/ML(Machine Learning)/IE(Inference Engine) chip market still seems immature and fragmented, so I can't find any consensus on generic names for such hardware accelerator devices.
Some of the chip vendors represented on the DPDK mailing list offer AI/ML/IE accelerator chips. Perhaps their marketing department could propose alternatives to "Machine Learning Device"/"mldev" for inference engine devices (with no acceleration for training the models). If not, the initially proposed name is good enough.
So: Everyone ask your marketing departments and speak up now, or the name "mldev" will be set in stone. ;-)
I'm thinking: While "Inference Engine Device"/iedev might be technically more correct, it doesn't have same value as "Machine Learning Device"/"mldev" on a marketing scale. And we should choose a name that we expect might become industry standard consensus.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Or Anyone else interested to review or contribute to this new DPDK device class?
17/08/2022 08:58, Morten Brørup:
Quoted 97 lines
Quoted 46 lines
From: Jerin Jacob [mailto:[email protected]]
Sent: Wednesday, 17 August 2022 07.37Quoted 16 lines · Morten Brørup
Quoted 16 lines
From: Jerin Jacob [mailto:[email protected]]
Sent: Tuesday, 16 August 2022 15.13Quoted 10 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 3 Aug 2022 18:58:37 +0530 <[email protected]> wrote:
Roadmap
-------
1) Address the comments for this RFC.
2) Common code for mldev
3) SW mldev driver based on TVM (https://tvm.apache.org/)Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Having a SW implementation is important because then it can be
covered
Quoted 1 line
by tests.
Yes. That reason for adding TVM based SW driver as item (3).
Is there any other high level or API level comments before
proceeding
Quoted 3 lines
Quoted 1 line
with v1 and implementation.
Have you seriously considered if the DPDK Project is the best home
for this project? I can easily imagine the DPDK development process being a hindrance in many aspects for an evolving AI/ML library. Off the top of my head, it would probably be better off as a separate project, like SPDK.
Yes. The reasons are following
# AI/ML compiler libraries more focused on model creation and training etc (Thats where actual value addition the AI/ML libraries can offer) and minimal part for interference(It is just added for testing the model)
# Considering the inference is the scope of the DPDK. DPDK is ideal place for following reasonsQuoted 15 lines
a) Inference scope is very limited.
b) Avoid memcpy of interference data (Use directly from network or other class of device like cryptodev, regexdev)
c) Reuse highspeed IO interface like PCI backed driver etc
d) Integration with other DPDK subsystems like eventdev etc for job completion.
e) Also support more inline offloads by merging two device classes likerte_secuity.
f) Run the inference model from different AI/ML compiler frameworks or abstract the inference usage.
Similar concept is already applied to other DPDK device classes like
1) In Regexdev, The compiler generates the rule database which is out of scope of DPDK. DPDK API just loads the rule database
2) In Gpudev, The GPU kernel etc out of scope of DPDK.DPDK cares about IO interface.Thank you for the detailed reply, Jerin.
These are good reasons for adding the new device class to the DPDK project - especially the Regexdev comparison got me convinced.
Quoted 5 lines
Quoted 2 lines
If all this stuff can be completely omitted at build time, I have no
objections.
Yes, It can be completely omitted at build time.
Perfect.
Quoted 3 lines
Also no plan to
integrate to testpmd and other existing application. Planning to add only app/test-mldev application.+1 to that
Quoted 12 lines
Quoted 3 lines
A small note about naming (not intending to start a flame war, so
please feel free to ignore!): I haven't worked seriously with ML/AI since university three decades ago, so I'm quite rusty in the domain. However, I don't see any Machine Learning functions proposed by this API. The library provides an API to an Inference Engine - but nobody says the inference model stems from Machine Learning; it might as well be a hand crafted model. Do you plan to propose APIs for training the models? If not, the name of the library could confuse some potential users.
Quoted 4 lines
No, scope is only inference and it is documented in the programing guide and API header file. I am trying to keep name similar to regexdev, gpudev etc which have similar scope. But I am open to other shortname/name if you have something in mind.
Quoted 7 lines
The AI(Artificial Intelligence)/ML(Machine Learning)/IE(Inference Engine) chip market still seems immature and fragmented, so I can't find any consensus on generic names for such hardware accelerator devices.
Some of the chip vendors represented on the DPDK mailing list offer AI/ML/IE accelerator chips. Perhaps their marketing department could propose alternatives to "Machine Learning Device"/"mldev" for inference engine devices (with no acceleration for training the models). If not, the initially proposed name is good enough.
So: Everyone ask your marketing departments and speak up now, or the name "mldev" will be set in stone. ;-)
I'm thinking: While "Inference Engine Device"/iedev might be technically more correct, it doesn't have same value as "Machine Learning Device"/"mldev" on a marketing scale. And we should choose a name that we expect might become industry standard consensus.
I don't why but I like mldev and dislike iedev.
I could be OK with aidev as well.