Skip to content

Commit

Permalink
app/mldev: enable support for inference validation
Browse files Browse the repository at this point in the history
Enabled support to validate inference output with reference
output provided by the user. Validation would be successful
only when the inference outputs are within the 'tolerance'
specified through command line option "--tolerance".

Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
Acked-by: Anup Prabhu <aprabhu@marvell.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
syalavarthi authored and ovsrobot committed Mar 16, 2023
1 parent 0347701 commit 0de7cfa
Show file tree
Hide file tree
Showing 7 changed files with 281 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/test-mldev/meson.build
Expand Up @@ -21,4 +21,4 @@ sources = files(
'test_inference_interleave.c',
)

deps += ['mldev']
deps += ['mldev', 'hash']
24 changes: 22 additions & 2 deletions app/test-mldev/ml_options.c
Expand Up @@ -4,6 +4,7 @@

#include <errno.h>
#include <getopt.h>
#include <math.h>

#include <rte_memory.h>
#include <rte_mldev.h>
Expand All @@ -28,6 +29,7 @@ ml_options_default(struct ml_options *opt)
opt->queue_pairs = 1;
opt->queue_size = 1;
opt->batches = 0;
opt->tolerance = 0.0;
opt->debug = false;
}

Expand Down Expand Up @@ -133,6 +135,13 @@ ml_parse_filelist(struct ml_options *opt, const char *arg)
}
strlcpy(opt->filelist[opt->nb_filelist].output, token, PATH_MAX);

/* reference - optional */
token = strtok(NULL, delim);
if (token != NULL)
strlcpy(opt->filelist[opt->nb_filelist].reference, token, PATH_MAX);
else
memset(opt->filelist[opt->nb_filelist].reference, 0, PATH_MAX);

opt->nb_filelist++;

if (opt->nb_filelist == 0) {
Expand Down Expand Up @@ -177,6 +186,14 @@ ml_parse_batches(struct ml_options *opt, const char *arg)
return parser_read_uint16(&opt->batches, arg);
}

static int
ml_parse_tolerance(struct ml_options *opt, const char *arg)
{
opt->tolerance = fabs(atof(arg));

return 0;
}

static void
ml_dump_test_options(const char *testname)
{
Expand All @@ -193,12 +210,13 @@ ml_dump_test_options(const char *testname)

if ((strcmp(testname, "inference_ordered") == 0) ||
(strcmp(testname, "inference_interleave") == 0)) {
printf("\t\t--filelist : comma separated list of model, input and output\n"
printf("\t\t--filelist : comma separated list of model, input, output and reference\n"
"\t\t--repetitions : number of inference repetitions\n"
"\t\t--burst_size : inference burst size\n"
"\t\t--queue_pairs : number of queue pairs to create\n"
"\t\t--queue_size : size fo queue-pair\n"
"\t\t--batches : number of batches of input\n");
"\t\t--batches : number of batches of input\n"
"\t\t--tolerance : maximum tolerance (%%) for output validation\n");
printf("\n");
}
}
Expand Down Expand Up @@ -229,6 +247,7 @@ static struct option lgopts[] = {
{ML_QUEUE_PAIRS, 1, 0, 0},
{ML_QUEUE_SIZE, 1, 0, 0},
{ML_BATCHES, 1, 0, 0},
{ML_TOLERANCE, 1, 0, 0},
{ML_DEBUG, 0, 0, 0},
{ML_HELP, 0, 0, 0},
{NULL, 0, 0, 0}};
Expand All @@ -249,6 +268,7 @@ ml_opts_parse_long(int opt_idx, struct ml_options *opt)
{ML_QUEUE_PAIRS, ml_parse_queue_pairs},
{ML_QUEUE_SIZE, ml_parse_queue_size},
{ML_BATCHES, ml_parse_batches},
{ML_TOLERANCE, ml_parse_tolerance},
};

for (i = 0; i < RTE_DIM(parsermap); i++) {
Expand Down
3 changes: 3 additions & 0 deletions app/test-mldev/ml_options.h
Expand Up @@ -22,13 +22,15 @@
#define ML_QUEUE_PAIRS ("queue_pairs")
#define ML_QUEUE_SIZE ("queue_size")
#define ML_BATCHES ("batches")
#define ML_TOLERANCE ("tolerance")
#define ML_DEBUG ("debug")
#define ML_HELP ("help")

struct ml_filelist {
char model[PATH_MAX];
char input[PATH_MAX];
char output[PATH_MAX];
char reference[PATH_MAX];
};

struct ml_options {
Expand All @@ -42,6 +44,7 @@ struct ml_options {
uint16_t queue_pairs;
uint16_t queue_size;
uint16_t batches;
float tolerance;
bool debug;
};

Expand Down

0 comments on commit 0de7cfa

Please sign in to comment.