Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/133420/?format=api
http://patches.dpdk.org/api/patches/133420/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20231026124347.22477-33-syalavarthi@marvell.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20231026124347.22477-33-syalavarthi@marvell.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20231026124347.22477-33-syalavarthi@marvell.com", "date": "2023-10-26T12:43:41", "name": "[v9,32/34] ml/cnxk: support quantize and dequantize callback", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "f8cdd51ddfe0b392e8bb2bc343463cffbca92cbe", "submitter": { "id": 2480, "url": "http://patches.dpdk.org/api/people/2480/?format=api", "name": "Srikanth Yalavarthi", "email": "syalavarthi@marvell.com" }, "delegate": { "id": 310, "url": "http://patches.dpdk.org/api/users/310/?format=api", "username": "jerin", "first_name": "Jerin", "last_name": "Jacob", "email": "jerinj@marvell.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20231026124347.22477-33-syalavarthi@marvell.com/mbox/", "series": [ { "id": 30002, "url": "http://patches.dpdk.org/api/series/30002/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=30002", "date": "2023-10-26T12:43:09", "name": "Implementation of revised ml/cnxk driver", "version": 9, "mbox": "http://patches.dpdk.org/series/30002/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/133420/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/133420/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "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])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 1578F43208;\n\tThu, 26 Oct 2023 14:50:24 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id CC3CC42ECD;\n\tThu, 26 Oct 2023 14:44:37 +0200 (CEST)", "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n [67.231.156.173])\n by mails.dpdk.org (Postfix) with ESMTP id 97D9E42E45\n for <dev@dpdk.org>; Thu, 26 Oct 2023 14:44:07 +0200 (CEST)", "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 39QALk0J007523 for <dev@dpdk.org>; Thu, 26 Oct 2023 05:44:07 -0700", "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3txcsr25pc-20\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Thu, 26 Oct 2023 05:44:06 -0700", "from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48;\n Thu, 26 Oct 2023 05:44:02 -0700", "from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend\n Transport; Thu, 26 Oct 2023 05:44:02 -0700", "from ml-host-33.caveonetworks.com (unknown [10.110.143.233])\n by maili.marvell.com (Postfix) with ESMTP id 2134D3F70C9;\n Thu, 26 Oct 2023 05:44:02 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-transfer-encoding : content-type; s=pfpt0220;\n bh=NX3jgCX4uc0HtjYhjzGQUc+IJbn/IpFuq5zUSPYkwxI=;\n b=haNANbWholgurODK7RWtQ37cOw/AUQW4SWvGDO0HCGI2wO4+RiwRwCrf9Es8NbiftOec\n dPN+D22W+S30U9GpEl0MG3Hk5TqIDpGNvEFCeUucv1VUOf2v5TQf5oBInayBesgdBXX5\n FqgCdhl/Br7Tr5MVuIuc3AP4QoxpcYXZvR6n6qOgbbX2ertetqTTZ2n8rEfhJqZy8kgB\n 4s39wOJNxO0WWTtvwL0W+JCN663t8kU6qg8UNKZ1qhtFkn9/gK9nQs5j4ConB5W2Y9NN\n tHdshaJYxfwG9PKALbkgHJ2kwX9OCg/l6YOTp6BvHLKTR+cTQrc468LoBl0q2dtNmud7 Tw==", "From": "Srikanth Yalavarthi <syalavarthi@marvell.com>", "To": "Srikanth Yalavarthi <syalavarthi@marvell.com>", "CC": "<dev@dpdk.org>, <sshankarnara@marvell.com>, <aprabhu@marvell.com>,\n <ptakkar@marvell.com>", "Subject": "[PATCH v9 32/34] ml/cnxk: support quantize and dequantize callback", "Date": "Thu, 26 Oct 2023 05:43:41 -0700", "Message-ID": "<20231026124347.22477-33-syalavarthi@marvell.com>", "X-Mailer": "git-send-email 2.42.0", "In-Reply-To": "<20231026124347.22477-1-syalavarthi@marvell.com>", "References": "<20230830155927.3566-1-syalavarthi@marvell.com>\n <20231026124347.22477-1-syalavarthi@marvell.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain", "X-Proofpoint-ORIG-GUID": "3sQiiDPJFQwirqASo8u0xzYd0DFa5hk2", "X-Proofpoint-GUID": "3sQiiDPJFQwirqASo8u0xzYd0DFa5hk2", "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26\n definitions=2023-10-26_10,2023-10-26_01,2023-05-22_02", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "From: Prince Takkar <ptakkar@marvell.com>\n\nAdded support for quantize and dequantize callback\nfunctions for TVM models.\n\nSigned-off-by: Prince Takkar <ptakkar@marvell.com>\n---\n drivers/ml/cnxk/mvtvm_ml_ops.c | 129 +++++++++++++++++++++++++++++++++\n drivers/ml/cnxk/mvtvm_ml_ops.h | 4 +\n 2 files changed, 133 insertions(+)", "diff": "diff --git a/drivers/ml/cnxk/mvtvm_ml_ops.c b/drivers/ml/cnxk/mvtvm_ml_ops.c\nindex 9d59e28661..39c8bf0f04 100644\n--- a/drivers/ml/cnxk/mvtvm_ml_ops.c\n+++ b/drivers/ml/cnxk/mvtvm_ml_ops.c\n@@ -2,11 +2,15 @@\n * Copyright (c) 2023 Marvell.\n */\n \n+#include <dlpack/dlpack.h>\n+\n #include <rte_common.h>\n #include <rte_cycles.h>\n #include <rte_mldev.h>\n #include <rte_mldev_pmd.h>\n \n+#include <mldev_utils.h>\n+\n #include \"cnxk_ml_dev.h\"\n #include \"cnxk_ml_model.h\"\n #include \"cnxk_ml_ops.h\"\n@@ -236,6 +240,8 @@ mvtvm_ml_model_load(struct cnxk_ml_dev *cnxk_mldev, struct rte_ml_model_params *\n \t\tcallback->tvmrt_io_free = cn10k_ml_io_free;\n \t\tcallback->tvmrt_malloc = cn10k_ml_malloc;\n \t\tcallback->tvmrt_free = cn10k_ml_free;\n+\t\tcallback->tvmrt_quantize = mvtvm_ml_io_quantize;\n+\t\tcallback->tvmrt_dequantize = mvtvm_ml_io_dequantize;\n \t} else {\n \t\tcallback = NULL;\n \t}\n@@ -366,3 +372,126 @@ mvtvm_ml_model_stop(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_model *model)\n \n \treturn 0;\n }\n+\n+int\n+mvtvm_ml_io_quantize(void *device, uint16_t model_id, const char *layer_name,\n+\t\t const DLTensor **deq_tensor, void *qbuffer)\n+{\n+\tstruct cnxk_ml_io_info *info = NULL;\n+\tstruct cnxk_ml_dev *cnxk_mldev;\n+\tstruct cnxk_ml_model *model;\n+\tuint16_t layer_id = 0;\n+\tuint8_t *lcl_dbuffer;\n+\tuint8_t *lcl_qbuffer;\n+\tuint32_t i;\n+\tint ret;\n+\n+#ifdef CNXK_ML_DEV_DEBUG\n+\tif ((device == NULL) || (deq_tensor == NULL) || (qbuffer == NULL))\n+\t\treturn -EINVAL;\n+#endif\n+\n+\tcnxk_mldev = (struct cnxk_ml_dev *)device;\n+\n+\tmodel = cnxk_mldev->mldev->data->models[model_id];\n+#ifdef CNXK_ML_DEV_DEBUG\n+\tif (model == NULL) {\n+\t\tplt_err(\"Invalid model_id = %u\", model_id);\n+\t\treturn -EINVAL;\n+\t}\n+#endif\n+\n+\t/* Get layer id */\n+\tfor (layer_id = 0; layer_id < model->mvtvm.metadata.model.nb_layers; layer_id++) {\n+\t\tif (strcmp(model->layer[layer_id].name, layer_name) == 0)\n+\t\t\tbreak;\n+\t}\n+\n+#ifdef CNXK_ML_DEV_DEBUG\n+\tif (layer_id == model->mvtvm.metadata.model.nb_layers) {\n+\t\tplt_err(\"Invalid layer name: %s\", layer_name);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (model->layer[layer_id].type != ML_CNXK_LAYER_TYPE_MRVL) {\n+\t\tplt_err(\"Invalid layer name / type: %s\", layer_name);\n+\t\treturn -EINVAL;\n+\t}\n+#endif\n+\n+\tinfo = &model->layer[layer_id].info;\n+\tlcl_qbuffer = (uint8_t *)qbuffer;\n+\n+\tfor (i = 0; i < info->nb_inputs; i++) {\n+\t\tlcl_dbuffer = PLT_PTR_ADD(deq_tensor[i]->data, deq_tensor[i]->byte_offset);\n+\n+\t\tret = cnxk_ml_io_quantize_single(&info->input[i], lcl_dbuffer, lcl_qbuffer);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\n+\t\tlcl_qbuffer += info->input[i].sz_q;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int\n+mvtvm_ml_io_dequantize(void *device, uint16_t model_id, const char *layer_name, void *qbuffer,\n+\t\t const DLTensor **deq_tensor)\n+{\n+\tstruct cnxk_ml_io_info *info = NULL;\n+\tstruct cnxk_ml_dev *cnxk_mldev;\n+\tstruct cnxk_ml_model *model;\n+\tuint16_t layer_id = 0;\n+\tuint8_t *lcl_dbuffer;\n+\tuint8_t *lcl_qbuffer;\n+\tuint32_t i;\n+\tint ret;\n+\n+#ifdef CNXK_ML_DEV_DEBUG\n+\tif ((device == NULL) || (deq_tensor == NULL) || (qbuffer == NULL))\n+\t\treturn -EINVAL;\n+#endif\n+\n+\tcnxk_mldev = (struct cnxk_ml_dev *)device;\n+\n+\tmodel = cnxk_mldev->mldev->data->models[model_id];\n+#ifdef CNXK_ML_DEV_DEBUG\n+\tif (model == NULL) {\n+\t\tplt_err(\"Invalid model_id = %u\", model_id);\n+\t\treturn -EINVAL;\n+\t}\n+#endif\n+\n+\tfor (layer_id = 0; layer_id < model->mvtvm.metadata.model.nb_layers; layer_id++) {\n+\t\tif (strcmp(model->layer[layer_id].name, layer_name) == 0)\n+\t\t\tbreak;\n+\t}\n+\n+#ifdef CNXK_ML_DEV_DEBUG\n+\tif (layer_id == model->mvtvm.metadata.model.nb_layers) {\n+\t\tplt_err(\"Invalid layer name: %s\", layer_name);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (model->layer[layer_id].type != ML_CNXK_LAYER_TYPE_MRVL) {\n+\t\tplt_err(\"Invalid layer name / type: %s\", layer_name);\n+\t\treturn -EINVAL;\n+\t}\n+#endif\n+\n+\tinfo = &model->layer[layer_id].info;\n+\tlcl_qbuffer = (uint8_t *)qbuffer;\n+\n+\tfor (i = 0; i < info->nb_outputs; i++) {\n+\t\tlcl_dbuffer = PLT_PTR_ADD(deq_tensor[i]->data, deq_tensor[i]->byte_offset);\n+\n+\t\tret = cnxk_ml_io_dequantize_single(&info->output[i], lcl_qbuffer, lcl_dbuffer);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\n+\t\tlcl_qbuffer += info->output[i].sz_q;\n+\t}\n+\n+\treturn 0;\n+}\ndiff --git a/drivers/ml/cnxk/mvtvm_ml_ops.h b/drivers/ml/cnxk/mvtvm_ml_ops.h\nindex 22e0340146..4cabe30a82 100644\n--- a/drivers/ml/cnxk/mvtvm_ml_ops.h\n+++ b/drivers/ml/cnxk/mvtvm_ml_ops.h\n@@ -24,6 +24,10 @@ int mvtvm_ml_model_load(struct cnxk_ml_dev *cnxk_mldev, struct rte_ml_model_para\n int mvtvm_ml_model_unload(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_model *model);\n int mvtvm_ml_model_start(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_model *model);\n int mvtvm_ml_model_stop(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_model *model);\n+int mvtvm_ml_io_quantize(void *device, uint16_t model_id, const char *layer_name,\n+\t\t\t const DLTensor **deq_tensor, void *qbuffer);\n+int mvtvm_ml_io_dequantize(void *device, uint16_t model_id, const char *layer_name, void *qbuffer,\n+\t\t\t const DLTensor **deq_tensor);\n \n void mvtvm_ml_model_xstat_name_set(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_model *model,\n \t\t\t\t uint16_t stat_id, uint16_t entry, char *suffix);\n", "prefixes": [ "v9", "32/34" ] }{ "id": 133420, "url": "