get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/130912/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 130912,
    "url": "http://patchwork.dpdk.org/api/patches/130912/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230830155927.3566-33-syalavarthi@marvell.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<20230830155927.3566-33-syalavarthi@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230830155927.3566-33-syalavarthi@marvell.com",
    "date": "2023-08-30T15:59:22",
    "name": "[v1,32/34] ml/cnxk: support quantize and dequantize callback",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d8ca6ee3d13b1af92312c08300cb66794e1e0735",
    "submitter": {
        "id": 2480,
        "url": "http://patchwork.dpdk.org/api/people/2480/?format=api",
        "name": "Srikanth Yalavarthi",
        "email": "syalavarthi@marvell.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20230830155927.3566-33-syalavarthi@marvell.com/mbox/",
    "series": [
        {
            "id": 29376,
            "url": "http://patchwork.dpdk.org/api/series/29376/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=29376",
            "date": "2023-08-30T15:58:50",
            "name": "Implemenation of revised ml/cnxk driver",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/29376/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/130912/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/130912/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 71E9341FD1;\n\tWed, 30 Aug 2023 18:06:16 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id E5999427D8;\n\tWed, 30 Aug 2023 18:00:13 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com\n [67.231.148.174])\n by mails.dpdk.org (Postfix) with ESMTP id E35A9402BD\n for <dev@dpdk.org>; Wed, 30 Aug 2023 17:59:44 +0200 (CEST)",
            "from pps.filterd (m0045849.ppops.net [127.0.0.1])\n by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 37U6P7K4004364 for <dev@dpdk.org>; Wed, 30 Aug 2023 08:59:44 -0700",
            "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3st0fysstv-3\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Wed, 30 Aug 2023 08:59:43 -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 Wed, 30 Aug 2023 08:59:42 -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; Wed, 30 Aug 2023 08:59:42 -0700",
            "from ml-host-33.caveonetworks.com (unknown [10.110.143.233])\n by maili.marvell.com (Postfix) with ESMTP id AC2913F7080;\n Wed, 30 Aug 2023 08:59:42 -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=SzvV2crAZvHZxE2qCJ8GBs7FYNpI/y/NgZrWzp90wSQ=;\n b=SdWuljYEqSbrFMNegTLGUqmFFFgE+PO34itaybdZ4Yy4uOb8OcNqYB5QAkBImQ2OLX/t\n FQi7rVZMGX/M+Hp4vzeT0s+xVtDs0jVIRWoDnAcrwv7WZa9JcV+PUM822urFkUe6LaP5\n UcAVS06QWJawkVEOY8jtP26X8T4vWjeZO2Bz8n776P2zCqeWZf1p4MeGni+qAst8gKHw\n HmsmcLi6JEe69z5mfsvNl6NP0visgZ2Hh0AZr0fk/+b2bVF92E2CRUmf7HXnH6dehCPU\n khoJtg8clbETrC8qZ3gyuyp//thPNTZ/aM3UEhgJFBmT7qya/5sModwELHaLFjSCOTKI BQ==",
        "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 v1 32/34] ml/cnxk: support quantize and dequantize callback",
        "Date": "Wed, 30 Aug 2023 08:59:22 -0700",
        "Message-ID": "<20230830155927.3566-33-syalavarthi@marvell.com>",
        "X-Mailer": "git-send-email 2.41.0",
        "In-Reply-To": "<20230830155927.3566-1-syalavarthi@marvell.com>",
        "References": "<20230830155927.3566-1-syalavarthi@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "pjXSAdQ8j4JE92qqkmdaYEw3ulQULWem",
        "X-Proofpoint-ORIG-GUID": "pjXSAdQ8j4JE92qqkmdaYEw3ulQULWem",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26\n definitions=2023-08-30_12,2023-08-29_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/meson.build      |   5 ++\n drivers/ml/cnxk/mvtvm_ml_model.h |   2 +\n drivers/ml/cnxk/mvtvm_ml_ops.c   | 127 +++++++++++++++++++++++++++++++\n drivers/ml/cnxk/mvtvm_ml_ops.h   |   6 ++\n 4 files changed, 140 insertions(+)",
    "diff": "diff --git a/drivers/ml/cnxk/meson.build b/drivers/ml/cnxk/meson.build\nindex db175b0834d..09a62b5c55a 100644\n--- a/drivers/ml/cnxk/meson.build\n+++ b/drivers/ml/cnxk/meson.build\n@@ -19,6 +19,11 @@ if not jansson_dep.found()\n         enable_mvtvm = false\n endif\n \n+if not cc.check_header('dlpack/dlpack.h')\n+        message('drivers/ml/cnxk: dlpack.h not found')\n+        enable_mvtvm = false\n+endif\n+\n tvmrt_lib = cc.find_library('tvm_runtime', required: false)\n if tvmrt_lib.found()\n         tvmrt_dep = declare_dependency(dependencies: tvmrt_lib)\ndiff --git a/drivers/ml/cnxk/mvtvm_ml_model.h b/drivers/ml/cnxk/mvtvm_ml_model.h\nindex d71df36f5a5..57a6ce0bb1a 100644\n--- a/drivers/ml/cnxk/mvtvm_ml_model.h\n+++ b/drivers/ml/cnxk/mvtvm_ml_model.h\n@@ -5,6 +5,8 @@\n #ifndef _MVTVM_ML_MODEL_H_\n #define _MVTVM_ML_MODEL_H_\n \n+#include <dlpack/dlpack.h>\n+\n #include <tvmdp.h>\n \n #include <rte_mldev.h>\ndiff --git a/drivers/ml/cnxk/mvtvm_ml_ops.c b/drivers/ml/cnxk/mvtvm_ml_ops.c\nindex 36616ece964..0bee5884640 100644\n--- a/drivers/ml/cnxk/mvtvm_ml_ops.c\n+++ b/drivers/ml/cnxk/mvtvm_ml_ops.c\n@@ -9,6 +9,8 @@\n #include <rte_mldev.h>\n #include <rte_mldev_pmd.h>\n \n+#include <mldev_utils.h>\n+\n #include \"cn10k_ml_ops.h\"\n \n #include \"mvtvm_ml_model.h\"\n@@ -170,6 +172,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@@ -300,3 +304,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 f6ede6229f4..3a1e97a7a08 100644\n--- a/drivers/ml/cnxk/mvtvm_ml_ops.h\n+++ b/drivers/ml/cnxk/mvtvm_ml_ops.h\n@@ -5,6 +5,8 @@\n #ifndef _MVTVM_ML_OPS_H_\n #define _MVTVM_ML_OPS_H_\n \n+#include <tvmdp.h>\n+\n #include <rte_mldev.h>\n \n struct cnxk_ml_dev;\n@@ -17,5 +19,9 @@ 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 #endif /* _MVTVM_ML_OPS_H_ */\n",
    "prefixes": [
        "v1",
        "32/34"
    ]
}