Enabled support to print TVM model layer info.

Signed-off-by: Srikanth Yalavarthi <syalavar...@marvell.com>
---
 drivers/ml/cnxk/cnxk_ml_model.c  |  7 +++-
 drivers/ml/cnxk/mvtvm_ml_model.c | 59 ++++++++++++++++++++++++++++++++
 drivers/ml/cnxk/mvtvm_ml_model.h |  2 ++
 drivers/ml/cnxk/mvtvm_ml_stubs.c |  8 +++++
 drivers/ml/cnxk/mvtvm_ml_stubs.h |  2 ++
 5 files changed, 77 insertions(+), 1 deletion(-)

diff --git a/drivers/ml/cnxk/cnxk_ml_model.c b/drivers/ml/cnxk/cnxk_ml_model.c
index 02f80410ec..ed6a1ed866 100644
--- a/drivers/ml/cnxk/cnxk_ml_model.c
+++ b/drivers/ml/cnxk/cnxk_ml_model.c
@@ -68,6 +68,8 @@ cnxk_ml_model_dump(struct cnxk_ml_dev *cnxk_mldev, struct 
cnxk_ml_model *model,
        cnxk_ml_print_line(fp, LINE_LEN);
        fprintf(fp, "%*s : %u\n", FIELD_LEN, "model_id", model->model_id);
        fprintf(fp, "%*s : %s\n", FIELD_LEN, "name", model->name);
+       fprintf(fp, "%*s : %d\n", FIELD_LEN, "type", model->type);
+       fprintf(fp, "%*s : %d\n", FIELD_LEN, "subtype", model->subtype);
        fprintf(fp, "%*s : 0x%016lx\n", FIELD_LEN, "model", 
PLT_U64_CAST(model));
        fprintf(fp, "%*s : %u\n", FIELD_LEN, "batch_size", model->batch_size);
        fprintf(fp, "%*s : %u\n", FIELD_LEN, "nb_layers", model->nb_layers);
@@ -84,6 +86,9 @@ cnxk_ml_model_dump(struct cnxk_ml_dev *cnxk_mldev, struct 
cnxk_ml_model *model,
 
        for (layer_id = 0; layer_id < model->nb_layers; layer_id++) {
                layer = &model->layer[layer_id];
-               cn10k_ml_layer_print(cnxk_mldev, layer, fp);
+               if (layer->type == ML_CNXK_LAYER_TYPE_MRVL)
+                       cn10k_ml_layer_print(cnxk_mldev, layer, fp);
+               else
+                       mvtvm_ml_layer_print(cnxk_mldev, layer, fp);
        }
 }
diff --git a/drivers/ml/cnxk/mvtvm_ml_model.c b/drivers/ml/cnxk/mvtvm_ml_model.c
index 88f2738423..e5ba672788 100644
--- a/drivers/ml/cnxk/mvtvm_ml_model.c
+++ b/drivers/ml/cnxk/mvtvm_ml_model.c
@@ -13,6 +13,7 @@
 
 #include "cnxk_ml_dev.h"
 #include "cnxk_ml_model.h"
+#include "cnxk_ml_utils.h"
 
 /* Objects list */
 char mvtvm_object_list[ML_MVTVM_MODEL_OBJECT_MAX][RTE_ML_STR_MAX] = {"mod.so", 
"mod.json",
@@ -334,3 +335,61 @@ mvtvm_ml_model_info_set(struct cnxk_ml_dev *cnxk_mldev, 
struct cnxk_ml_model *mo
                                &model->layer[0].glow.metadata);
        info->io_layout = RTE_ML_IO_LAYOUT_SPLIT;
 }
+
+void
+mvtvm_ml_layer_print(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_layer 
*layer, FILE *fp)
+{
+       char str[STR_LEN];
+       uint8_t i;
+
+       /* Print debug info */
+       cnxk_ml_print_line(fp, LINE_LEN);
+       fprintf(fp, " Layer Information (Layer ID: %u, Name: %s)\n",
+               cnxk_mldev->index_map[layer->index].layer_id, layer->name);
+       cnxk_ml_print_line(fp, LINE_LEN);
+       fprintf(fp, "%*s : %u\n", FIELD_LEN, "layer_id",
+               cnxk_mldev->index_map[layer->index].layer_id);
+       fprintf(fp, "%*s : %s\n", FIELD_LEN, "name", layer->name);
+       fprintf(fp, "%*s : %d\n", FIELD_LEN, "type", layer->type);
+       fprintf(fp, "%*s : 0x%016lx\n", FIELD_LEN, "layer", 
PLT_U64_CAST(layer));
+       fprintf(fp, "%*s : %u\n", FIELD_LEN, "batch_size", layer->batch_size);
+
+       /* Print model state */
+       if (layer->state == ML_CNXK_LAYER_STATE_LOADED)
+               fprintf(fp, "%*s : %s\n", FIELD_LEN, "state", "loaded");
+       if (layer->state == ML_CNXK_LAYER_STATE_JOB_ACTIVE)
+               fprintf(fp, "%*s : %s\n", FIELD_LEN, "state", "job_active");
+       if (layer->state == ML_CNXK_LAYER_STATE_STARTED)
+               fprintf(fp, "%*s : %s\n", FIELD_LEN, "state", "started");
+
+       fprintf(fp, "%*s : %u\n", FIELD_LEN, "num_inputs", 
layer->info.nb_inputs);
+       fprintf(fp, "%*s : %u\n", FIELD_LEN, "num_outputs", 
layer->info.nb_outputs);
+       fprintf(fp, "\n");
+
+       cnxk_ml_print_line(fp, LINE_LEN);
+       fprintf(fp, "%8s  %16s  %12s\n", "input", "input_name", "input_type");
+       cnxk_ml_print_line(fp, LINE_LEN);
+       for (i = 0; i < layer->info.nb_inputs; i++) {
+               fprintf(fp, "%8u  ", i);
+               fprintf(fp, "%*s  ", 16, layer->info.input[i].name);
+               rte_ml_io_type_to_str(layer->info.input[i].qtype, str, STR_LEN);
+               fprintf(fp, "%*s  ", 12, str);
+       }
+       fprintf(fp, "\n");
+       cnxk_ml_print_line(fp, LINE_LEN);
+       fprintf(fp, "\n");
+
+       cnxk_ml_print_line(fp, LINE_LEN);
+       fprintf(fp, "%8s  %16s  %12s\n", "output", "output_name", 
"output_type");
+       cnxk_ml_print_line(fp, LINE_LEN);
+       for (i = 0; i < layer->info.nb_outputs; i++) {
+               fprintf(fp, "%8u  ", i);
+               fprintf(fp, "%*s  ", 16, layer->info.output[i].name);
+               rte_ml_io_type_to_str(layer->info.output[i].qtype, str, 
STR_LEN);
+               fprintf(fp, "%*s  ", 12, str);
+               fprintf(fp, "\n");
+       }
+       fprintf(fp, "\n");
+       cnxk_ml_print_line(fp, LINE_LEN);
+       fprintf(fp, "\n");
+}
diff --git a/drivers/ml/cnxk/mvtvm_ml_model.h b/drivers/ml/cnxk/mvtvm_ml_model.h
index a1247ffbde..900ba44fa0 100644
--- a/drivers/ml/cnxk/mvtvm_ml_model.h
+++ b/drivers/ml/cnxk/mvtvm_ml_model.h
@@ -13,6 +13,7 @@
 
 struct cnxk_ml_dev;
 struct cnxk_ml_model;
+struct cnxk_ml_layer;
 
 /* Maximum number of objects per model */
 #define ML_MVTVM_MODEL_OBJECT_MAX 3
@@ -54,5 +55,6 @@ int mvtvm_ml_model_get_layer_id(struct cnxk_ml_model *model, 
const char *layer_n
 void mvtvm_ml_model_io_info_set(struct cnxk_ml_model *model);
 struct cnxk_ml_io_info *mvtvm_ml_model_io_info_get(struct cnxk_ml_model 
*model, uint16_t layer_id);
 void mvtvm_ml_model_info_set(struct cnxk_ml_dev *cnxk_mldev, struct 
cnxk_ml_model *model);
+void mvtvm_ml_layer_print(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_layer 
*layer, FILE *fp);
 
 #endif /* _MVTVM_ML_MODEL_H_ */
diff --git a/drivers/ml/cnxk/mvtvm_ml_stubs.c b/drivers/ml/cnxk/mvtvm_ml_stubs.c
index b8c2e6a1fc..260a051b08 100644
--- a/drivers/ml/cnxk/mvtvm_ml_stubs.c
+++ b/drivers/ml/cnxk/mvtvm_ml_stubs.c
@@ -36,6 +36,14 @@ mvtvm_ml_model_io_info_get(struct cnxk_ml_model *model, 
uint16_t layer_id)
        return NULL;
 }
 
+void
+mvtvm_ml_layer_print(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_layer 
*layer, FILE *fp)
+{
+       RTE_SET_USED(cnxk_mldev);
+       RTE_SET_USED(layer);
+       RTE_SET_USED(fp);
+}
+
 int
 mvtvm_ml_dev_configure(struct cnxk_ml_dev *cnxk_mldev, const struct 
rte_ml_dev_config *conf)
 {
diff --git a/drivers/ml/cnxk/mvtvm_ml_stubs.h b/drivers/ml/cnxk/mvtvm_ml_stubs.h
index 1eb663b1d1..d6d0edbcf1 100644
--- a/drivers/ml/cnxk/mvtvm_ml_stubs.h
+++ b/drivers/ml/cnxk/mvtvm_ml_stubs.h
@@ -9,6 +9,7 @@
 
 struct cnxk_ml_dev;
 struct cnxk_ml_model;
+struct cnxk_ml_layer;
 
 enum cnxk_ml_model_type mvtvm_ml_model_type_get(struct rte_ml_model_params 
*params);
 int mvtvm_ml_dev_configure(struct cnxk_ml_dev *cnxk_mldev, const struct 
rte_ml_dev_config *conf);
@@ -22,5 +23,6 @@ int mvtvm_ml_model_stop(struct cnxk_ml_dev *cnxk_mldev, 
struct cnxk_ml_model *mo
 int mvtvm_ml_model_get_layer_id(struct cnxk_ml_model *model, const char 
*layer_name,
                                uint16_t *layer_id);
 struct cnxk_ml_io_info *mvtvm_ml_model_io_info_get(struct cnxk_ml_model 
*model, uint16_t layer_id);
+void mvtvm_ml_layer_print(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_layer 
*layer, FILE *fp);
 
 #endif /* _MVTVM_ML_STUBS_H_ */
-- 
2.42.0

Reply via email to