DPDK patches and discussions
 help / color / mirror / Atom feed
From: Srikanth Yalavarthi <syalavarthi@marvell.com>
To: Srikanth Yalavarthi <syalavarthi@marvell.com>,
	Prince Takkar <ptakkar@marvell.com>
Cc: <dev@dpdk.org>, <sshankarnara@marvell.com>, <aprabhu@marvell.com>
Subject: [PATCH v1 1/1] ml/cnxk: fix incorrect handling of TVM model I/O
Date: Tue, 30 Jul 2024 22:41:03 -0700	[thread overview]
Message-ID: <20240731054104.7576-1-syalavarthi@marvell.com> (raw)

Fixed incorrect handling of TVM models with single MRVL
layer. Set the I/O layout to packed and fixed calculation
of quantized and dequantized data buffer addresses.

Fixes: 5cea2c67edfc ("ml/cnxk: update internal TVM model info structure")
Fixes: df2358f3adce ("ml/cnxk: add structures for TVM model type")

Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
---
 drivers/ml/cnxk/cnxk_ml_ops.c    | 12 ++++++++----
 drivers/ml/cnxk/mvtvm_ml_model.c |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/ml/cnxk/cnxk_ml_ops.c b/drivers/ml/cnxk/cnxk_ml_ops.c
index 971362b2420..07c7001b175 100644
--- a/drivers/ml/cnxk/cnxk_ml_ops.c
+++ b/drivers/ml/cnxk/cnxk_ml_ops.c
@@ -1462,7 +1462,8 @@ cnxk_ml_io_quantize(struct rte_ml_dev *dev, uint16_t model_id, struct rte_ml_buf
 	d_offset = 0;
 	q_offset = 0;
 	for (i = 0; i < info->nb_inputs; i++) {
-		if (model->type == ML_CNXK_MODEL_TYPE_TVM) {
+		if (model->type == ML_CNXK_MODEL_TYPE_TVM &&
+		    model->subtype != ML_CNXK_MODEL_SUBTYPE_TVM_MRVL) {
 			lcl_dbuffer = dbuffer[i]->addr;
 			lcl_qbuffer = qbuffer[i]->addr;
 		} else {
@@ -1474,7 +1475,8 @@ cnxk_ml_io_quantize(struct rte_ml_dev *dev, uint16_t model_id, struct rte_ml_buf
 		if (ret < 0)
 			return ret;
 
-		if (model->type == ML_CNXK_MODEL_TYPE_GLOW) {
+		if ((model->type == ML_CNXK_MODEL_TYPE_GLOW) ||
+		    (model->subtype == ML_CNXK_MODEL_SUBTYPE_TVM_MRVL)) {
 			d_offset += info->input[i].sz_d;
 			q_offset += info->input[i].sz_q;
 		}
@@ -1516,7 +1518,8 @@ cnxk_ml_io_dequantize(struct rte_ml_dev *dev, uint16_t model_id, struct rte_ml_b
 	q_offset = 0;
 	d_offset = 0;
 	for (i = 0; i < info->nb_outputs; i++) {
-		if (model->type == ML_CNXK_MODEL_TYPE_TVM) {
+		if (model->type == ML_CNXK_MODEL_TYPE_TVM &&
+		    model->subtype != ML_CNXK_MODEL_SUBTYPE_TVM_MRVL) {
 			lcl_qbuffer = qbuffer[i]->addr;
 			lcl_dbuffer = dbuffer[i]->addr;
 		} else {
@@ -1528,7 +1531,8 @@ cnxk_ml_io_dequantize(struct rte_ml_dev *dev, uint16_t model_id, struct rte_ml_b
 		if (ret < 0)
 			return ret;
 
-		if (model->type == ML_CNXK_MODEL_TYPE_GLOW) {
+		if ((model->type == ML_CNXK_MODEL_TYPE_GLOW) ||
+		    (model->subtype == ML_CNXK_MODEL_SUBTYPE_TVM_MRVL)) {
 			q_offset += info->output[i].sz_q;
 			d_offset += info->output[i].sz_d;
 		}
diff --git a/drivers/ml/cnxk/mvtvm_ml_model.c b/drivers/ml/cnxk/mvtvm_ml_model.c
index e3234ae4422..c8c4f61f134 100644
--- a/drivers/ml/cnxk/mvtvm_ml_model.c
+++ b/drivers/ml/cnxk/mvtvm_ml_model.c
@@ -356,7 +356,7 @@ mvtvm_ml_model_info_set(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_model *mo
 	metadata = &model->mvtvm.metadata;
 	strlcpy(info->name, metadata->model.name, TVMDP_NAME_STRLEN);
 
-	info->io_layout = RTE_ML_IO_LAYOUT_SPLIT;
+	info->io_layout = RTE_ML_IO_LAYOUT_PACKED;
 }
 
 void
-- 
2.45.1


             reply	other threads:[~2024-07-31  5:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31  5:41 Srikanth Yalavarthi [this message]
2024-09-19 17:31 ` Jerin Jacob
2024-07-31  6:10 Srikanth Yalavarthi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240731054104.7576-1-syalavarthi@marvell.com \
    --to=syalavarthi@marvell.com \
    --cc=aprabhu@marvell.com \
    --cc=dev@dpdk.org \
    --cc=ptakkar@marvell.com \
    --cc=sshankarnara@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).