From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6DD97426A1; Mon, 2 Oct 2023 12:02:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 51ED2402CC; Mon, 2 Oct 2023 12:02:24 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 82D4740294 for ; Mon, 2 Oct 2023 12:02:22 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 391N1kSb003427 for ; Mon, 2 Oct 2023 03:02:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=y4IO9zkb++9rs2TcV9FhO4U/oOgB5IDa4f5PAPIKcOw=; b=MbIi4TylYWaEsERdcPCE1gWVmCUDGbwHe6RvFZ3OiauoLBaFwtv1Tb7pRgmNdgA0FH0J XTQn0nFvcZvTS51HM3oIOSKCPDI9hd/AGXJMUMDXQN5trP+HxzdbW1VklnyonZ7+vYYB UTEd8ScoIvIo8DIKk0LaDpdVuLml4utVWxn3yN/N3FRNtJdfcwCRZj0FNonD6NrUK6sx nxISSsc8h4iQ6uHtXgWRAVxye3KYY/gpnNqmNZ1OIHRzPteLtPyu3oFCVDZuwbiwavbb yd+8kFIh6klKhQjJnZ2QF0Dm2JMS3VOq9Qpxi6+Oeju2znB7cbDhEjPtUk5sNBPY6766 SQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3teh1qvd3u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 02 Oct 2023 03:02:21 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 2 Oct 2023 03:02:20 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Mon, 2 Oct 2023 03:02:19 -0700 Received: from ml-host-33.caveonetworks.com (unknown [10.110.143.233]) by maili.marvell.com (Postfix) with ESMTP id 55D8B3F704D; Mon, 2 Oct 2023 03:02:18 -0700 (PDT) From: Srikanth Yalavarthi To: Srikanth Yalavarthi CC: , , , Subject: [PATCH v1 1/1] app/mldev: enable support for pre-quantized I/O Date: Mon, 2 Oct 2023 03:02:17 -0700 Message-ID: <20231002100217.12456-1-syalavarthi@marvell.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: zpaiPQnhzbhfVcevimt0YKQf8NhsouZz X-Proofpoint-ORIG-GUID: zpaiPQnhzbhfVcevimt0YKQf8NhsouZz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-02_03,2023-09-28_03,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Anup Prabhu Enabled support for pre-quantized input and output in ML test application. Signed-off-by: Anup Prabhu --- Depends-on: series-29710 ("Spec changes to support multi I/O models") app/test-mldev/ml_options.c | 8 ++++++++ app/test-mldev/ml_options.h | 28 ++++++++++++++------------ app/test-mldev/test_inference_common.c | 20 ++++++++++++------ doc/guides/tools/testmldev.rst | 3 +++ 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/app/test-mldev/ml_options.c b/app/test-mldev/ml_options.c index eeaffec399..7d24f7e2f0 100644 --- a/app/test-mldev/ml_options.c +++ b/app/test-mldev/ml_options.c @@ -24,6 +24,7 @@ ml_options_default(struct ml_options *opt) opt->dev_id = 0; opt->socket_id = SOCKET_ID_ANY; opt->nb_filelist = 0; + opt->quantized_io = false; opt->repetitions = 1; opt->burst_size = 1; opt->queue_pairs = 1; @@ -269,6 +270,7 @@ static struct option lgopts[] = { {ML_SOCKET_ID, 1, 0, 0}, {ML_MODELS, 1, 0, 0}, {ML_FILELIST, 1, 0, 0}, + {ML_QUANTIZED_IO, 0, 0, 0}, {ML_REPETITIONS, 1, 0, 0}, {ML_BURST_SIZE, 1, 0, 0}, {ML_QUEUE_PAIRS, 1, 0, 0}, @@ -316,6 +318,11 @@ ml_options_parse(struct ml_options *opt, int argc, char **argv) while ((opts = getopt_long(argc, argv, "", lgopts, &opt_idx)) != EOF) { switch (opts) { case 0: /* parse long options */ + if (!strcmp(lgopts[opt_idx].name, "quantized_io")) { + opt->quantized_io = true; + break; + } + if (!strcmp(lgopts[opt_idx].name, "stats")) { opt->stats = true; break; @@ -360,4 +367,5 @@ ml_options_dump(struct ml_options *opt) ml_dump("socket_id", "%d", opt->socket_id); ml_dump("debug", "%s", (opt->debug ? "true" : "false")); + ml_dump("quantized_io", "%s", (opt->quantized_io ? "true" : "false")); } diff --git a/app/test-mldev/ml_options.h b/app/test-mldev/ml_options.h index 90e22adeac..edb9dba8f7 100644 --- a/app/test-mldev/ml_options.h +++ b/app/test-mldev/ml_options.h @@ -12,19 +12,20 @@ #define ML_TEST_MAX_MODELS 8 /* Options names */ -#define ML_TEST ("test") -#define ML_DEVICE_ID ("dev_id") -#define ML_SOCKET_ID ("socket_id") -#define ML_MODELS ("models") -#define ML_FILELIST ("filelist") -#define ML_REPETITIONS ("repetitions") -#define ML_BURST_SIZE ("burst_size") -#define ML_QUEUE_PAIRS ("queue_pairs") -#define ML_QUEUE_SIZE ("queue_size") -#define ML_TOLERANCE ("tolerance") -#define ML_STATS ("stats") -#define ML_DEBUG ("debug") -#define ML_HELP ("help") +#define ML_TEST ("test") +#define ML_DEVICE_ID ("dev_id") +#define ML_SOCKET_ID ("socket_id") +#define ML_MODELS ("models") +#define ML_FILELIST ("filelist") +#define ML_QUANTIZED_IO ("quantized_io") +#define ML_REPETITIONS ("repetitions") +#define ML_BURST_SIZE ("burst_size") +#define ML_QUEUE_PAIRS ("queue_pairs") +#define ML_QUEUE_SIZE ("queue_size") +#define ML_TOLERANCE ("tolerance") +#define ML_STATS ("stats") +#define ML_DEBUG ("debug") +#define ML_HELP ("help") struct ml_filelist { char model[PATH_MAX]; @@ -46,6 +47,7 @@ struct ml_options { float tolerance; bool stats; bool debug; + bool quantized_io; }; void ml_options_default(struct ml_options *opt); diff --git a/app/test-mldev/test_inference_common.c b/app/test-mldev/test_inference_common.c index 846f71abb1..36629210ee 100644 --- a/app/test-mldev/test_inference_common.c +++ b/app/test-mldev/test_inference_common.c @@ -777,14 +777,22 @@ ml_inference_iomem_setup(struct ml_test *test, struct ml_options *opt, uint16_t } t->model[fid].inp_dsize = 0; - for (i = 0; i < t->model[fid].info.nb_inputs; i++) - t->model[fid].inp_dsize += - t->model[fid].info.input_info[i].nb_elements * sizeof(float); + for (i = 0; i < t->model[fid].info.nb_inputs; i++) { + if (opt->quantized_io) + t->model[fid].inp_dsize += t->model[fid].info.input_info[i].size; + else + t->model[fid].inp_dsize += + t->model[fid].info.input_info[i].nb_elements * sizeof(float); + } t->model[fid].out_dsize = 0; - for (i = 0; i < t->model[fid].info.nb_outputs; i++) - t->model[fid].out_dsize += - t->model[fid].info.output_info[i].nb_elements * sizeof(float); + for (i = 0; i < t->model[fid].info.nb_outputs; i++) { + if (opt->quantized_io) + t->model[fid].out_dsize += t->model[fid].info.output_info[i].size; + else + t->model[fid].out_dsize += + t->model[fid].info.output_info[i].nb_elements * sizeof(float); + } /* allocate buffer for user data */ mz_size = t->model[fid].inp_dsize + t->model[fid].out_dsize; diff --git a/doc/guides/tools/testmldev.rst b/doc/guides/tools/testmldev.rst index 9b1565a457..55e26eed08 100644 --- a/doc/guides/tools/testmldev.rst +++ b/doc/guides/tools/testmldev.rst @@ -89,6 +89,9 @@ The following are the command-line options supported by the test application. A suffix ``.q`` is appended to quantized output filename. Maximum number of filelist entries supported by the test is ``8``. +``--quantized_io`` + Disable IO quantization and dequantization. + ``--repetitions `` Set the number of inference repetitions to be executed in the test per each model. Default value is ``1``. -- 2.41.0