DPDK 25.03.0-rc0
rte_mldev.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2022 Marvell.
3 */
4
5#ifndef RTE_MLDEV_H
6#define RTE_MLDEV_H
7
137#include <rte_common.h>
138#include <rte_log.h>
139#include <rte_mempool.h>
140
141#ifdef __cplusplus
142extern "C" {
143#endif
144
145/* Logging Macro */
146extern int rte_ml_dev_logtype;
147#define RTE_LOGTYPE_MLDEV rte_ml_dev_logtype
148
149#define RTE_MLDEV_LOG(level, ...) \
150 RTE_LOG_LINE_PREFIX(level, MLDEV, "%s(): ", __func__, __VA_ARGS__)
151
152#define RTE_ML_STR_MAX 128
155#define RTE_MLDEV_DEFAULT_MAX 32
158/* Device operations */
159
173__rte_experimental
174int
175rte_ml_dev_init(size_t dev_max);
176
183__rte_experimental
184uint16_t
186
197__rte_experimental
198int
200
212__rte_experimental
213int
214rte_ml_dev_socket_id(int16_t dev_id);
215
218 const char *driver_name;
220 uint16_t max_models;
228 uint16_t max_desc;
232 uint16_t max_io;
234 uint16_t max_segments;
238 uint16_t align_size;
240};
241
254__rte_experimental
255int
256rte_ml_dev_info_get(int16_t dev_id, struct rte_ml_dev_info *dev_info);
257
262 uint16_t nb_models;
272};
273
294__rte_experimental
295int
296rte_ml_dev_configure(int16_t dev_id, const struct rte_ml_dev_config *config);
297
298/* Forward declaration */
299struct rte_ml_op;
300
302typedef void (*rte_ml_dev_stop_flush_t)(int16_t dev_id, uint16_t qp_id, struct rte_ml_op *op);
303
306 uint32_t nb_desc;
318};
319
329__rte_experimental
330uint16_t
332
352__rte_experimental
353int
354rte_ml_dev_queue_pair_setup(int16_t dev_id, uint16_t queue_pair_id,
355 const struct rte_ml_dev_qp_conf *qp_conf, int socket_id);
356
370__rte_experimental
371int
372rte_ml_dev_start(int16_t dev_id);
373
385__rte_experimental
386int
387rte_ml_dev_stop(int16_t dev_id);
388
399__rte_experimental
400int
401rte_ml_dev_close(int16_t dev_id);
402
414};
415
421 void *addr;
423 uint32_t length;
425 uint32_t reserved;
429};
430
438 uint16_t model_id;
440 uint16_t nb_batches;
444 uint32_t reserved;
470 union {
471 uint64_t user_u64;
473 void *user_ptr;
475 };
478 uint64_t impl_opaque;
485};
486
487/* Enqueue/Dequeue operations */
488
519__rte_experimental
520uint16_t
521rte_ml_enqueue_burst(int16_t dev_id, uint16_t qp_id, struct rte_ml_op **ops, uint16_t nb_ops);
522
556__rte_experimental
557uint16_t
558rte_ml_dequeue_burst(int16_t dev_id, uint16_t qp_id, struct rte_ml_op **ops, uint16_t nb_ops);
559
565 uint64_t errcode;
566};
567
585__rte_experimental
586int
587rte_ml_op_error_get(int16_t dev_id, struct rte_ml_op *op, struct rte_ml_op_error *error);
588
589/* Statistics operations */
590
601};
602
615__rte_experimental
616int
617rte_ml_dev_stats_get(int16_t dev_id, struct rte_ml_dev_stats *stats);
618
625__rte_experimental
626void
628
637};
638
645 uint16_t id;
649};
650
677__rte_experimental
678int
679rte_ml_dev_xstats_names_get(int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id,
680 struct rte_ml_dev_xstats_map *xstats_map, uint32_t size);
681
699__rte_experimental
700int
701rte_ml_dev_xstats_by_name_get(int16_t dev_id, const char *name, uint16_t *stat_id, uint64_t *value);
702
726__rte_experimental
727int
728rte_ml_dev_xstats_get(int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id,
729 const uint16_t stat_ids[], uint64_t values[], uint16_t nb_ids);
730
749__rte_experimental
750int
751rte_ml_dev_xstats_reset(int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id,
752 const uint16_t stat_ids[], uint16_t nb_ids);
753
765__rte_experimental
766int
767rte_ml_dev_dump(int16_t dev_id, FILE *fd);
768
779__rte_experimental
780int
781rte_ml_dev_selftest(int16_t dev_id);
782
783/* Model operations */
784
790 void *addr;
792 size_t size;
794};
795
812__rte_experimental
813int
814rte_ml_model_load(int16_t dev_id, struct rte_ml_model_params *params, uint16_t *model_id);
815
828__rte_experimental
829int
830rte_ml_model_unload(int16_t dev_id, uint16_t model_id);
831
846__rte_experimental
847int
848rte_ml_model_start(int16_t dev_id, uint16_t model_id);
849
865__rte_experimental
866int
867rte_ml_model_stop(int16_t dev_id, uint16_t model_id);
868
903
932
941 uint32_t nb_dims;
943 uint32_t *shape;
949 uint64_t nb_elements;
951 uint64_t size;
953 float scale;
955 int64_t zero_point;
957};
958
965 uint16_t model_id;
967 uint16_t device_id;
971 uint16_t min_batches;
975 uint16_t max_batches;
979 uint32_t nb_inputs;
983 uint32_t nb_outputs;
987 uint64_t wb_size;
989};
990
1005__rte_experimental
1006int
1007rte_ml_model_info_get(int16_t dev_id, uint16_t model_id, struct rte_ml_model_info *model_info);
1008
1027__rte_experimental
1028int
1029rte_ml_model_params_update(int16_t dev_id, uint16_t model_id, void *buffer);
1030
1031/* IO operations */
1032
1052__rte_experimental
1053int
1054rte_ml_io_float32_to_int8(const void *fp32, void *i8, uint64_t nb_elements, float scale,
1055 int8_t zero_point);
1056
1076__rte_experimental
1077int
1078rte_ml_io_int8_to_float32(const void *i8, void *fp32, uint64_t nb_elements, float scale,
1079 int8_t zero_point);
1080
1100__rte_experimental
1101int
1102rte_ml_io_float32_to_uint8(const void *fp32, void *ui8, uint64_t nb_elements, float scale,
1103 uint8_t zero_point);
1104
1124__rte_experimental
1125int
1126rte_ml_io_uint8_to_float32(const void *ui8, void *fp32, uint64_t nb_elements, float scale,
1127 uint8_t zero_point);
1128
1148__rte_experimental
1149int
1150rte_ml_io_float32_to_int16(const void *fp32, void *i16, uint64_t nb_elements, float scale,
1151 int16_t zero_point);
1152
1172__rte_experimental
1173int
1174rte_ml_io_int16_to_float32(const void *i16, void *fp32, uint64_t nb_elements, float scale,
1175 int16_t zero_point);
1176
1196__rte_experimental
1197int
1198rte_ml_io_float32_to_uint16(const void *fp32, void *ui16, uint64_t nb_elements, float scale,
1199 uint16_t zero_point);
1200
1220__rte_experimental
1221int
1222rte_ml_io_uint16_to_float32(const void *ui16, void *fp32, uint64_t nb_elements, float scale,
1223 uint16_t zero_point);
1224
1244__rte_experimental
1245int
1246rte_ml_io_float32_to_int32(const void *fp32, void *i32, uint64_t nb_elements, float scale,
1247 int32_t zero_point);
1248
1269__rte_experimental
1270int
1271rte_ml_io_int32_to_float32(const void *i32, void *fp32, uint64_t nb_elements, float scale,
1272 int32_t zero_point);
1273
1293__rte_experimental
1294int
1295rte_ml_io_float32_to_uint32(const void *fp32, void *ui32, uint64_t nb_elements, float scale,
1296 uint32_t zero_point);
1297
1317__rte_experimental
1318int
1319rte_ml_io_uint32_to_float32(const void *ui32, void *fp32, uint64_t nb_elements, float scale,
1320 uint32_t zero_point);
1321
1341__rte_experimental
1342int
1343rte_ml_io_float32_to_int64(const void *fp32, void *i64, uint64_t nb_elements, float scale,
1344 int64_t zero_point);
1345
1365__rte_experimental
1366int
1367rte_ml_io_int64_to_float32(const void *i64, void *fp32, uint64_t nb_elements, float scale,
1368 int64_t zero_point);
1369
1389__rte_experimental
1390int
1391rte_ml_io_float32_to_uint64(const void *fp32, void *ui64, uint64_t nb_elements, float scale,
1392 uint64_t zero_point);
1393
1413__rte_experimental
1414int
1415rte_ml_io_uint64_to_float32(const void *ui64, void *fp32, uint64_t nb_elements, float scale,
1416 uint64_t zero_point);
1417
1433__rte_experimental
1434int
1435rte_ml_io_float32_to_float16(const void *fp32, void *fp16, uint64_t nb_elements);
1436
1452__rte_experimental
1453int
1454rte_ml_io_float16_to_float32(const void *fp16, void *fp32, uint64_t nb_elements);
1455
1471__rte_experimental
1472int
1473rte_ml_io_float32_to_bfloat16(const void *fp32, void *bf16, uint64_t nb_elements);
1474
1491__rte_experimental
1492int
1493rte_ml_io_bfloat16_to_float32(const void *bf16, void *fp32, uint64_t nb_elements);
1494
1515__rte_experimental
1516int
1517rte_ml_io_quantize(int16_t dev_id, uint16_t model_id, struct rte_ml_buff_seg **dbuffer,
1518 struct rte_ml_buff_seg **qbuffer);
1519
1539__rte_experimental
1540int
1541rte_ml_io_dequantize(int16_t dev_id, uint16_t model_id, struct rte_ml_buff_seg **qbuffer,
1542 struct rte_ml_buff_seg **dbuffer);
1543
1544/* ML op pool operations */
1545
1564__rte_experimental
1565struct rte_mempool *
1566rte_ml_op_pool_create(const char *name, unsigned int nb_elts, unsigned int cache_size,
1567 uint16_t user_size, int socket_id);
1568
1576__rte_experimental
1577void
1579
1580#ifdef __cplusplus
1581}
1582#endif
1583
1584#endif /* RTE_MLDEV_H */
uint64_t rte_iova_t
Definition: rte_common.h:658
#define __rte_cache_aligned
Definition: rte_common.h:627
__rte_experimental int rte_ml_io_float32_to_bfloat16(const void *fp32, void *bf16, uint64_t nb_elements)
__rte_experimental int rte_ml_io_float32_to_float16(const void *fp32, void *fp16, uint64_t nb_elements)
__rte_experimental int rte_ml_io_quantize(int16_t dev_id, uint16_t model_id, struct rte_ml_buff_seg **dbuffer, struct rte_ml_buff_seg **qbuffer)
__rte_experimental int rte_ml_io_uint8_to_float32(const void *ui8, void *fp32, uint64_t nb_elements, float scale, uint8_t zero_point)
__rte_experimental int rte_ml_dev_init(size_t dev_max)
__rte_experimental int rte_ml_io_uint64_to_float32(const void *ui64, void *fp32, uint64_t nb_elements, float scale, uint64_t zero_point)
__rte_experimental int rte_ml_model_start(int16_t dev_id, uint16_t model_id)
__rte_experimental struct rte_mempool * rte_ml_op_pool_create(const char *name, unsigned int nb_elts, unsigned int cache_size, uint16_t user_size, int socket_id)
__rte_experimental int rte_ml_io_float32_to_int8(const void *fp32, void *i8, uint64_t nb_elements, float scale, int8_t zero_point)
__rte_experimental int rte_ml_model_info_get(int16_t dev_id, uint16_t model_id, struct rte_ml_model_info *model_info)
rte_ml_io_layout
Definition: rte_mldev.h:905
@ RTE_ML_IO_LAYOUT_SPLIT
Definition: rte_mldev.h:919
@ RTE_ML_IO_LAYOUT_PACKED
Definition: rte_mldev.h:906
__rte_experimental int rte_ml_io_float16_to_float32(const void *fp16, void *fp32, uint64_t nb_elements)
__rte_experimental int rte_ml_dev_close(int16_t dev_id)
__rte_experimental int rte_ml_dev_start(int16_t dev_id)
__rte_experimental void rte_ml_op_pool_free(struct rte_mempool *mempool)
#define RTE_ML_STR_MAX
Definition: rte_mldev.h:152
__rte_experimental int rte_ml_dev_socket_id(int16_t dev_id)
__rte_experimental int rte_ml_dev_stats_get(int16_t dev_id, struct rte_ml_dev_stats *stats)
__rte_experimental int rte_ml_io_uint32_to_float32(const void *ui32, void *fp32, uint64_t nb_elements, float scale, uint32_t zero_point)
__rte_experimental int rte_ml_io_float32_to_int64(const void *fp32, void *i64, uint64_t nb_elements, float scale, int64_t zero_point)
__rte_experimental int rte_ml_dev_dump(int16_t dev_id, FILE *fd)
__rte_experimental void rte_ml_dev_stats_reset(int16_t dev_id)
__rte_experimental int rte_ml_io_dequantize(int16_t dev_id, uint16_t model_id, struct rte_ml_buff_seg **qbuffer, struct rte_ml_buff_seg **dbuffer)
__rte_experimental int rte_ml_io_int8_to_float32(const void *i8, void *fp32, uint64_t nb_elements, float scale, int8_t zero_point)
__rte_experimental int rte_ml_dev_is_valid_dev(int16_t dev_id)
__rte_experimental int rte_ml_dev_stop(int16_t dev_id)
__rte_experimental uint16_t rte_ml_enqueue_burst(int16_t dev_id, uint16_t qp_id, struct rte_ml_op **ops, uint16_t nb_ops)
__rte_experimental int rte_ml_dev_xstats_reset(int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id, const uint16_t stat_ids[], uint16_t nb_ids)
__rte_experimental int rte_ml_io_float32_to_uint64(const void *fp32, void *ui64, uint64_t nb_elements, float scale, uint64_t zero_point)
__rte_experimental int rte_ml_dev_xstats_get(int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id, const uint16_t stat_ids[], uint64_t values[], uint16_t nb_ids)
__rte_experimental int rte_ml_io_float32_to_uint8(const void *fp32, void *ui8, uint64_t nb_elements, float scale, uint8_t zero_point)
__rte_experimental uint16_t rte_ml_dev_count(void)
__rte_experimental int rte_ml_dev_queue_pair_setup(int16_t dev_id, uint16_t queue_pair_id, const struct rte_ml_dev_qp_conf *qp_conf, int socket_id)
__rte_experimental int rte_ml_io_bfloat16_to_float32(const void *bf16, void *fp32, uint64_t nb_elements)
__rte_experimental int rte_ml_model_unload(int16_t dev_id, uint16_t model_id)
__rte_experimental int rte_ml_io_float32_to_int16(const void *fp32, void *i16, uint64_t nb_elements, float scale, int16_t zero_point)
__rte_experimental uint16_t rte_ml_dev_queue_pair_count(int16_t dev_id)
__rte_experimental uint16_t rte_ml_dequeue_burst(int16_t dev_id, uint16_t qp_id, struct rte_ml_op **ops, uint16_t nb_ops)
__rte_experimental int rte_ml_dev_selftest(int16_t dev_id)
__rte_experimental int rte_ml_dev_xstats_by_name_get(int16_t dev_id, const char *name, uint16_t *stat_id, uint64_t *value)
__rte_experimental int rte_ml_model_stop(int16_t dev_id, uint16_t model_id)
rte_ml_dev_xstats_mode
Definition: rte_mldev.h:632
@ RTE_ML_DEV_XSTATS_MODEL
Definition: rte_mldev.h:635
@ RTE_ML_DEV_XSTATS_DEVICE
Definition: rte_mldev.h:633
__rte_experimental int rte_ml_op_error_get(int16_t dev_id, struct rte_ml_op *op, struct rte_ml_op_error *error)
__rte_experimental int rte_ml_dev_info_get(int16_t dev_id, struct rte_ml_dev_info *dev_info)
__rte_experimental int rte_ml_io_int32_to_float32(const void *i32, void *fp32, uint64_t nb_elements, float scale, int32_t zero_point)
rte_ml_op_status
Definition: rte_mldev.h:404
@ RTE_ML_OP_STATUS_ERROR
Definition: rte_mldev.h:409
@ RTE_ML_OP_STATUS_SUCCESS
Definition: rte_mldev.h:405
@ RTE_ML_OP_STATUS_NOT_PROCESSED
Definition: rte_mldev.h:407
__rte_experimental int rte_ml_io_float32_to_uint32(const void *fp32, void *ui32, uint64_t nb_elements, float scale, uint32_t zero_point)
__rte_experimental int rte_ml_io_int64_to_float32(const void *i64, void *fp32, uint64_t nb_elements, float scale, int64_t zero_point)
rte_ml_io_type
Definition: rte_mldev.h:875
@ RTE_ML_IO_TYPE_FP8
Definition: rte_mldev.h:894
@ RTE_ML_IO_TYPE_BFLOAT16
Definition: rte_mldev.h:900
@ RTE_ML_IO_TYPE_UINT8
Definition: rte_mldev.h:880
@ RTE_ML_IO_TYPE_UINT16
Definition: rte_mldev.h:884
@ RTE_ML_IO_TYPE_INT64
Definition: rte_mldev.h:890
@ RTE_ML_IO_TYPE_INT16
Definition: rte_mldev.h:882
@ RTE_ML_IO_TYPE_UINT64
Definition: rte_mldev.h:892
@ RTE_ML_IO_TYPE_FP32
Definition: rte_mldev.h:898
@ RTE_ML_IO_TYPE_UINT32
Definition: rte_mldev.h:888
@ RTE_ML_IO_TYPE_INT8
Definition: rte_mldev.h:878
@ RTE_ML_IO_TYPE_INT32
Definition: rte_mldev.h:886
@ RTE_ML_IO_TYPE_UNKNOWN
Definition: rte_mldev.h:876
@ RTE_ML_IO_TYPE_FP16
Definition: rte_mldev.h:896
__rte_experimental int rte_ml_io_int16_to_float32(const void *i16, void *fp32, uint64_t nb_elements, float scale, int16_t zero_point)
__rte_experimental int rte_ml_io_float32_to_uint16(const void *fp32, void *ui16, uint64_t nb_elements, float scale, uint16_t zero_point)
void(* rte_ml_dev_stop_flush_t)(int16_t dev_id, uint16_t qp_id, struct rte_ml_op *op)
Definition: rte_mldev.h:302
__rte_experimental int rte_ml_model_load(int16_t dev_id, struct rte_ml_model_params *params, uint16_t *model_id)
__rte_experimental int rte_ml_io_uint16_to_float32(const void *ui16, void *fp32, uint64_t nb_elements, float scale, uint16_t zero_point)
__rte_experimental int rte_ml_dev_xstats_names_get(int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id, struct rte_ml_dev_xstats_map *xstats_map, uint32_t size)
__rte_experimental int rte_ml_model_params_update(int16_t dev_id, uint16_t model_id, void *buffer)
__rte_experimental int rte_ml_dev_configure(int16_t dev_id, const struct rte_ml_dev_config *config)
__rte_experimental int rte_ml_io_float32_to_int32(const void *fp32, void *i32, uint64_t nb_elements, float scale, int32_t zero_point)
char name[RTE_MEMPOOL_NAMESIZE]
Definition: rte_mempool.h:231
uint32_t cache_size
Definition: rte_mempool.h:241
rte_iova_t iova_addr
Definition: rte_mldev.h:419
uint32_t reserved
Definition: rte_mldev.h:425
struct rte_ml_buff_seg * next
Definition: rte_mldev.h:427
uint32_t length
Definition: rte_mldev.h:423
uint16_t nb_queue_pairs
Definition: rte_mldev.h:267
uint16_t nb_models
Definition: rte_mldev.h:262
uint16_t max_segments
Definition: rte_mldev.h:234
uint16_t max_io
Definition: rte_mldev.h:232
uint16_t max_queue_pairs
Definition: rte_mldev.h:224
uint16_t max_desc
Definition: rte_mldev.h:228
uint16_t max_models
Definition: rte_mldev.h:220
uint16_t align_size
Definition: rte_mldev.h:238
const char * driver_name
Definition: rte_mldev.h:218
uint32_t nb_desc
Definition: rte_mldev.h:306
rte_ml_dev_stop_flush_t cb
Definition: rte_mldev.h:311
uint64_t enqueue_err_count
Definition: rte_mldev.h:597
uint64_t enqueued_count
Definition: rte_mldev.h:593
uint64_t dequeue_err_count
Definition: rte_mldev.h:599
uint64_t dequeued_count
Definition: rte_mldev.h:595
char name[RTE_ML_STR_MAX]
Definition: rte_mldev.h:647
char name[RTE_ML_STR_MAX]
Definition: rte_mldev.h:939
uint32_t nb_dims
Definition: rte_mldev.h:941
uint64_t nb_elements
Definition: rte_mldev.h:949
enum rte_ml_io_type type
Definition: rte_mldev.h:945
int64_t zero_point
Definition: rte_mldev.h:955
uint32_t * shape
Definition: rte_mldev.h:943
uint64_t size
Definition: rte_mldev.h:951
char name[RTE_ML_STR_MAX]
Definition: rte_mldev.h:961
uint16_t min_batches
Definition: rte_mldev.h:971
uint16_t model_id
Definition: rte_mldev.h:965
uint32_t nb_inputs
Definition: rte_mldev.h:979
char version[RTE_ML_STR_MAX]
Definition: rte_mldev.h:963
uint16_t max_batches
Definition: rte_mldev.h:975
uint64_t wb_size
Definition: rte_mldev.h:987
enum rte_ml_io_layout io_layout
Definition: rte_mldev.h:969
const struct rte_ml_io_info * output_info
Definition: rte_mldev.h:985
uint16_t device_id
Definition: rte_mldev.h:967
uint32_t nb_outputs
Definition: rte_mldev.h:983
const struct rte_ml_io_info * input_info
Definition: rte_mldev.h:981
uint64_t errcode
Definition: rte_mldev.h:565
char message[RTE_ML_STR_MAX]
Definition: rte_mldev.h:564
uint16_t nb_batches
Definition: rte_mldev.h:440
struct rte_mempool * mempool
Definition: rte_mldev.h:446
uint64_t user_u64
Definition: rte_mldev.h:471
struct rte_ml_buff_seg ** input
Definition: rte_mldev.h:448
uint16_t model_id
Definition: rte_mldev.h:438
void * user_ptr
Definition: rte_mldev.h:473
uint64_t impl_opaque
Definition: rte_mldev.h:478
uint32_t reserved
Definition: rte_mldev.h:444
enum rte_ml_op_status status
Definition: rte_mldev.h:476
struct rte_ml_buff_seg ** output
Definition: rte_mldev.h:459