From patchwork Wed Jul 31 06:25:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Yalavarthi X-Patchwork-Id: 142779 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 39B6E456FF; Wed, 31 Jul 2024 08:33:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 19F624065D; Wed, 31 Jul 2024 08:33:25 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id A918040652 for ; Wed, 31 Jul 2024 08:25:34 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46V3DPZw001739 for ; Tue, 30 Jul 2024 23:25:33 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=pfpt0220; bh=ox+gdn7ma+p2GkVgQx2TMK5 mZAvcohDR6W19xTRs3kM=; b=A1YgfcjHpPoHsma2Mri7ojhUVlSp1KnmQX7e+2J swn/blddZGU/FGitN/cTmKW/ke3+oON8J8BBGavguWMJWVcfChV7AUQdxeQZDKGi oaYrcK2ct8P4HoGtMnj0RFz1jVy5+rpSPhi8WRw/3c/9/ugHHnDuzr6GQGV4o8p8 bur24QUeWc5HwHHXxiPM31lLzdqdQ0eC7r0pBhsJlvL/mjIlreCd51k7ZkAQTqx2 fKtbG60srJid/SkDLJHOcm0pnFhbxyXWZNHUJz5SDrbNiRrreNaJRhqOMDdx/vh5 hdKAwrqZW5m4VzIU0FbfDNvR/gj5OscAIa718j5OplDIZXQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 40qd64rkv0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 30 Jul 2024 23:25:33 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 30 Jul 2024 23:25:32 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 30 Jul 2024 23:25:32 -0700 Received: from ml-host-33.sclab.marvell.com. (unknown [10.110.143.233]) by maili.marvell.com (Postfix) with ESMTP id 28EF95C68E1; Tue, 30 Jul 2024 23:25:32 -0700 (PDT) From: Srikanth Yalavarthi To: Srikanth Yalavarthi CC: , , , Subject: [PATCH v1 1/1] mldev: add scale and zero point to I/O info struct Date: Tue, 30 Jul 2024 23:25:29 -0700 Message-ID: <20240731062530.8708-1-syalavarthi@marvell.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 5ffNDm4oYQgZjGl8WdtzG97-M_MVxpDm X-Proofpoint-GUID: 5ffNDm4oYQgZjGl8WdtzG97-M_MVxpDm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-31_03,2024-07-30_01,2024-05-17_01 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 Added scale and zero point to I/O information structure. This would provision sharing the recommended sclae factor and zero point to the user for quantization process. Signed-off-by: Srikanth Yalavarthi --- drivers/ml/cnxk/cn10k_ml_model.c | 4 ++++ drivers/ml/cnxk/cnxk_ml_io.h | 3 +++ drivers/ml/cnxk/mvtvm_ml_model.c | 4 ++++ lib/mldev/rte_mldev.h | 4 ++++ 4 files changed, 15 insertions(+) diff --git a/drivers/ml/cnxk/cn10k_ml_model.c b/drivers/ml/cnxk/cn10k_ml_model.c index 0325cd54f1f..12a2dda800e 100644 --- a/drivers/ml/cnxk/cn10k_ml_model.c +++ b/drivers/ml/cnxk/cn10k_ml_model.c @@ -586,6 +586,8 @@ cn10k_ml_model_info_set(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_model *mo input[i].nb_elements = io_info->input[i].nb_elements; input[i].size = io_info->input[i].nb_elements * rte_ml_io_type_size_get(io_info->input[i].qtype); + input[i].scale = 1.0 / io_info->input[i].scale; + input[i].zero_point = 0; } /* Set output info */ @@ -597,6 +599,8 @@ cn10k_ml_model_info_set(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_model *mo output[i].nb_elements = io_info->output[i].nb_elements; output[i].size = io_info->output[i].nb_elements * rte_ml_io_type_size_get(io_info->output[i].qtype); + output[i].scale = io_info->output[i].scale; + output[i].zero_point = 0; } } diff --git a/drivers/ml/cnxk/cnxk_ml_io.h b/drivers/ml/cnxk/cnxk_ml_io.h index c33a9c23a11..83329c237aa 100644 --- a/drivers/ml/cnxk/cnxk_ml_io.h +++ b/drivers/ml/cnxk/cnxk_ml_io.h @@ -55,6 +55,9 @@ struct cnxk_ml_io { /* Scale */ float scale; + + /* Zero point */ + int64_t zero_point; }; /* Model / Layer IO structure */ diff --git a/drivers/ml/cnxk/mvtvm_ml_model.c b/drivers/ml/cnxk/mvtvm_ml_model.c index e3234ae4422..88b0089295d 100644 --- a/drivers/ml/cnxk/mvtvm_ml_model.c +++ b/drivers/ml/cnxk/mvtvm_ml_model.c @@ -334,6 +334,8 @@ mvtvm_ml_model_info_set(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_model *mo input[i].nb_elements = model->mvtvm.info.input[i].nb_elements; input[i].size = model->mvtvm.info.input[i].nb_elements * rte_ml_io_type_size_get(model->mvtvm.info.input[i].qtype); + input[i].scale = model->mvtvm.info.input[i].scale; + input[i].zero_point = 0; } /* Set output info */ @@ -345,6 +347,8 @@ mvtvm_ml_model_info_set(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_model *mo output[i].nb_elements = model->mvtvm.info.output[i].nb_elements; output[i].size = model->mvtvm.info.output[i].nb_elements * rte_ml_io_type_size_get(model->mvtvm.info.output[i].qtype); + input[i].scale = model->mvtvm.info.output[i].scale; + input[i].zero_point = 0; } return; diff --git a/lib/mldev/rte_mldev.h b/lib/mldev/rte_mldev.h index 634af3d5e1a..e2f715f140d 100644 --- a/lib/mldev/rte_mldev.h +++ b/lib/mldev/rte_mldev.h @@ -937,6 +937,10 @@ struct rte_ml_io_info { /** Number of elements in tensor */ uint64_t size; /** Size of tensor in bytes */ + float scale; + /** Scale factor */ + int64_t zero_point; + /* Zero point */ }; /** Model information structure */