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 <syalavar...@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 via email to