14#include <odp/helper/odph_api.h>
35 int mode, num_threads, rounds, latency, warmup;
36 char *model_name, *input_name, *reference_name;
37 float scale_q, scale_d;
41static test_opt_t opt_def = {
48typedef struct io_size {
54 uint64_t sum, min, max;
61 void *model_file_data;
62 uint64_t model_file_size;
65 uint64_t inp_file_size;
68 uint64_t ref_file_size;
77 uint64_t inp_size_q, inp_size_d, out_size_q, out_size_d;
81static test_global_t *glb;
88static void time_elapsed(
odp_time_t *t,
int thr)
94 glb->stat[thr].sum += nsec;
95 if (nsec < glb->stat[thr].min || !glb->stat[thr].min)
96 glb->stat[thr].min = nsec;
97 if (nsec > glb->stat[thr].max)
98 glb->stat[thr].max = nsec;
101static void *read_file(
const char *name, uint64_t *size)
104 FILE *file = fopen(name,
"rb");
107 ODPH_ERR(
"Failed to open file %s: %s\n", name, strerror(errno));
111 if (fseek(file, 0, SEEK_END)) {
112 ODPH_ERR(
"Failed to get file size for file %s\n", name);
116 long pos = ftell(file);
119 ODPH_ERR(
"Failed to get file size for file %s\n", name);
125 addr = malloc(*size);
128 ODPH_ERR(
"Allocating %" PRIu64
" bytes failed\n", *size);
132 if (fread(addr, *size, 1, file) != 1) {
133 ODPH_ERR(
"Reading %" PRIu64
" bytes failed\n", *size);
138 printf(
"Read %" PRIu64
" bytes from %s\n", *size, name);
149static int read_file_to_shm(
odp_shm_t *shm,
void **data, uint64_t *size,
const char *filename,
152 void *file = read_file(filename, size);
163 ODPH_ERR(
"Failed to reserve shm for %s\n", filename);
168 memcpy(*data, file, *size);
174static void usage(
const char *prog)
177 "Usage: %s [options]\n"
179 "Mandatory OPTIONS:\n"
180 " -M, --model Model file\n"
181 " -I, --input Input file\n"
184 " -c, --num_cpu Number of CPUs (worker threads). 0: all available CPUs. Default 1.\n"
185 " -r, --rounds Number of test rounds. Default %u.\n"
186 " -m, --mode Test mode. Default 0.\n"
188 " 1: Quantization-inference-dequantization\n"
189 " 2: Create-destroy\n"
191 " -l, --latency Measure each round, report min, avg, max\n"
192 " -w, --warmup Warmup rounds. Default %d.\n"
193 " -R, --reference Reference file. To verify correctness, output from the last\n"
194 " inference is compared to this file.\n"
195 " -q, --quant Quantization scale\n"
196 " -d, --dequant Dequantization scale\n"
197 " -b, --batches Number of batches\n"
200 prog, opt_def.rounds, opt_def.warmup);
203static int parse_args(
int argc,
char *argv[])
205 static const struct option longopts[] = {
206 {
"model", required_argument, NULL,
'M' },
207 {
"input", required_argument, NULL,
'I' },
208 {
"num_cpu", required_argument, NULL,
'c' },
209 {
"rounds", required_argument, NULL,
'r' },
210 {
"mode", required_argument, NULL,
'm' },
211 {
"latency", no_argument, NULL,
'l' },
212 {
"warmup", required_argument, NULL,
'w' },
213 {
"reference", required_argument, NULL,
'R' },
214 {
"quant", required_argument, NULL,
'q' },
215 {
"dequant", required_argument, NULL,
'd' },
216 {
"batches", required_argument, NULL,
'b' },
217 {
"help", no_argument, NULL,
'h' },
218 { NULL, 0, NULL, 0 } };
220 static const char *shortopts =
"+M:I:c:r:m:lw:R:q:d:b:h";
225 int c = getopt_long(argc, argv, shortopts, longopts, NULL);
232 glb->opt.model_name = optarg;
235 glb->opt.input_name = optarg;
238 glb->opt.num_threads = atoi(optarg);
241 glb->opt.rounds = atoi(optarg);
244 glb->opt.mode = atoi(optarg);
247 glb->opt.latency = 1;
250 glb->opt.warmup = atoi(optarg);
253 glb->opt.reference_name = optarg;
256 glb->opt.scale_q = atof(optarg);
259 glb->opt.scale_d = atof(optarg);
262 glb->opt.num_batch = atoi(optarg);
275 if (!glb->opt.model_name || !glb->opt.input_name) {
276 ODPH_ERR(
"Model and input files are mandatory\n");
280 if (glb->opt.mode < 0 || glb->opt.mode >= MODE_NUM) {
281 ODPH_ERR(
"Invalid mode %d\n", glb->opt.mode);
285 if (glb->opt.warmup < 0) {
286 ODPH_ERR(
"Invalid number of warmup rounds: %d\n", glb->opt.warmup);
290 printf(
"Options:\n");
291 printf(
"--------\n");
292 printf(
"model_name: %s\n", glb->opt.model_name);
293 printf(
"input_name: %s\n", glb->opt.input_name);
294 printf(
"num_cpu: %d\n", glb->opt.num_threads);
295 printf(
"rounds: %u\n", glb->opt.rounds);
296 printf(
"mode: %u\n", glb->opt.mode);
297 printf(
"latency: %d\n", glb->opt.latency);
298 printf(
"warmup: %d\n", glb->opt.warmup);
299 printf(
"reference_name: %s\n", glb->opt.reference_name);
300 printf(
"scale_q: %g\n", glb->opt.scale_q);
301 printf(
"scale_d: %g\n", glb->opt.scale_d);
302 printf(
"num_batch: %d\n", glb->opt.num_batch);
308static int check_num_batch(
void)
310 int min_batch = 1, max_batch = 1;
312 for (
int i = 0; i < glb->num_inp; i++) {
315 for (
int j = 0; j < (int)shape->
num_dim; j++) {
324 if (glb->opt.num_batch < min_batch || glb->opt.num_batch > max_batch) {
325 ODPH_ERR(
"Number of batches %d out of range [%d, %d]\n", glb->opt.num_batch,
326 min_batch, max_batch);
333static void calc_io_size(
void)
335 for (
int i = 0; i < glb->num_inp; i++) {
339 io_size *inp = &glb->inp[i];
341 printf(
"Input %d: %s, shape:", i, info->
name);
343 for (
int j = 0; j < (int)shape->
num_dim; j++) {
344 printf(
" %d", shape->
dim[j]);
346 elems *= shape->
dim[j];
350 elems *= glb->opt.num_batch;
354 glb->inp_size_q += inp->size;
355 glb->inp_size_d += elems *
sizeof(float);
357 printf(
", elems: %" PRIu64
", datatype size: %d, size: %" PRIu64
"\n", inp->elems,
358 inp->elem_size, inp->size);
361 printf(
"Input size_q: %" PRIu64
", size_d: %" PRIu64
"\n", glb->inp_size_q,
364 for (
int i = 0; i < glb->num_out; i++) {
368 io_size *out = &glb->out[i];
370 printf(
"Output %d: %s, shape:", i, info->
name);
372 for (
int j = 0; j < (int)shape->
num_dim; j++) {
373 printf(
" %d", shape->
dim[j]);
375 elems *= shape->
dim[j];
379 elems *= glb->opt.num_batch;
383 glb->out_size_q += out->size;
384 glb->out_size_d += elems *
sizeof(float);
386 printf(
", elems: %" PRIu64
", datatype size: %d, size: %" PRIu64
"\n", out->elems,
387 out->elem_size, out->size);
390 printf(
"Output size_q: %" PRIu64
", size_d: %" PRIu64
"\n", glb->out_size_q,
406static void quantize_input(uint8_t *inp_q_addr,
float *inp_d_addr)
408 for (
int i = 0; i < glb->num_inp; i++) {
409 float scale_q = glb->opt.scale_q;
410 uint64_t elems = glb->inp[i].elems;
426 ODPH_ERR(
"Unsupported type %d for input %d\n", data_type, i);
429 inp_q_addr += glb->inp[i].size;
434static void dequantize_output(
float *out_d_addr, uint8_t *out_q_addr)
436 for (
int i = 0; i < glb->num_out; i++) {
437 float scale_d = glb->opt.scale_d;
438 uint64_t elems = glb->out[i].elems;
454 ODPH_ERR(
"Unsupported type %d for output %d\n", data_type, i);
457 out_q_addr += glb->out[i].size;
462static int test_ml(
void *ptr)
469 int thread_idx = (int)(uintptr_t)ptr;
470 void *input = NULL, *output = NULL, *output_file = NULL;
471 void *output_final = NULL;
472 uint64_t out_size_final = 0;
475 inp_addr = glb->inp_file_data;
477 if (glb->opt.scale_q > 0.0) {
478 input = malloc(glb->inp_size_q);
480 ODPH_ERR(
"Allocating %" PRIu64
" bytes failed\n", glb->inp_size_q);
488 for (
int i = 0; i < glb->num_inp; i++) {
489 inp_seg[i].
addr = inp_addr;
490 inp_seg[i].
size = glb->inp[i].size;
491 inp_addr += glb->inp[i].size;
494 output = malloc(glb->out_size_q);
497 ODPH_ERR(
"Allocating %" PRIu64
" bytes failed\n", glb->out_size_q);
503 output_final = output;
504 out_size_final = glb->out_size_q;
506 if (glb->opt.scale_d > 0.0) {
507 output_file = malloc(glb->out_size_d);
509 ODPH_ERR(
"Allocating %" PRIu64
" bytes failed\n", glb->out_size_d);
514 output_final = output_file;
515 out_size_final = glb->out_size_d;
518 for (
int i = 0; i < glb->num_out; i++) {
519 out_seg[i].
addr = out_addr;
520 out_seg[i].
size = glb->out[i].size;
521 out_addr += glb->out[i].size;
526 .num_input_seg = glb->num_inp,
527 .output_seg = out_seg,
528 .num_output_seg = glb->num_out,
535 if (glb->opt.mode != MODE_INFERENCE_QUANT && glb->opt.scale_q > 0.0)
536 quantize_input(input, glb->inp_file_data);
540 for (
int i = 0; i < glb->opt.rounds + glb->opt.warmup; i++) {
541 if (i == glb->opt.warmup)
544 if (glb->opt.mode == MODE_INFERENCE_QUANT && glb->opt.scale_q > 0.0)
545 quantize_input(input, glb->inp_file_data);
549 while (!(r =
odp_ml_run(glb->mdl, &data, &run_param)))
552 ODPH_ERR(
"odp_ml_run() failed\n");
557 if (glb->opt.mode == MODE_INFERENCE_QUANT && glb->opt.scale_d > 0.0)
558 dequantize_output(output_file, output);
560 if (glb->opt.latency && i >= glb->opt.warmup)
561 time_elapsed(&time, thread_idx);
564 if (!glb->opt.latency)
565 time_elapsed(&time, thread_idx);
567 if (glb->opt.mode != MODE_INFERENCE_QUANT && glb->opt.scale_d > 0.0)
568 dequantize_output(output_file, output);
570 if (glb->ref_file_data) {
571 if (out_size_final != glb->ref_file_size) {
572 ODPH_ERR(
"Output size mismatch: %" PRIu64
573 " differs from reference file size %" PRIu64
"\n",
574 out_size_final, glb->ref_file_size);
579 if (memcmp(glb->ref_file_data, output_final, out_size_final)) {
580 ODPH_ERR(
"Output differs from reference\n");
594static int test_ml_create(
void *ptr)
597 int thread_idx = (int)(uintptr_t)ptr;
603 model_param.
model = glb->model_file_data;
604 model_param.
size = glb->model_file_size;
608 for (
int i = 0; i < glb->opt.rounds + glb->opt.warmup; i++) {
609 if (i == glb->opt.warmup)
614 ODPH_ERR(
"odp_ml_model_create() failed\n");
620 ODPH_ERR(
"odp_ml_model_destroy() failed\n");
625 if (glb->opt.latency && i >= glb->opt.warmup)
626 time_elapsed(&time, thread_idx);
629 if (!glb->opt.latency)
630 time_elapsed(&time, thread_idx);
636static int test_ml_load(
void *ptr)
639 int thread_idx = (int)(uintptr_t)ptr;
645 model_param.
model = glb->model_file_data;
646 model_param.
size = glb->model_file_size;
650 ODPH_ERR(
"odp_ml_model_create() failed\n");
657 for (
int i = 0; i < glb->opt.rounds + glb->opt.warmup; i++) {
658 if (i == glb->opt.warmup)
662 ODPH_ERR(
"odp_ml_model_load() failed\n");
668 ODPH_ERR(
"odp_ml_model_unload() failed\n");
673 if (glb->opt.latency && i >= glb->opt.warmup)
674 time_elapsed(&time, thread_idx);
677 if (!glb->opt.latency)
678 time_elapsed(&time, thread_idx);
681 ODPH_ERR(
"odp_ml_model_destroy() failed\n");
690static void print_results_avg(
void)
692 int num_threads = glb->opt.num_threads;
693 int rounds = glb->opt.rounds;
695 printf(
"thread %15s %15s\n",
"avg (nsec)",
"rounds / sec");
696 printf(
"--------------------------------------\n");
697 if (num_threads > 1) {
700 for (
int i = 0; i < num_threads; i++)
701 avg += glb->stat[i].sum;
703 avg /= rounds * num_threads;
706 for (
int i = 0; i < num_threads; i++) {
707 glb->stat[i].sum /= rounds;
708 printf(
"%-6d %15" PRIu64
" %15.1f\n", i, glb->stat[i].sum,
713static void print_stat(stat_t *stat)
715 printf(
"%15" PRIu64
" %15" PRIu64
" %15" PRIu64, stat->min, stat->sum, stat->max);
718static void print_results_min_avg_max(
void)
720 int num_threads = glb->opt.num_threads;
721 int rounds = glb->opt.rounds;
723 printf(
"thread %15s %15s %15s\n",
"min (nsec)",
"avg (nsec)",
"max (nsec)");
724 printf(
"------------------------------------------------------\n");
725 if (num_threads > 1) {
728 for (
int i = 0; i < num_threads; i++) {
729 s.sum += glb->stat[i].sum;
730 if (glb->stat[i].min && (glb->stat[i].min < s.min || !s.min))
731 s.min = glb->stat[i].min;
732 if (glb->stat[i].max > s.max)
733 s.max = glb->stat[i].max;
736 s.sum /= rounds * num_threads;
737 printf(
"%-6s ",
"all");
741 for (
int i = 0; i < num_threads; i++) {
742 glb->stat[i].sum /= rounds;
744 print_stat(&glb->stat[i]);
749static void print_results(
void)
753 if (glb->opt.latency)
754 print_results_min_avg_max();
761int main(
int argc,
char *argv[])
764 odph_helper_options_t helper_options;
770 argc = odph_parse_options(argc, argv);
772 if (odph_options(&helper_options)) {
773 ODPH_ERR(
"Failed to read ODP helper options.\n");
787 init.
mem_model = helper_options.mem_model;
791 ODPH_ERR(
"Global init failed.\n");
797 ODPH_ERR(
"Local init failed.\n");
803 shm_glb =
odp_shm_reserve(
"test_globals",
sizeof(test_global_t), ODP_CACHE_LINE_SIZE, 0);
809 ODPH_ERR(
"Failed to reserve shm\n");
814 memset(glb, 0,
sizeof(test_global_t));
816 ret = parse_args(argc, argv);
823 if (read_file_to_shm(&glb->model_file_shm, &glb->model_file_data, &glb->model_file_size,
824 glb->opt.model_name,
"ml_perf_model")) {
829 if (read_file_to_shm(&glb->inp_file_shm, &glb->inp_file_data, &glb->inp_file_size,
830 glb->opt.input_name,
"ml_perf_input")) {
835 if (glb->opt.reference_name) {
836 if (read_file_to_shm(&glb->ref_file_shm, &glb->ref_file_data, &glb->ref_file_size,
837 glb->opt.reference_name,
"ml_perf_reference")) {
844 ODPH_ERR(
"odp_ml_capability() failed\n");
849 if (glb->capa.max_models < 1) {
850 ODPH_ERR(
"ML not supported (maximum number of models is zero)\n");
855 if (glb->capa.max_model_size < glb->model_file_size) {
856 ODPH_ERR(
"Model size %" PRIu64
" exceeds maximum %" PRIu64
"\n",
857 glb->model_file_size, glb->capa.max_model_size);
862 if (glb->capa.min_input_align > 1) {
863 ODPH_ERR(
"Minimum input alignment %u not supported\n", glb->capa.min_input_align);
868 if (glb->capa.min_output_align > 1) {
869 ODPH_ERR(
"Minimum output alignment %u not supported\n", glb->capa.min_output_align);
874 if ((glb->opt.mode == MODE_CREATE || glb->opt.mode == MODE_LOAD) &&
875 (
int)glb->capa.max_models < glb->opt.num_threads) {
876 ODPH_ERR(
"Maximum number of models %u less than number of threads %d\n",
877 glb->capa.max_models, glb->opt.num_threads);
882 if (glb->opt.mode == MODE_LOAD && (
int)glb->capa.max_models_loaded < glb->opt.num_threads) {
883 ODPH_ERR(
"Maximum number of models loaded %u less than number of threads %d\n",
884 glb->capa.max_models_loaded, glb->opt.num_threads);
898 ODPH_ERR(
"odp_ml_config() failed\n");
904 model_param.
model = glb->model_file_data;
905 model_param.
size = glb->model_file_size;
909 ODPH_ERR(
"odp_ml_model_create() failed\n");
917 ODPH_ERR(
"odp_ml_model_load() failed\n");
923 ODPH_ERR(
"odp_ml_model_info() failed\n");
930 if (glb->num_inp < 0 || glb->num_inp > MAX_IO) {
931 ODPH_ERR(
"odp_ml_model_input_info() failed, or too many inputs\n");
938 if (glb->num_out < 0 || glb->num_out > MAX_IO) {
939 ODPH_ERR(
"odp_ml_model_output_info() failed, or too many outputs\n");
944 if (check_num_batch()) {
951 if (glb->opt.scale_q > 0.0) {
952 for (
int i = 0; i < glb->num_inp; i++) {
953 if (!data_type_supported(glb->inp_info[i].data_type)) {
954 ODPH_ERR(
"Unsupported data type %d for input %d quantization\n",
955 glb->inp_info[i].data_type, i);
960 for (
int i = 0; i < glb->num_out; i++) {
961 if (!data_type_supported(glb->out_info[i].data_type)) {
962 ODPH_ERR(
"Unsupported data type %d for output %d dequantization\n",
963 glb->out_info[i].data_type, i);
970 if ((glb->opt.scale_q > 0.0 && glb->inp_file_size != glb->inp_size_d) ||
971 (!(glb->opt.scale_q > 0.0) && glb->inp_file_size != glb->inp_size_q)) {
972 ODPH_ERR(
"Input file size mismatch\n");
977 if (glb->opt.mode != MODE_INFERENCE && glb->opt.mode != MODE_INFERENCE_QUANT) {
983 ODPH_ERR(
"odp_ml_model_unload() failed\n");
989 ODPH_ERR(
"odp_ml_model_destroy() failed\n");
995 int num_threads = glb->opt.num_threads;
1000 odph_thread_common_param_t thr_common;
1006 ODPH_ERR(
"Failed to get default CPU mask.\n");
1011 odph_thread_common_param_init(&thr_common);
1012 thr_common.instance = inst;
1013 thr_common.cpumask = &cpumask;
1015 for (
int i = 0; i < num_threads; i++) {
1016 odph_thread_param_init(&thr_param[i]);
1018 thr_param[i].arg = (
void *)(uintptr_t)i;
1019 switch (glb->opt.mode) {
1020 case MODE_INFERENCE:
1021 case MODE_INFERENCE_QUANT:
1022 thr_param[i].start = test_ml;
1025 thr_param[i].start = test_ml_create;
1028 thr_param[i].start = test_ml_load;
1033 memset(&thr_worker, 0,
sizeof(thr_worker));
1035 if (odph_thread_create(thr_worker, &thr_common, thr_param, num_threads) != num_threads) {
1036 ODPH_ERR(
"Failed to create worker threads.\n");
1041 if (odph_thread_join_result(thr_worker, res, num_threads) != num_threads) {
1042 ODPH_ERR(
"Failed to join worker threads.\n");
1047 for (
int i = 0; i < num_threads; i++) {
1048 if (res[i].is_sig || res[i].ret != 0) {
1049 ODPH_ERR(
"Worker thread failure%s: %d\n",
1050 res[i].is_sig ?
" (signaled)" :
"", res[i].ret);
1062 ODPH_ERR(
"odp_ml_model_unload() failed\n");
1067 ODPH_ERR(
"odp_ml_model_destroy() failed\n");
1073 ODPH_ERR(
"odp_shm_free() failed\n");
1078 ODPH_ERR(
"odp_shm_free() failed\n");
1083 ODPH_ERR(
"odp_shm_free() failed\n");
1088 ODPH_ERR(
"odp_shm_free() failed\n");
1093 ODPH_ERR(
"Local term failed\n");
1098 ODPH_ERR(
"Global term failed\n");
void odp_barrier_init(odp_barrier_t *barr, int count)
Initialize barrier with thread count.
void odp_barrier_wait(odp_barrier_t *barr)
Synchronize thread execution on barrier.
#define ODP_ALIGNED_CACHE
Defines type/struct/variable to be cache line size aligned.
int odp_cpumask_default_worker(odp_cpumask_t *mask, int num)
Default CPU mask for worker threads.
void odp_init_param_init(odp_init_t *param)
Initialize the odp_init_t to default values for all fields.
int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type)
Thread local ODP initialization.
int odp_init_global(odp_instance_t *instance, const odp_init_t *params, const odp_platform_init_t *platform_params)
Global ODP initialization.
int odp_term_local(void)
Thread local ODP termination.
int odp_term_global(odp_instance_t instance)
Global ODP termination.
uint64_t odp_instance_t
ODP instance ID.
void odp_ml_run_param_init(odp_ml_run_param_t *param)
Initialize model run parameters.
void odp_ml_model_param_init(odp_ml_model_param_t *param)
Initialize ML model parameters.
void odp_ml_config_init(odp_ml_config_t *config)
Initialize ML configuration parameters.
void odp_ml_fp32_to_fp16(uint16_t *dst_fp16, const float *src_fp32, uint32_t num)
Quantize 32-bit float to 16-bit float.
void odp_ml_fp32_to_int8(int8_t *dst_i8, const float *src_fp32, uint32_t num, float scale, int8_t zerop)
Quantize 32-bit float to int8_t.
#define ODP_ML_DIM_DYNAMIC
Dimension size is dynamic.
void odp_ml_fp32_from_fp16(float *dst_fp32, const uint16_t *src_fp16, uint32_t num)
De-quantize 32-bit float from 16-bit float.
void odp_ml_fp32_from_uint8(float *dst_fp32, const uint8_t *src_u8, uint32_t num, float scale, uint8_t zerop)
De-quantize 32-bit float from uint8_t.
#define ODP_ML_COMPL_MODE_SYNC
Synchronous operation.
int odp_ml_config(const odp_ml_config_t *config)
Configure ML offload.
#define ODP_ML_MODEL_INVALID
Invalid ML model.
int odp_ml_run(odp_ml_model_t model, const odp_ml_data_t *data, const odp_ml_run_param_t *param)
Run the model in synchronous mode.
odp_ml_data_type_t
Model input / output data type enumeration.
uint32_t odp_ml_model_output_info(odp_ml_model_t model, odp_ml_output_info_t info[], uint32_t num)
Retrieve model output information.
odp_ml_model_t odp_ml_model_create(const char *name, const odp_ml_model_param_t *param)
Create an ML model.
void odp_ml_fp32_to_uint8(uint8_t *dst_u8, const float *src_fp32, uint32_t num, float scale, uint8_t zerop)
Quantize 32-bit float to uint8_t.
int odp_ml_model_load(odp_ml_model_t model, odp_ml_load_result_t *result)
Load ML model.
uint32_t odp_ml_model_input_info(odp_ml_model_t model, odp_ml_input_info_t info[], uint32_t num)
Retrieve model input information.
int odp_ml_model_unload(odp_ml_model_t model, odp_ml_load_result_t *result)
Unload ML model.
void odp_ml_model_print(odp_ml_model_t model)
Print debug information about the model.
int odp_ml_capability(odp_ml_capability_t *capa)
Query ML capabilities.
int odp_ml_model_info(odp_ml_model_t model, odp_ml_model_info_t *info)
Retrieve model information.
int odp_ml_model_destroy(odp_ml_model_t model)
Destroy an ML model.
void odp_ml_fp32_from_int8(float *dst_fp32, const int8_t *src_i8, uint32_t num, float scale, int8_t zerop)
De-quantize 32-bit float from int8_t.
@ ODP_ML_SHAPE_BATCH
Dynamic batch size.
@ ODP_ML_DATA_TYPE_FP16
16-bit floating point number
@ ODP_ML_DATA_TYPE_UINT8
8-bit unsigned integer
@ ODP_ML_DATA_TYPE_INT8
8-bit integer
int odp_shm_free(odp_shm_t shm)
Free a contiguous block of shared memory.
void * odp_shm_addr(odp_shm_t shm)
Shared memory block address.
#define ODP_SHM_INVALID
Invalid shared memory block.
odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, uint32_t flags)
Reserve a contiguous block of shared memory.
void odp_sys_info_print(void)
Print system info.
#define ODP_THREAD_COUNT_MAX
Maximum number of threads supported in build time.
@ ODP_THREAD_WORKER
Worker thread.
@ ODP_THREAD_CONTROL
Control thread.
#define ODP_TIME_SEC_IN_NS
A second in nanoseconds.
#define ODP_TIME_NULL
Zero time stamp.
odp_time_t odp_time_local_strict(void)
Current local time (strict)
uint64_t odp_time_diff_ns(odp_time_t t2, odp_time_t t1)
Time difference in nanoseconds.
Global initialization parameters.
odp_mem_model_t mem_model
Application memory model.
odp_feature_t not_used
Unused features.
Machine learning capabilities.
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.
odp_ml_compl_mode_t run_mode_mask
Run completion modes.
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.
odp_ml_data_seg_t * input_seg
Model input data segments.
Machine learning model parameters.
uint64_t size
Size of the model binary in bytes.
void * model
Model binary.
Model output information.
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.
uint32_t batch_size
Batch size.
Model input / output data shape information.
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.
uint32_t tm
Traffic Manager APIs, e.g., odp_tm_xxx()
uint32_t crypto
Crypto APIs, e.g., odp_crypto_xxx()
uint32_t ipsec
IPsec APIs, e.g., odp_ipsec_xxx()
uint32_t dma
DMA APIs, e.g., odp_dma_xxx()
uint32_t timer
Timer APIs, e.g., odp_timer_xxx(), odp_timeout_xxx()
uint32_t cls
Classifier APIs, e.g., odp_cls_xxx(), odp_cos_xxx()
struct odp_feature_t::@174 feat
Individual feature bits.
uint32_t schedule
Scheduler APIs, e.g., odp_schedule_xxx()
uint32_t compress
Compression APIs, e.g., odp_comp_xxx()