API Reference Manual  1.45.1
api/spec/ml_types.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2021-2023 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 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #include <odp/api/event_types.h>
21 #include <odp/api/queue_types.h>
22 #include <odp/api/std_types.h>
23 
74 #define ODP_ML_MAX_DIMS 8
75 
77 #define ODP_ML_DIM_DYNAMIC 0
78 
80 #define ODP_ML_COMPL_MODE_SYNC 0x1u
81 
88 #define ODP_ML_COMPL_MODE_POLL 0x2u
89 
96 #define ODP_ML_COMPL_MODE_EVENT 0x4u
97 
99 typedef uint32_t odp_ml_compl_mode_t;
100 
113  uint32_t max_pools;
114 
116  uint32_t max_num;
117 
119  uint32_t max_uarea_size;
120 
127 
129  uint32_t max_cache_size;
130 
132  uint32_t min_cache_size;
133 
135 
148  uint32_t num;
149 
156  uint32_t uarea_size;
157 
159  struct {
163  void (*init_fn)(void *uarea, uint32_t size, void *args, uint32_t index);
164 
167  void *args;
168 
170 
178  uint32_t cache_size;
179 
181 
183 typedef struct odp_ml_capability_t {
188  uint32_t max_models;
189 
192 
194  uint64_t max_model_size;
195 
197  uint32_t max_compl_id;
198 
200  uint32_t max_inputs;
201 
203  uint32_t max_outputs;
204 
211 
218 
225  uint32_t min_input_align;
226 
234 
245 
256 
258  struct {
266 
277 
288 
289  } load;
290 
292  struct {
300 
311 
322 
323  } run;
324 
327 
329 
331 typedef struct odp_ml_config_t {
338 
346 
353  uint64_t max_model_size;
354 
364 
374 
376 
378 typedef enum {
381 
384 
387 
390 
393 
396 
399 
402 
405 
408 
411 
414 
417 
420 
423 
425 
427 typedef enum {
430 
436 
444 
446 
448 typedef struct odp_ml_shape_info_t {
451 
458  uint32_t num_dim;
459 
484  uint32_t dim[ODP_ML_MAX_DIMS];
485 
493 
501 
512 
514 
516 typedef struct odp_ml_input_info_t {
519 
522 
524  uint32_t data_type_size;
525 
528 
530 
532 typedef struct odp_ml_output_info_t {
535 
538 
540  uint32_t data_type_size;
541 
544 
546 
548 typedef struct odp_ml_model_info_t {
551 
558  uint64_t model_version;
559 
568 
570  uint32_t index;
571 
573  uint32_t num_inputs;
574 
576  uint32_t num_outputs;
577 
579 
583 typedef struct odp_ml_data_format_t {
586 
588  uint32_t data_type_size;
589 
592 
594 
600 typedef struct odp_ml_model_param_t {
606  void *model;
607 
609  uint64_t size;
610 
618  uint32_t max_compl_id;
619 
627 
636  struct {
644  uint32_t num_inputs;
645 
653  uint32_t num_outputs;
654 
663 
672 
674 
684 
686 
688 typedef struct odp_ml_run_result_t {
694  uint64_t error_code;
695 
697  void *user_ptr;
698 
700 
702 typedef struct odp_ml_load_result_t {
708  uint64_t error_code;
709 
711  void *user_ptr;
712 
714 
720 typedef struct odp_ml_compl_param_t {
730 
740 
747 
761  uint32_t compl_id;
762 
771  void *user_ptr;
772 
774 
776 typedef struct odp_ml_data_seg_t {
778  void *addr;
779 
781  uint64_t size;
782 
784 
786 typedef struct odp_ml_data_t {
792  uint32_t num_input_seg;
793 
799  uint32_t num_output_seg;
800 
813 
827 
829 
835 typedef struct odp_ml_run_param_t {
842  uint32_t batch_size;
843 
852 
854 
858 typedef struct odp_ml_extra_stat_info_t {
861 
863 
868 #ifdef __cplusplus
869 }
870 #endif
871 
872 #include <odp/visibility_end.h>
873 #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_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.
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::@84 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.
struct odp_ml_capability_t::@85 run
Model run capabilities.
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).
uint32_t uarea_size
User area size in bytes.
struct odp_ml_compl_pool_param_t::@83 uarea_init
Parameters for user area initialization.
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.
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_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.
uint64_t model_version
Model version number.
uint64_t interface_version
Model interface version number.
uint32_t num_outputs
Number of model outputs.
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::@86 extra_info
Extra model information.
odp_bool_t extra_stat_enable
Enable / disable extra statistics counters.
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.
uint32_t data_type_size
Size of model output data type in bytes.
char name[ODP_ML_MODEL_IO_NAME_LEN]
Model output name.
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.