API Reference Manual  1.48.0
api/spec/ml_types.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2021-2025 Nokia
3  * Copyright (c) 2021 Marvell
4  */
5 
12 #ifndef ODP_API_SPEC_ML_TYPES_H_
13 #define ODP_API_SPEC_ML_TYPES_H_
14 #include <odp/visibility_begin.h>
15 
16 #include <odp/api/event_types.h>
17 #include <odp/api/queue_types.h>
18 #include <odp/api/std_types.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
76 #define ODP_ML_ENGINE_ANY 0
77 
79 #define ODP_ML_MAX_DIMS 8
80 
82 #define ODP_ML_DIM_DYNAMIC 0
83 
85 #define ODP_ML_COMPL_MODE_SYNC 0x1u
86 
93 #define ODP_ML_COMPL_MODE_POLL 0x2u
94 
101 #define ODP_ML_COMPL_MODE_EVENT 0x4u
102 
104 typedef uint32_t odp_ml_compl_mode_t;
105 
118  uint32_t max_pools;
119 
121  uint32_t max_num;
122 
124  uint32_t max_uarea_size;
125 
132 
134  uint32_t max_cache_size;
135 
137  uint32_t min_cache_size;
138 
140 
153  uint32_t num;
154 
161  uint32_t uarea_size;
162 
164  struct {
168  void (*init_fn)(void *uarea, uint32_t size, void *args, uint32_t index);
169 
172  void *args;
173 
175 
183  uint32_t cache_size;
184 
186 
188 typedef struct odp_ml_capability_t {
193  uint32_t max_models;
194 
197 
199  uint64_t max_model_size;
200 
202  uint32_t max_compl_id;
203 
205  uint32_t max_inputs;
206 
208  uint32_t max_outputs;
209 
216 
223 
230  uint32_t min_input_align;
231 
239 
250 
261 
263  struct {
271 
282 
293 
294  } load;
295 
297  struct {
305 
316 
327 
328  } run;
329 
332 
334 
336 typedef struct odp_ml_config_t {
347  uint32_t engine_id;
348 
355 
363 
370  uint64_t max_model_size;
371 
381 
391 
393 
395 typedef enum {
398 
401 
404 
407 
410 
413 
416 
419 
422 
425 
428 
431 
434 
437 
440 
442 
444 typedef enum {
447 
453 
461 
463 
465 typedef struct odp_ml_shape_info_t {
468 
475  uint32_t num_dim;
476 
501  uint32_t dim[ODP_ML_MAX_DIMS];
502 
510 
518 
529 
531 
538 typedef struct odp_ml_quant_param_t {
547 
549  float scale_fp32;
550 
552  int32_t zerop_i32;
553 
555 
557 typedef struct odp_ml_quant_info_t {
560 
562 
564 typedef struct odp_ml_input_info_t {
567 
570 
572  uint32_t data_type_size;
573 
576 
579 
581 
583 typedef struct odp_ml_output_info_t {
586 
589 
591  uint32_t data_type_size;
592 
595 
598 
600 
602 typedef struct odp_ml_model_info_t {
605 
612  uint64_t model_version;
613 
622 
624  uint32_t engine_id;
625 
627  uint32_t index;
628 
630  uint32_t num_inputs;
631 
633  uint32_t num_outputs;
634 
636  union {
638  struct {
648  uint32_t input_quant_info : 1;
649 
659  uint32_t output_quant_info : 1;
660 
661  };
662 
668  uint32_t all;
669 
670  } aux;
671 
673 
677 typedef struct odp_ml_data_format_t {
680 
682  uint32_t data_type_size;
683 
686 
688 
694 typedef struct odp_ml_model_param_t {
704  uint32_t engine_id;
705 
711  void *model;
712 
714  uint64_t size;
715 
723  uint32_t max_compl_id;
724 
732 
741  struct {
749  uint32_t num_inputs;
750 
758  uint32_t num_outputs;
759 
768 
777 
779 
789 
791 
793 typedef struct odp_ml_run_result_t {
799  uint64_t error_code;
800 
802  void *user_ptr;
803 
805 
807 typedef struct odp_ml_load_result_t {
813  uint64_t error_code;
814 
816  void *user_ptr;
817 
819 
825 typedef struct odp_ml_compl_param_t {
835 
845 
852 
866  uint32_t compl_id;
867 
876  void *user_ptr;
877 
879 
881 typedef struct odp_ml_data_seg_t {
883  void *addr;
884 
886  uint64_t size;
887 
889 
891 typedef struct odp_ml_data_t {
897  uint32_t num_input_seg;
898 
904  uint32_t num_output_seg;
905 
918 
932 
934 
940 typedef struct odp_ml_run_param_t {
947  uint32_t batch_size;
948 
957 
959 
963 typedef struct odp_ml_extra_stat_info_t {
966 
968 
973 #ifdef __cplusplus
974 }
975 #endif
976 
977 #include <odp/visibility_end.h>
978 #endif
ODP event API type definitions.
ODP queue.
Standard C language types and definitions for ODP.
#define ODP_ML_MAX_DIMS
Maximum number of dimensions in input / output data shape.
odp_ml_shape_type_t
Model input / output data shape type.
struct odp_ml_data_format_t odp_ml_data_format_t
Model input / output data format.
struct odp_ml_output_info_t odp_ml_output_info_t
Model output information.
uint32_t odp_ml_compl_mode_t
ML completion mode.
struct odp_ml_quant_info_t odp_ml_quant_info_t
Quantization information.
struct odp_ml_quant_param_t odp_ml_quant_param_t
Quantization parameters.
struct odp_ml_run_result_t odp_ml_run_result_t
Results of model run operation.
#define ODP_ML_MODEL_IO_NAME_LEN
Maximum length of model input/output name, including the null character.
odp_ml_data_type_t
Model input / output data type enumeration.
struct odp_ml_compl_pool_capability_t odp_ml_compl_pool_capability_t
ML completion event pool capabilities.
struct odp_ml_input_info_t odp_ml_input_info_t
Model input information.
struct odp_ml_compl_param_t odp_ml_compl_param_t
ML completion parameters.
#define ODP_ML_MODEL_NAME_LEN
Maximum length of model name, including the null character.
struct odp_ml_capability_t odp_ml_capability_t
Machine learning capabilities.
struct odp_ml_load_result_t odp_ml_load_result_t
Result of model load / unload operation.
struct odp_ml_config_t odp_ml_config_t
Machine learning configuration parameters.
struct odp_ml_model_param_t odp_ml_model_param_t
Machine learning model parameters.
struct odp_ml_data_t odp_ml_data_t
Model input / output data for a model inference run.
struct odp_ml_data_seg_t odp_ml_data_seg_t
Model input / output data segment.
#define ODP_ML_SHAPE_NAME_LEN
Maximum length of data dimension name, including the null character.
struct odp_ml_shape_info_t odp_ml_shape_info_t
Model input / output data shape information.
struct odp_ml_compl_pool_param_t odp_ml_compl_pool_param_t
ML completion event pool parameters.
struct odp_ml_extra_stat_info_t odp_ml_extra_stat_info_t
ML extra statistics counter information.
struct odp_ml_model_info_t odp_ml_model_info_t
Model information.
#define ODP_ML_EXTRA_STAT_NAME_LEN
Maximum length of extra statistics counter name, including the null character.
struct odp_ml_run_param_t odp_ml_run_param_t
Parameters for model run.
@ ODP_ML_SHAPE_STATIC
Static shape of data.
@ ODP_ML_SHAPE_NONE
Type of shape is not defined.
@ ODP_ML_SHAPE_BATCH
Dynamic batch size.
@ ODP_ML_DATA_TYPE_UINT32
32-bit unsigned integer
@ ODP_ML_DATA_TYPE_FP32
32-bit floating point number
@ ODP_ML_DATA_TYPE_FP16
16-bit floating point number
@ ODP_ML_DATA_TYPE_UINT8
8-bit unsigned integer
@ ODP_ML_DATA_TYPE_UINT64
64-bit unsigned integer
@ ODP_ML_DATA_TYPE_UINT24
24-bit unsigned integer
@ ODP_ML_DATA_TYPE_UINT16
16-bit unsigned integer
@ ODP_ML_DATA_TYPE_INT32
32-bit integer
@ ODP_ML_DATA_TYPE_BFP16
16-bit brain floating point (bfloat16) number
@ ODP_ML_DATA_TYPE_FP64
64-bit floating point number
@ ODP_ML_DATA_TYPE_INT64
64-bit integer
@ ODP_ML_DATA_TYPE_INT24
24-bit integer
@ ODP_ML_DATA_TYPE_NONE
Data type is not defined.
@ ODP_ML_DATA_TYPE_INT16
16-bit integer
@ ODP_ML_DATA_TYPE_INT8
8-bit integer
bool odp_bool_t
Boolean type.
Machine learning capabilities.
odp_ml_compl_mode_t compl_mode_mask
Supported completion modes for model load / unload operations.
struct odp_ml_capability_t::@89 run
Model run capabilities.
odp_bool_t compl_queue_sched
Support of model load / unload completion into scheduled queues.
uint32_t min_output_align
Minimum output data alignment in bytes.
odp_bool_t packed_output_data
Output data packing.
uint64_t max_model_size
Maximum model size in bytes.
uint32_t min_input_align
Minimum input data alignment in bytes.
odp_bool_t compl_queue_plain
Support of model load / unload completion into plain queues.
uint32_t max_segs_per_input
Maximum number of data segments per model input.
odp_bool_t packed_input_data
Input data packing.
struct odp_ml_capability_t::@88 load
Model load / unload capabilities.
uint32_t max_compl_id
Maximum completion identifier value.
uint32_t max_segs_per_output
Maximum number of data segments per model output.
odp_ml_compl_pool_capability_t pool
ML completion event pool capabilities.
uint32_t max_models
Maximum number of models.
uint32_t max_models_loaded
Maximum number of models that can be loaded simultaneously.
uint32_t max_inputs
Maximum number of model inputs.
uint32_t max_outputs
Maximum number of model outputs.
ML completion parameters.
odp_event_t event
Completion event.
void * user_ptr
User defined context pointer.
odp_ml_compl_mode_t mode
Completion mode.
uint32_t compl_id
Completion identifier.
odp_queue_t queue
Completion queue.
ML completion event pool capabilities.
uint32_t max_pools
Maximum number of ML completion event pools.
uint32_t max_num
Maximum number of ML completion events in a pool.
uint32_t max_cache_size
Maximum size of local thread cache.
odp_bool_t uarea_persistence
User area persistence.
uint32_t max_uarea_size
Maximum user area size in bytes.
uint32_t min_cache_size
Minimum size of local thread cache.
ML completion event pool parameters.
void(* init_fn)(void *uarea, uint32_t size, void *args, uint32_t index)
See uarea_init.init_fn of odp_pool_param_t for details (odp_pool_param_t.init_fn).
struct odp_ml_compl_pool_param_t::@87 uarea_init
Parameters for user area initialization.
uint32_t uarea_size
User area size in bytes.
uint32_t cache_size
Maximum number of events cached locally per thread.
uint32_t num
Number of ML completion events in the pool.
void * args
See uarea_init.args of odp_pool_param_t for details (odp_pool_param_t.args).
Machine learning configuration parameters.
uint32_t engine_id
Engine ID to be configured.
uint64_t max_model_size
Maximum model binary size in bytes.
odp_ml_compl_mode_t load_mode_mask
Load / unload completion modes.
uint32_t max_models_loaded
Maximum number of models loaded.
uint32_t max_models_created
Maximum number of models.
odp_ml_compl_mode_t run_mode_mask
Run completion modes.
Model input / output data format.
odp_ml_data_type_t data_type
Model input / output data type.
odp_ml_shape_info_t shape
Model input / output data shape.
uint32_t data_type_size
Size of data type in bytes.
Model input / output data segment.
void * addr
Segment start address.
uint64_t size
Segment size in bytes.
Model input / output data for a model inference run.
uint32_t num_output_seg
Number of output data segments.
uint32_t num_input_seg
Number of input data segments.
odp_ml_data_seg_t * output_seg
Model output data segments.
odp_ml_data_seg_t * input_seg
Model input data segments.
ML extra statistics counter information.
char name[ODP_ML_EXTRA_STAT_NAME_LEN]
Name of the statistics counter.
Model input information.
uint32_t data_type_size
Size of model input data type in bytes.
odp_ml_quant_info_t quant_info
Model input quantization information.
odp_ml_data_type_t data_type
Model input data type.
char name[ODP_ML_MODEL_IO_NAME_LEN]
Model input name.
odp_ml_shape_info_t shape
Model input data shape.
Result of model load / unload operation.
uint64_t error_code
Model load / unload error code.
void * user_ptr
User context pointer value from odp_ml_compl_param_t.
Model information.
union odp_ml_model_info_t::@90 aux
Auxiliary information regarding the model and its inputs / outputs.
uint64_t model_version
Model version number.
uint64_t interface_version
Model interface version number.
uint32_t num_outputs
Number of model outputs.
uint32_t all
All bits of the bit field structure.
uint32_t input_quant_info
Input quantization information provision.
uint32_t output_quant_info
Output quantization information provision.
uint32_t engine_id
Engine ID to which the model is assigned.
char name[ODP_ML_MODEL_NAME_LEN]
Model name.
uint32_t index
Model index assigned by the implementation.
uint32_t num_inputs
Number of model inputs.
Machine learning model parameters.
const odp_ml_model_extra_param_t * extra_param
ODP implementation specific extra parameters.
uint64_t size
Size of the model binary in bytes.
struct odp_ml_model_param_t::@93 extra_info
Extra model information.
odp_bool_t extra_stat_enable
Enable / disable extra statistics counters.
uint32_t engine_id
Engine ID.
const odp_ml_data_format_t * output_format
Model output data format array.
uint32_t num_outputs
Number of model outputs.
uint32_t max_compl_id
Maximum completion identifier value.
const odp_ml_data_format_t * input_format
Model input data format array.
void * model
Model binary.
uint32_t num_inputs
Number of model inputs.
Model output information.
odp_ml_data_type_t data_type
Model output data type.
odp_ml_shape_info_t shape
Model output data shape.
odp_ml_quant_info_t quant_info
Model output quantization information.
uint32_t data_type_size
Size of model output data type in bytes.
char name[ODP_ML_MODEL_IO_NAME_LEN]
Model output name.
Quantization information.
odp_ml_quant_param_t common
Quantization parameters common to all data values of an input / output.
Quantization parameters.
float scale_fp32
Quantization scale.
odp_ml_data_type_t type
Type of quantization scale value.
int32_t zerop_i32
Quantization zero point.
Parameters for model run.
odp_ml_run_result_t * result
Model run results.
uint32_t batch_size
Batch size.
Results of model run operation.
void * user_ptr
User context pointer value from odp_ml_compl_param_t.
uint64_t error_code
Model run error code.
Model input / output data shape information.
char dim_name[ODP_ML_MAX_DIMS][ODP_ML_SHAPE_NAME_LEN]
Dimension name.
uint32_t dim_min[ODP_ML_MAX_DIMS]
Minimum dimension sizes.
odp_ml_shape_type_t type
Shape type.
uint32_t dim_max[ODP_ML_MAX_DIMS]
Maximum dimension sizes.
uint32_t num_dim
Number of dimensions.
uint32_t dim[ODP_ML_MAX_DIMS]
Dimension sizes.