Skip to content

Commit

Permalink
ml/cnxk: fix incorrect handling of TVM model I/O
Browse files Browse the repository at this point in the history
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: 5cea2c6 ("ml/cnxk: update internal TVM model info structure")
Fixes: df2358f ("ml/cnxk: add structures for TVM model type")
Cc: stable@dpdk.org

Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
  • Loading branch information
syalavarthi authored and jerinjacobk committed Sep 19, 2024
1 parent 41dd9a6 commit ecfc8af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions drivers/ml/cnxk/cnxk_ml_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/ml/cnxk/mvtvm_ml_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ecfc8af

Please sign in to comment.