[v6,18/34] ml/cnxk: support config and close of tvmdp library

Message ID 20231018135423.14111-19-syalavarthi@marvell.com (mailing list archive)
State Changes Requested, archived
Delegated to: Jerin Jacob
Headers
Series Implementation of revised ml/cnxk driver |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Srikanth Yalavarthi Oct. 18, 2023, 1:54 p.m. UTC
  Added support to configure and close TVMDP library based
on ML device configuration options.

Updated meson build to enable Jansson, TVM runtime, TVMDP
library as build dependencies.

Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
---
 doc/guides/mldevs/cnxk.rst       | 78 ++++++++++++++++++++++++++++++++
 drivers/ml/cnxk/cnxk_ml_ops.c    |  7 +++
 drivers/ml/cnxk/cnxk_ml_ops.h    |  6 +++
 drivers/ml/cnxk/meson.build      | 59 ++++++++++++++++++++++++
 drivers/ml/cnxk/mvtvm_ml_ops.c   | 41 +++++++++++++++++
 drivers/ml/cnxk/mvtvm_ml_ops.h   | 19 ++++++++
 drivers/ml/cnxk/mvtvm_ml_stubs.c | 26 +++++++++++
 drivers/ml/cnxk/mvtvm_ml_stubs.h | 15 ++++++
 8 files changed, 251 insertions(+)
 create mode 100644 drivers/ml/cnxk/mvtvm_ml_ops.c
 create mode 100644 drivers/ml/cnxk/mvtvm_ml_ops.h
 create mode 100644 drivers/ml/cnxk/mvtvm_ml_stubs.c
 create mode 100644 drivers/ml/cnxk/mvtvm_ml_stubs.h
  

Comments

Jerin Jacob Oct. 18, 2023, 6:34 p.m. UTC | #1
On Wed, Oct 18, 2023 at 7:52 PM Srikanth Yalavarthi
<syalavarthi@marvell.com> wrote:
>
> Added support to configure and close TVMDP library based
> on ML device configuration options.
>
> Updated meson build to enable Jansson, TVM runtime, TVMDP
> library as build dependencies.
>
> Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
> ---

>
> +Compilation Prerequisites
> +-------------------------
> +
> +This driver requires external libraries to optionally enable support for
> +models compiled using Apache TVM framework. The following dependencies are
> +not part of DPDK and must be installed separately:
> +
> +- **Jansson**
> +
> +  This library enables support to parse and read JSON files.
> +
> +- **DLPack**
> +
> +  This library provides headers for open in-memory tensor structures.
> +
> +.. note::
> +
> +    DPDK CNXK ML driver requires DLPack version 0.7
> +
> +.. code-block:: console


Please add sections for cross and native.

> +    git clone https://github.com/dmlc/dlpack.git
> +    cd dlpack
> +    git checkout v0.7 -b v0.7
> +    cmake -S ./ -B build \
> +      -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
> +      -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
> +      -DBUILD_MOCK=OFF
> +    make -C build
> +    make -C build install
> +
> +- **TVM**
> +
> +  Apache TVM provides a runtime library (libtvm_runtime) used to execute
> +  models on CPU cores or hardware accelerators.
> +
> +.. note::
> +
> +    DPDK CNXK ML driver requires TVM version 0.10.0
> +
> +.. code-block:: console
> +
> +    git clone https://github.com/apache/tvm.git

I need to use --recursive to avoid
CMake Error at /usr/share/cmake/Modules/ExternalProject.cmake:3176 (message):
  No download info given for 'project_libbacktrace' and its source directory:


> +    cd tvm
> +    git checkout v0.10.0 -b v0.10.0
> +    cmake -S ./ -B build \
> +      -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
> +      -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
> +      -DMACHINE_NAME=aarch64-linux-gnu \
> +      -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
> +      -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
> +    make -C build
> +    make -C build install
> +
> +- **TVMDP**
> +
> +  Marvell's `TVM Dataplane Library <https://github.com/MarvellEmbeddedProcessors/tvmdp>`_
> +  works as an interface between TVM runtime and DPDK drivers. TVMDP library
> +  provides a simplified C interface for TVM's runtime based on C++.
> +
> +.. code-block:: console
> +
> +    git clone https://github.com/MarvellEmbeddedProcessors/tvmdp.git
> +    cd tvmdp
> +    git checkout main
> +    cmake -S ./ -B build \
> +      -DCMAKE_TOOLCHAIN_FILE=config/toolchains/arm64_linux_gcc.cmake \
> +      -DBUILD_SHARED_LIBS=ON \
> +      -DBUILD_TESTING=OFF

[main]dell[tvmdp] $ cmake -S ./ -B build
-DCMAKE_INSTALL_PREFIX=/export/cross_prefix/prefix
-DCMAKE_TOOLCHAIN_FILE=config/toolchains/arm64_linux_gcc.cmake
-DBUILD_SHARED_LIBS=ON  -DBUILD_TESTING=OFF
-- The CXX compiler identification is GNU 13.2.0
-- The C compiler identification is GNU 13.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/aarch64-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/aarch64-linux-gnu-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at CMakeLists.txt:53 (find_package):
  By not providing "Finddmlc.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "dmlc", but
  CMake did not find one.

  Could not find a package configuration file provided by "dmlc" with any of
  the following names:

    dmlcConfig.cmake
    dmlc-config.cmake

  Add the installation prefix of "dmlc" to CMAKE_PREFIX_PATH or set
  "dmlc_DIR" to a directory containing one of the above files.  If "dmlc"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!


> +enable_mvtvm = true
> +
> +if not jansson_dep.found()
> +        message('drivers/ml/cnxk: jansson not found')
> +        enable_mvtvm = false
> +endif
> +
> +if not cc.check_header('dlpack/dlpack.h')
> +        message('drivers/ml/cnxk: dlpack.h not found')
> +        enable_mvtvm = false
> +endif
> +
> +tvmrt_lib = cc.find_library('tvm_runtime', required: false)
> +if tvmrt_lib.found()
> +        tvmrt_dep = declare_dependency(dependencies: tvmrt_lib)
> +else
> +        message('drivers/ml/cnxk: tvm_runtime not found')
> +        enable_mvtvm = false
> +endif
> +
> +tvmdp_dep = dependency('tvmdp', required: false)
> +if not tvmdp_dep.found()
> +        message('drivers/ml/cnxk: tvmdp not found')
> +        enable_mvtvm = false
> +endif
> +
>  sources = files(
>          'cn10k_ml_dev.c',
>          'cn10k_ml_ops.c',
> @@ -21,6 +47,39 @@ sources = files(
>
>  deps += ['mldev', 'common_cnxk', 'kvargs', 'hash']
>
> +if enable_mvtvm
> +
> +dpdk_conf.set('RTE_MLDEV_CNXK_ENABLE_MVTVM', 1)
> +
> +driver_sdk_headers += files(
> +        'mvtvm_ml_ops.h',
> +)

Remove this
  
Srikanth Yalavarthi Oct. 19, 2023, 6:44 a.m. UTC | #2
> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: 19 October 2023 00:04
> To: Srikanth Yalavarthi <syalavarthi@marvell.com>
> Cc: dev@dpdk.org; Shivah Shankar Shankar Narayan Rao
> <sshankarnara@marvell.com>; Anup Prabhu <aprabhu@marvell.com>;
> Prince Takkar <ptakkar@marvell.com>; Srikanth Yalavarthi
> <syalavarthi@marvell.com>
> Subject: [EXT] Re: [PATCH v6 18/34] ml/cnxk: support config and close of
> tvmdp library
> 
> External Email
> 
> ----------------------------------------------------------------------
> On Wed, Oct 18, 2023 at 7:52 PM Srikanth Yalavarthi
> <syalavarthi@marvell.com> wrote:
> >
> > Added support to configure and close TVMDP library based on ML device
> > configuration options.
> >
> > Updated meson build to enable Jansson, TVM runtime, TVMDP library as
> > build dependencies.
> >
> > Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
> > ---
> 
> >
> > +Compilation Prerequisites
> > +-------------------------
> > +
> > +This driver requires external libraries to optionally enable support
> > +for models compiled using Apache TVM framework. The following
> > +dependencies are not part of DPDK and must be installed separately:
> > +
> > +- **Jansson**
> > +
> > +  This library enables support to parse and read JSON files.
> > +
> > +- **DLPack**
> > +
> > +  This library provides headers for open in-memory tensor structures.
> > +
> > +.. note::
> > +
> > +    DPDK CNXK ML driver requires DLPack version 0.7
> > +
> > +.. code-block:: console
> 
> 
> Please add sections for cross and native.
> 
> > +    git clone https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__github.com_dmlc_dlpack.git&d=DwIFaQ&c=nKjWec2b6R0mOyPaz7xtfQ
> &r=SNPqUkGl0n_Ms1iJa_6wD6LBwX8efL_NOyXvAX-
> iCMI&m=Af3Vz7Jwj42zg2TmQe6-
> BpsSzCWoeRVDxlAtzIB9e_Rtv6KG1mT0_Lq0_HnJyz1E&s=d5Yn2kMNnw-
> GyGXVRyExfsC8-Uy9S3TKnW0boz8mlsI&e=
> > +    cd dlpack
> > +    git checkout v0.7 -b v0.7
> > +    cmake -S ./ -B build \
> > +      -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
> > +      -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
> > +      -DBUILD_MOCK=OFF
> > +    make -C build
> > +    make -C build install
> > +
> > +- **TVM**
> > +
> > +  Apache TVM provides a runtime library (libtvm_runtime) used to
> > + execute  models on CPU cores or hardware accelerators.
> > +
> > +.. note::
> > +
> > +    DPDK CNXK ML driver requires TVM version 0.10.0
> > +
> > +.. code-block:: console
> > +
> > +    git clone
> > + https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__github.com_apac
> > +
> he_tvm.git&d=DwIFaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=SNPqUkGl0n_Ms1
> iJa_6wD
> > + 6LBwX8efL_NOyXvAX-iCMI&m=Af3Vz7Jwj42zg2TmQe6-
> BpsSzCWoeRVDxlAtzIB9e_R
> > + tv6KG1mT0_Lq0_HnJyz1E&s=pj_HUWALTg49rW1wRTyzB-yWSyuHzWr-
> XzPycb8UtlI&
> > + e=
> 
> I need to use --recursive to avoid
> CMake Error at /usr/share/cmake/Modules/ExternalProject.cmake:3176
> (message):
>   No download info given for 'project_libbacktrace' and its source directory:

Updated build steps in version 7. Added steps to initialize submodules.
> 
> 
> > +    cd tvm
> > +    git checkout v0.10.0 -b v0.10.0
> > +    cmake -S ./ -B build \
> > +      -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
> > +      -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
> > +      -DMACHINE_NAME=aarch64-linux-gnu \
> > +      -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
> > +      -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
> > +    make -C build
> > +    make -C build install
> > +
> > +- **TVMDP**
> > +
> > +  Marvell's `TVM Dataplane Library
> > + <https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__github.com_Mar
> > +
> vellEmbeddedProcessors_tvmdp&d=DwIFaQ&c=nKjWec2b6R0mOyPaz7xtfQ
> &r=SNPqUkGl0n_Ms1iJa_6wD6LBwX8efL_NOyXvAX-
> iCMI&m=Af3Vz7Jwj42zg2TmQe6-
> BpsSzCWoeRVDxlAtzIB9e_Rtv6KG1mT0_Lq0_HnJyz1E&s=kqu82cbMqOdusys
> dSYmp2cCwH9VTwcVvmMK0wqy04w0&e= >`_  works as an interface
> between TVM runtime and DPDK drivers. TVMDP library  provides a
> simplified C interface for TVM's runtime based on C++.
> > +
> > +.. code-block:: console
> > +
> > +    git clone https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__github.com_MarvellEmbeddedProcessors_tvmdp.git&d=DwIFaQ&c=nK
> jWec2b6R0mOyPaz7xtfQ&r=SNPqUkGl0n_Ms1iJa_6wD6LBwX8efL_NOyXvAX
> -iCMI&m=Af3Vz7Jwj42zg2TmQe6-
> BpsSzCWoeRVDxlAtzIB9e_Rtv6KG1mT0_Lq0_HnJyz1E&s=pR-
> 2iG1huVG6g7jrnjHx-nhJVQHnJWu-UJxrd6ziFx4&e=
> > +    cd tvmdp
> > +    git checkout main
> > +    cmake -S ./ -B build \
> > +      -
> DCMAKE_TOOLCHAIN_FILE=config/toolchains/arm64_linux_gcc.cmake \
> > +      -DBUILD_SHARED_LIBS=ON \
> > +      -DBUILD_TESTING=OFF
> 
> [main]dell[tvmdp] $ cmake -S ./ -B build -
> DCMAKE_INSTALL_PREFIX=/export/cross_prefix/prefix
> -DCMAKE_TOOLCHAIN_FILE=config/toolchains/arm64_linux_gcc.cmake
> -DBUILD_SHARED_LIBS=ON  -DBUILD_TESTING=OFF
> -- The CXX compiler identification is GNU 13.2.0
> -- The C compiler identification is GNU 13.2.0
> -- Detecting CXX compiler ABI info
> -- Detecting CXX compiler ABI info - done
> -- Check for working CXX compiler: /usr/bin/aarch64-linux-gnu-g++ - skipped
> -- Detecting CXX compile features
> -- Detecting CXX compile features - done
> -- Detecting C compiler ABI info
> -- Detecting C compiler ABI info - done
> -- Check for working C compiler: /usr/bin/aarch64-linux-gnu-gcc - skipped
> -- Detecting C compile features
> -- Detecting C compile features - done
> CMake Error at CMakeLists.txt:53 (find_package):
>   By not providing "Finddmlc.cmake" in CMAKE_MODULE_PATH this project
> has
>   asked CMake to find a package configuration file provided by "dmlc", but
>   CMake did not find one.
> 
>   Could not find a package configuration file provided by "dmlc" with any of
>   the following names:
> 
>     dmlcConfig.cmake
>     dmlc-config.cmake
> 
>   Add the installation prefix of "dmlc" to CMAKE_PREFIX_PATH or set
>   "dmlc_DIR" to a directory containing one of the above files.  If "dmlc"
>   provides a separate development package or SDK, be sure it has been
>   installed.
> 
> 
> -- Configuring incomplete, errors occurred!

This is bug in TVMDP CMakeLists.txt. This issue is fixed now and change is pushed to TVMDP's github repo.
> 
> 
> > +enable_mvtvm = true
> > +
> > +if not jansson_dep.found()
> > +        message('drivers/ml/cnxk: jansson not found')
> > +        enable_mvtvm = false
> > +endif
> > +
> > +if not cc.check_header('dlpack/dlpack.h')
> > +        message('drivers/ml/cnxk: dlpack.h not found')
> > +        enable_mvtvm = false
> > +endif
> > +
> > +tvmrt_lib = cc.find_library('tvm_runtime', required: false) if
> > +tvmrt_lib.found()
> > +        tvmrt_dep = declare_dependency(dependencies: tvmrt_lib) else
> > +        message('drivers/ml/cnxk: tvm_runtime not found')
> > +        enable_mvtvm = false
> > +endif
> > +
> > +tvmdp_dep = dependency('tvmdp', required: false) if not
> > +tvmdp_dep.found()
> > +        message('drivers/ml/cnxk: tvmdp not found')
> > +        enable_mvtvm = false
> > +endif
> > +
> >  sources = files(
> >          'cn10k_ml_dev.c',
> >          'cn10k_ml_ops.c',
> > @@ -21,6 +47,39 @@ sources = files(
> >
> >  deps += ['mldev', 'common_cnxk', 'kvargs', 'hash']
> >
> > +if enable_mvtvm
> > +
> > +dpdk_conf.set('RTE_MLDEV_CNXK_ENABLE_MVTVM', 1)
> > +
> > +driver_sdk_headers += files(
> > +        'mvtvm_ml_ops.h',
> > +)
> 
> Remove this
Done. Change part of version 7.
  

Patch

diff --git a/doc/guides/mldevs/cnxk.rst b/doc/guides/mldevs/cnxk.rst
index 1834b1f905..ef2b5d4581 100644
--- a/doc/guides/mldevs/cnxk.rst
+++ b/doc/guides/mldevs/cnxk.rst
@@ -46,6 +46,84 @@  or cross-compiled on an x86 platform.
 
 Refer to :doc:`../platform/cnxk` for instructions to build your DPDK application.
 
+Compilation Prerequisites
+-------------------------
+
+This driver requires external libraries to optionally enable support for
+models compiled using Apache TVM framework. The following dependencies are
+not part of DPDK and must be installed separately:
+
+- **Jansson**
+
+  This library enables support to parse and read JSON files.
+
+- **DLPack**
+
+  This library provides headers for open in-memory tensor structures.
+
+.. note::
+
+    DPDK CNXK ML driver requires DLPack version 0.7
+
+.. code-block:: console
+
+    git clone https://github.com/dmlc/dlpack.git
+    cd dlpack
+    git checkout v0.7 -b v0.7
+    cmake -S ./ -B build \
+      -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
+      -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
+      -DBUILD_MOCK=OFF
+    make -C build
+    make -C build install
+
+- **TVM**
+
+  Apache TVM provides a runtime library (libtvm_runtime) used to execute
+  models on CPU cores or hardware accelerators.
+
+.. note::
+
+    DPDK CNXK ML driver requires TVM version 0.10.0
+
+.. code-block:: console
+
+    git clone https://github.com/apache/tvm.git
+    cd tvm
+    git checkout v0.10.0 -b v0.10.0
+    cmake -S ./ -B build \
+      -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
+      -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
+      -DMACHINE_NAME=aarch64-linux-gnu \
+      -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
+      -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
+    make -C build
+    make -C build install
+
+- **TVMDP**
+
+  Marvell's `TVM Dataplane Library <https://github.com/MarvellEmbeddedProcessors/tvmdp>`_
+  works as an interface between TVM runtime and DPDK drivers. TVMDP library
+  provides a simplified C interface for TVM's runtime based on C++.
+
+.. code-block:: console
+
+    git clone https://github.com/MarvellEmbeddedProcessors/tvmdp.git
+    cd tvmdp
+    git checkout main
+    cmake -S ./ -B build \
+      -DCMAKE_TOOLCHAIN_FILE=config/toolchains/arm64_linux_gcc.cmake \
+      -DBUILD_SHARED_LIBS=ON \
+      -DBUILD_TESTING=OFF
+    make -C build
+    make -C build install
+
+- **libarchive**
+
+  Apached TVM framework generates compiled models as tar archives. This
+  library enables support to decompress and read archive files in tar,
+  xz and other formats.
+
 
 Initialization
 --------------
diff --git a/drivers/ml/cnxk/cnxk_ml_ops.c b/drivers/ml/cnxk/cnxk_ml_ops.c
index 8339f8342b..c3639320a5 100644
--- a/drivers/ml/cnxk/cnxk_ml_ops.c
+++ b/drivers/ml/cnxk/cnxk_ml_ops.c
@@ -564,6 +564,10 @@  cnxk_ml_dev_configure(struct rte_ml_dev *dev, const struct rte_ml_dev_config *co
 		goto error;
 	}
 
+	ret = mvtvm_ml_dev_configure(cnxk_mldev, conf);
+	if (ret != 0)
+		goto error;
+
 	/* Set device capabilities */
 	cnxk_mldev->max_nb_layers =
 		cnxk_mldev->cn10k_mldev.fw.req->cn10k_req.jd.fw_load.cap.s.max_models;
@@ -624,6 +628,9 @@  cnxk_ml_dev_close(struct rte_ml_dev *dev)
 	/* Un-initialize xstats */
 	cnxk_ml_xstats_uninit(cnxk_mldev);
 
+	if (mvtvm_ml_dev_close(cnxk_mldev) != 0)
+		plt_err("Failed to close MVTVM ML Device");
+
 	if (cn10k_ml_dev_close(cnxk_mldev) != 0)
 		plt_err("Failed to close CN10K ML Device");
 
diff --git a/drivers/ml/cnxk/cnxk_ml_ops.h b/drivers/ml/cnxk/cnxk_ml_ops.h
index d0c126f34b..b22a2b0d95 100644
--- a/drivers/ml/cnxk/cnxk_ml_ops.h
+++ b/drivers/ml/cnxk/cnxk_ml_ops.h
@@ -12,6 +12,12 @@ 
 
 #include "cn10k_ml_ops.h"
 
+#ifdef RTE_MLDEV_CNXK_ENABLE_MVTVM
+#include "mvtvm_ml_ops.h"
+#else
+#include "mvtvm_ml_stubs.h"
+#endif
+
 /* Request structure */
 struct cnxk_ml_req {
 	/* Device specific request */
diff --git a/drivers/ml/cnxk/meson.build b/drivers/ml/cnxk/meson.build
index 5d27a87d91..607e1c72e9 100644
--- a/drivers/ml/cnxk/meson.build
+++ b/drivers/ml/cnxk/meson.build
@@ -7,6 +7,32 @@  if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
     subdir_done()
 endif
 
+enable_mvtvm = true
+
+if not jansson_dep.found()
+        message('drivers/ml/cnxk: jansson not found')
+        enable_mvtvm = false
+endif
+
+if not cc.check_header('dlpack/dlpack.h')
+        message('drivers/ml/cnxk: dlpack.h not found')
+        enable_mvtvm = false
+endif
+
+tvmrt_lib = cc.find_library('tvm_runtime', required: false)
+if tvmrt_lib.found()
+        tvmrt_dep = declare_dependency(dependencies: tvmrt_lib)
+else
+        message('drivers/ml/cnxk: tvm_runtime not found')
+        enable_mvtvm = false
+endif
+
+tvmdp_dep = dependency('tvmdp', required: false)
+if not tvmdp_dep.found()
+        message('drivers/ml/cnxk: tvmdp not found')
+        enable_mvtvm = false
+endif
+
 sources = files(
         'cn10k_ml_dev.c',
         'cn10k_ml_ops.c',
@@ -21,6 +47,39 @@  sources = files(
 
 deps += ['mldev', 'common_cnxk', 'kvargs', 'hash']
 
+if enable_mvtvm
+
+dpdk_conf.set('RTE_MLDEV_CNXK_ENABLE_MVTVM', 1)
+
+driver_sdk_headers += files(
+        'mvtvm_ml_ops.h',
+)
+
+sources += files(
+        'mvtvm_ml_ops.c',
+)
+
+ext_deps += tvmrt_dep
+ext_deps += tvmdp_dep
+ext_deps += cc.find_library('stdc++', required: true)
+ext_deps += jansson_dep
+
+deps += ['bus_vdev']
+
+message('drivers/ml/cnxk: Enabled TVM model support')
+else
+message('drivers/ml/cnxk: Disabled TVM model support')
+
+driver_sdk_headers += files(
+        'mvtvm_ml_stubs.h',
+)
+
+sources += files(
+        'mvtvm_ml_stubs.c',
+)
+
+endif
+
 require_iova_in_mbuf = false
 
 if get_option('buildtype').contains('debug')
diff --git a/drivers/ml/cnxk/mvtvm_ml_ops.c b/drivers/ml/cnxk/mvtvm_ml_ops.c
new file mode 100644
index 0000000000..88c6d5a864
--- /dev/null
+++ b/drivers/ml/cnxk/mvtvm_ml_ops.c
@@ -0,0 +1,41 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Marvell.
+ */
+
+#include <rte_common.h>
+#include <rte_cycles.h>
+#include <rte_mldev.h>
+#include <rte_mldev_pmd.h>
+
+#include "cnxk_ml_dev.h"
+#include "cnxk_ml_ops.h"
+
+int
+mvtvm_ml_dev_configure(struct cnxk_ml_dev *cnxk_mldev, const struct rte_ml_dev_config *conf)
+{
+	int ret;
+
+	RTE_SET_USED(conf);
+
+	/* Configure TVMDP library */
+	ret = tvmdp_configure(cnxk_mldev->mldev->data->nb_models, rte_get_tsc_cycles);
+	if (ret != 0)
+		plt_err("TVMDP configuration failed, error = %d\n", ret);
+
+	return ret;
+}
+
+int
+mvtvm_ml_dev_close(struct cnxk_ml_dev *cnxk_mldev)
+{
+	int ret;
+
+	RTE_SET_USED(cnxk_mldev);
+
+	/* Close TVMDP library configuration */
+	ret = tvmdp_close();
+	if (ret != 0)
+		plt_err("TVMDP close failed, error = %d\n", ret);
+
+	return ret;
+}
diff --git a/drivers/ml/cnxk/mvtvm_ml_ops.h b/drivers/ml/cnxk/mvtvm_ml_ops.h
new file mode 100644
index 0000000000..305b4681ed
--- /dev/null
+++ b/drivers/ml/cnxk/mvtvm_ml_ops.h
@@ -0,0 +1,19 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Marvell.
+ */
+
+#ifndef _MVTVM_ML_OPS_H_
+#define _MVTVM_ML_OPS_H_
+
+#include <dlpack/dlpack.h>
+
+#include <tvmdp.h>
+
+#include <rte_mldev.h>
+
+struct cnxk_ml_dev;
+
+int mvtvm_ml_dev_configure(struct cnxk_ml_dev *cnxk_mldev, const struct rte_ml_dev_config *conf);
+int mvtvm_ml_dev_close(struct cnxk_ml_dev *cnxk_mldev);
+
+#endif /* _MVTVM_ML_OPS_H_ */
diff --git a/drivers/ml/cnxk/mvtvm_ml_stubs.c b/drivers/ml/cnxk/mvtvm_ml_stubs.c
new file mode 100644
index 0000000000..a31cd39cfa
--- /dev/null
+++ b/drivers/ml/cnxk/mvtvm_ml_stubs.c
@@ -0,0 +1,26 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Marvell.
+ */
+
+#include <rte_mldev.h>
+
+#include "mvtvm_ml_stubs.h"
+
+#include "cnxk_ml_dev.h"
+
+int
+mvtvm_ml_dev_configure(struct cnxk_ml_dev *cnxk_mldev, const struct rte_ml_dev_config *conf)
+{
+	RTE_SET_USED(cnxk_mldev);
+	RTE_SET_USED(conf);
+
+	return 0;
+}
+
+int
+mvtvm_ml_dev_close(struct cnxk_ml_dev *cnxk_mldev)
+{
+	RTE_SET_USED(cnxk_mldev);
+
+	return 0;
+}
diff --git a/drivers/ml/cnxk/mvtvm_ml_stubs.h b/drivers/ml/cnxk/mvtvm_ml_stubs.h
new file mode 100644
index 0000000000..11c56e5144
--- /dev/null
+++ b/drivers/ml/cnxk/mvtvm_ml_stubs.h
@@ -0,0 +1,15 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Marvell.
+ */
+
+#ifndef _MVTVM_ML_STUBS_H_
+#define _MVTVM_ML_STUBS_H_
+
+#include <rte_mldev.h>
+
+struct cnxk_ml_dev;
+
+int mvtvm_ml_dev_configure(struct cnxk_ml_dev *cnxk_mldev, const struct rte_ml_dev_config *conf);
+int mvtvm_ml_dev_close(struct cnxk_ml_dev *cnxk_mldev);
+
+#endif /* _MVTVM_ML_STUBS_H_ */