:orphan:

HOW TO
------



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="TVM&#x27;s Bring Your Own Codegen (BYOC) framework lets you offload parts of a model to a custom backend -- a hardware accelerator, an inference library, or your own kernels -- while TVM compiles the rest.  This tutorial has two parts:">

.. only:: html

  .. image:: /how_to/tutorials/images/thumb/sphx_glr_bring_your_own_codegen_thumb.png
    :alt:

  :doc:`/how_to/tutorials/bring_your_own_codegen`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Bring Your Own Codegen</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces cross compilation and remote device execution with RPC in TVM.">

.. only:: html

  .. image:: /how_to/tutorials/images/thumb/sphx_glr_cross_compilation_and_rpc_thumb.png
    :alt:

  :doc:`/how_to/tutorials/cross_compilation_and_rpc`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Cross Compilation and RPC</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Customize Optimization">

.. only:: html

  .. image:: /how_to/tutorials/images/thumb/sphx_glr_customize_opt_thumb.png
    :alt:

  :doc:`/how_to/tutorials/customize_opt`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Customize Optimization</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="End-to-End Optimize Model">

.. only:: html

  .. image:: /how_to/tutorials/images/thumb/sphx_glr_e2e_opt_model_thumb.png
    :alt:

  :doc:`/how_to/tutorials/e2e_opt_model`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">End-to-End Optimize Model</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This tutorial walks through exporting a compiled Relax module to a shared object, loading it back into the TVM runtime, and running the result either interactively or from a standalone script. This tutorial demonstrates how to turn Relax (or imported PyTorch / ONNX) programs into deployable artifacts using tvm.relax APIs.">

.. only:: html

  .. image:: /how_to/tutorials/images/thumb/sphx_glr_export_and_load_executable_thumb.png
    :alt:

  :doc:`/how_to/tutorials/export_and_load_executable`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Export and Load Relax Executables</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="For end-to-end optimization and deployment after importing, see optimize_model.">

.. only:: html

  .. image:: /how_to/tutorials/images/thumb/sphx_glr_import_model_thumb.png
    :alt:

  :doc:`/how_to/tutorials/import_model`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Importing Models from ML Frameworks</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="BasePyModule solves this by letting Python functions, TIR kernels, and Relax functions coexist in one module. TIR and Relax functions are JIT-compiled on instantiation, Python functions run as-is, and tensors move between TVM and PyTorch via zero-copy DLPack. This enables:">

.. only:: html

  .. image:: /how_to/tutorials/images/thumb/sphx_glr_mix_python_and_tvm_with_pymodule_thumb.png
    :alt:

  :doc:`/how_to/tutorials/mix_python_and_tvm_with_pymodule`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Mix Python/PyTorch with TVM Using BasePyModule</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Optimize Large Language Model">

.. only:: html

  .. image:: /how_to/tutorials/images/thumb/sphx_glr_optimize_llm_thumb.png
    :alt:

  :doc:`/how_to/tutorials/optimize_llm`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Optimize Large Language Model</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /how_to/tutorials/bring_your_own_codegen
   /how_to/tutorials/cross_compilation_and_rpc
   /how_to/tutorials/customize_opt
   /how_to/tutorials/e2e_opt_model
   /how_to/tutorials/export_and_load_executable
   /how_to/tutorials/import_model
   /how_to/tutorials/mix_python_and_tvm_with_pymodule
   /how_to/tutorials/optimize_llm

