zhiics commented on a change in pull request #6343:
URL: https://github.com/apache/incubator-tvm/pull/6343#discussion_r479815587



##########
File path: cmake/modules/contrib/VITISAI.cmake
##########
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+if(USE_VITIS_AI)
+  set(PYXIR_SHARED_LIB libpyxir.so)
+  find_package(PythonInterp 3.6 REQUIRED)
+  if(NOT PYTHON)
+    find_program(PYTHON NAMES python3 python3.6)
+  endif()
+  if(PYTHON)

Review comment:
       else()?

##########
File path: src/runtime/contrib/vitis_ai/vitis_ai_runtime.h
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \brief Vitis-AI runtime that can run model
+ *        containing only tvm PackedFunc.
+ * \file vitis_ai_runtime.h
+ */
+#ifndef TVM_RUNTIME_CONTRIB_VITIS_AI_RUNTIME_H_
+#define TVM_RUNTIME_CONTRIB_VITIS_AI_RUNTIME_H_
+
+
+#include <dlpack/dlpack.h>
+#include <tvm/runtime/ndarray.h>
+#include <tvm/runtime/packed_func.h>
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include<pyxir/pyxir.hpp>
+#include <pyxir/runtime/run_options.hpp>
+
+
+
+namespace tvm {
+namespace runtime {
+
+/*!
+ * \brief VAI runtime.
+ *
+ *  This runtime can be accessed in various language via
+ *  TVM runtime PackedFunc API.
+ */
+class VitisAIRuntime : public ModuleNode {
+ public:
+VitisAIRuntime(const std::string& symbol_name, const Array<String> 
const_names):
+  symbol_name_(symbol_name), const_names_(const_names) {}
+  /*!
+   * \brief Get member function to front-end.
+   * \param name The name of the function.
+   * \param sptr_to_self The pointer to the module node.
+   * \return The corresponding member function.
+   */
+  virtual PackedFunc GetFunction(const std::string& name, const 
ObjectPtr<Object>& sptr_to_self);
+  /*!
+   * \return The type key of the executor.
+   */
+  const char* type_key() const { return "VitisAIRuntime"; }
+
+  /*!
+   * \brief Initialize the vai runtime with pyxir.
+   * \param model_path The compiled model path.
+   * \param target The name of the target being used
+   */
+void Init(const std::string& model_path, const std::string& target);
+  /*!
+   * \brief Serialize the content of the pyxir directory and save it to
+   *        binary stream.
+   * \param stream The binary stream to save to.
+   */
+  void SaveToBinary(dmlc::Stream* stream) final;
+
+ private:
+  /*! \brief The only subgraph name for this module. */
+  std::string symbol_name_;
+  /*! \brief The graph. */
+  std::string graph_json_;

Review comment:
       This seems unused. This class looks like similar to the json runtime. 
Are we doing something similar?

##########
File path: docs/deploy/vitis_ai.rst
##########
@@ -0,0 +1,671 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+
+Vitis-AI Integration
+====================
+
+`Vitis-AI <https://github.com/Xilinx/Vitis-AI>`__ is Xilinx's
+development stack for hardware-accelerated AI inference on Xilinx
+platforms, including both edge devices and Alveo cards. It consists of
+optimized IP, tools, libraries, models, and example designs. It is
+designed with high efficiency and ease of use in mind, unleashing the
+full potential of AI acceleration on Xilinx FPGA and ACAP.
+
+The current Vitis-AI Byoc flow inside TVM enables acceleration of Neural
+Network model inference on edge and cloud. The identifiers for the
+supported edge and cloud Deep Learning Processor Units (DPU's) are
+DPUCZDX8G respectively DPUCADX8G. DPUCZDX8G and DPUCADX8G are hardware
+accelerators for convolutional neural networks (CNN's) on top of the
+Xilinx `Zynq Ultrascale+
+MPSoc 
<https://www.xilinx.com/products/silicon-devices/soc/zynq-ultrascale-mpsoc.html>`__
+respectively
+`Alveo <https://www.xilinx.com/products/boards-and-kits/alveo.html>`__
+(U200/U250) platforms. For more information about the DPU identifiers
+see the section on `DPU naming information <#dpu-naming-information>`__.
+
+On this page you will find information on how to
+`build <#build-instructions>`__ TVM with Vitis-AI and on how to `get
+started <#getting-started>`__ with an example.
+
+DPU naming information
+----------------------
+
++---------------------------------+-----------------+-------------------------------------------------------------------------+------------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------+
+| DPU                             | Application     | HW Platform              
                                               | Quantization Method            
                            | Quantization Bitwidth                             
| Design Target                                                            |
++=================================+=================+=========================================================================+============================================================+===================================================+==========================================================================+
+| Deep Learning Processing Unit   | C: CNN R: RNN   | AD: Alveo DDR AH: Alveo 
HBM VD: Versal DDR with AIE & PL ZD: Zynq DDR   | X: DECENT I: Integer 
threshold F: Float threshold R: RNN   | 4: 4-bit 8: 8-bit 16: 16-bit M: Mixed 
Precision   | G: General purpose H: High throughput L: Low latency C: Cost 
optimized   |
++---------------------------------+-----------------+-------------------------------------------------------------------------+------------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------+
+
+Build instructions
+------------------
+
+This section lists the instructions for building TVM with Vitis-AI for
+both `cloud <#cloud-dpucadx8g>`__ and `edge <#edge-dpuczdx8g>`__.
+
+Cloud (DPUCADX8G)
+~~~~~~~~~~~~~~~~~
+
+For Vitis-AI acceleration in the cloud TVM has to be built on top of the
+Xilinx Alveo platform.
+
+System requirements
+^^^^^^^^^^^^^^^^^^^
+
+The following table lists system requirements for running docker
+containers as well as Alveo cards.
+
++-----------------------------------------------------+----------------------------------------------------------+
+| **Component**                                       | **Requirement**        
                                  |
++=====================================================+==========================================================+
+| Motherboard                                         | PCI Express 
3.0-compliant with one dual-width x16 slot   |
++-----------------------------------------------------+----------------------------------------------------------+
+| System Power Supply                                 | 225W                   
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| Operating System                                    | Ubuntu 16.04, 18.04    
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+|                                                     | CentOS 7.4, 7.5        
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+|                                                     | RHEL 7.4, 7.5          
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| CPU                                                 | Intel i3/i5/i7/i9/Xeon 
64-bit CPU                        |
++-----------------------------------------------------+----------------------------------------------------------+
+| GPU (Optional to accelerate quantization)           | NVIDIA GPU with a 
compute capability > 3.0               |
++-----------------------------------------------------+----------------------------------------------------------+
+| CUDA Driver (Optional to accelerate quantization)   | nvidia-410             
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| FPGA                                                | Xilinx Alveo U200 or 
U250                                |
++-----------------------------------------------------+----------------------------------------------------------+
+| Docker Version                                      | 19.03.1                
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+
+Hardware setup and docker build
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1. Clone the Vitis AI repository:
+
+   .. code:: bash
+
+   git clone --recurse-submodules https://github.com/Xilinx/Vitis-AI
+   
+2. Install Docker, and add the user to the docker group. Link the user
+   to docker installation instructions from the following docker's
+   website:
+   
+
+   -  https://docs.docker.com/install/linux/docker-ce/ubuntu/
+   -  https://docs.docker.com/install/linux/docker-ce/centos/
+   -  https://docs.docker.com/install/linux/linux-postinstall/
+
+3. Download the latest Vitis AI Docker with the following command. This 
container runs on CPU.
+
+   .. code:: bash
+   

Review comment:
       remove one newline to keep consistent with other code blocks?

##########
File path: docs/deploy/vitis_ai.rst
##########
@@ -0,0 +1,671 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+
+Vitis-AI Integration
+====================
+
+`Vitis-AI <https://github.com/Xilinx/Vitis-AI>`__ is Xilinx's
+development stack for hardware-accelerated AI inference on Xilinx
+platforms, including both edge devices and Alveo cards. It consists of
+optimized IP, tools, libraries, models, and example designs. It is
+designed with high efficiency and ease of use in mind, unleashing the
+full potential of AI acceleration on Xilinx FPGA and ACAP.
+
+The current Vitis-AI Byoc flow inside TVM enables acceleration of Neural
+Network model inference on edge and cloud. The identifiers for the
+supported edge and cloud Deep Learning Processor Units (DPU's) are
+DPUCZDX8G respectively DPUCADX8G. DPUCZDX8G and DPUCADX8G are hardware
+accelerators for convolutional neural networks (CNN's) on top of the
+Xilinx `Zynq Ultrascale+
+MPSoc 
<https://www.xilinx.com/products/silicon-devices/soc/zynq-ultrascale-mpsoc.html>`__
+respectively
+`Alveo <https://www.xilinx.com/products/boards-and-kits/alveo.html>`__
+(U200/U250) platforms. For more information about the DPU identifiers
+see the section on `DPU naming information <#dpu-naming-information>`__.
+
+On this page you will find information on how to
+`build <#build-instructions>`__ TVM with Vitis-AI and on how to `get
+started <#getting-started>`__ with an example.
+
+DPU naming information
+----------------------
+
++---------------------------------+-----------------+-------------------------------------------------------------------------+------------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------+
+| DPU                             | Application     | HW Platform              
                                               | Quantization Method            
                            | Quantization Bitwidth                             
| Design Target                                                            |
++=================================+=================+=========================================================================+============================================================+===================================================+==========================================================================+
+| Deep Learning Processing Unit   | C: CNN R: RNN   | AD: Alveo DDR AH: Alveo 
HBM VD: Versal DDR with AIE & PL ZD: Zynq DDR   | X: DECENT I: Integer 
threshold F: Float threshold R: RNN   | 4: 4-bit 8: 8-bit 16: 16-bit M: Mixed 
Precision   | G: General purpose H: High throughput L: Low latency C: Cost 
optimized   |
++---------------------------------+-----------------+-------------------------------------------------------------------------+------------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------+
+
+Build instructions
+------------------
+
+This section lists the instructions for building TVM with Vitis-AI for
+both `cloud <#cloud-dpucadx8g>`__ and `edge <#edge-dpuczdx8g>`__.
+
+Cloud (DPUCADX8G)
+~~~~~~~~~~~~~~~~~
+
+For Vitis-AI acceleration in the cloud TVM has to be built on top of the
+Xilinx Alveo platform.
+
+System requirements
+^^^^^^^^^^^^^^^^^^^
+
+The following table lists system requirements for running docker
+containers as well as Alveo cards.
+
++-----------------------------------------------------+----------------------------------------------------------+
+| **Component**                                       | **Requirement**        
                                  |
++=====================================================+==========================================================+
+| Motherboard                                         | PCI Express 
3.0-compliant with one dual-width x16 slot   |
++-----------------------------------------------------+----------------------------------------------------------+
+| System Power Supply                                 | 225W                   
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| Operating System                                    | Ubuntu 16.04, 18.04    
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+|                                                     | CentOS 7.4, 7.5        
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+|                                                     | RHEL 7.4, 7.5          
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| CPU                                                 | Intel i3/i5/i7/i9/Xeon 
64-bit CPU                        |
++-----------------------------------------------------+----------------------------------------------------------+
+| GPU (Optional to accelerate quantization)           | NVIDIA GPU with a 
compute capability > 3.0               |
++-----------------------------------------------------+----------------------------------------------------------+
+| CUDA Driver (Optional to accelerate quantization)   | nvidia-410             
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| FPGA                                                | Xilinx Alveo U200 or 
U250                                |
++-----------------------------------------------------+----------------------------------------------------------+
+| Docker Version                                      | 19.03.1                
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+
+Hardware setup and docker build
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1. Clone the Vitis AI repository:
+
+   .. code:: bash
+
+   git clone --recurse-submodules https://github.com/Xilinx/Vitis-AI
+   
+2. Install Docker, and add the user to the docker group. Link the user
+   to docker installation instructions from the following docker's
+   website:
+   
+
+   -  https://docs.docker.com/install/linux/docker-ce/ubuntu/
+   -  https://docs.docker.com/install/linux/docker-ce/centos/
+   -  https://docs.docker.com/install/linux/linux-postinstall/
+
+3. Download the latest Vitis AI Docker with the following command. This 
container runs on CPU.
+
+   .. code:: bash
+   
+   
+      docker pull xilinx/vitis-ai:latest
+    
+   To accelerate the quantization, you can optionally use the Vitis-AI GPU 
docker image. Use the below commands to build the Vitis-AI GPU docker container:
+   
+    
+   .. code:: bash
+    
+    
+    cd Vitis-AI/docker
+    ./docker_build_gpu.sh
+
+
+4. Set up Vitis AI to target Alveo cards. To target Alveo cards with
+   Vitis AI for machine learning workloads, you must install the
+   following software components:
+
+   -  Xilinx Runtime (XRT)
+   -  Alveo Deployment Shells (DSAs)
+   -  Xilinx Resource Manager (XRM) (xbutler)
+   -  Xilinx Overlaybins (Accelerators to Dynamically Load - binary
+      programming files)
+
+   While it is possible to install all of these software components
+   individually, a script has been provided to automatically install
+   them at once. To do so:
+
+   -  Run the following commands:
+   .. code:: bash
+      
+      cd Vitis-AI/alveo/packages
+      sudo su
+      ./install.sh
+      
+   -  Power cycle the system.
+   
+5. Clone tvm repo and pyxir repo
+
+   .. code:: bash
+   
+   
+      git clone --recursive https://github.com/apache/incubator-tvm.git
+      git clone --recursive https://github.com/Xilinx/pyxir.git
+   
+6. Build and start the tvm runtime Vitis-AI Docker Container.
+
+   .. code:: bash
+
+      bash incubator-tvm/docker/build.sh demo_vitis_ai bash
+      bash incubator-tvm/docker/bash.sh tvm.demo_vitis_ai
+         
+      #Setup inside container
+      source /opt/xilinx/xrt/setup.sh
+      . $VAI_ROOT/conda/etc/profile.d/conda.sh
+      conda activate vitis-ai-tensorflow
+      
+7. Install PyXIR
+
+   .. code:: bash
+
+     cd pyxir
+     python3 setup.py install --use_vai_rt_dpucadx8g --user
+
+   
+8. Build TVM inside the container with Vitis-AI
+
+   .. code:: bash
+
+
+      cd incubator-tvm
+      mkdir build
+      cp cmake/config.cmake build
+      cd build  
+      echo set\(USE_LLVM ON\) >> config.cmake
+      echo set\(USE_VITIS_AI ON\) >> config.cmake
+      cmake ..
+      make -j$(nproc)
+   
+9.  Install TVM
+
+    .. code:: bash
+
+      cd incubator-tvm/python
+      pip3 install -e . --user
+      
+Edge (DPUCZDX8G)
+^^^^^^^^^^^^^^^^
+
+
+For edge deployment we make use of two systems referred to as host and
+edge. The `host <#host-requirements>`__ system is responsible for
+quantization and compilation of the neural network model in a first
+offline step. Afterwards, the model will de deployed on the
+`edge <#edge-requirements>`__ system.
+
+Host requirements
+^^^^^^^^^^^^^^^^^
+
+The following table lists system requirements for running the TVM -
+Vitis-AI docker container.
+
++-----------------------------------------------------+----------------------------------------------+
+| **Component**                                       | **Requirement**        
                      |
++=====================================================+==============================================+
+| Operating System                                    | Ubuntu 16.04, 18.04    
                      |
++-----------------------------------------------------+----------------------------------------------+
+|                                                     | CentOS 7.4, 7.5        
                      |
++-----------------------------------------------------+----------------------------------------------+
+|                                                     | RHEL 7.4, 7.5          
                      |
++-----------------------------------------------------+----------------------------------------------+
+| CPU                                                 | Intel i3/i5/i7/i9/Xeon 
64-bit CPU            |
++-----------------------------------------------------+----------------------------------------------+
+| GPU (Optional to accelerate quantization)           | NVIDIA GPU with a 
compute capability > 3.0   |
++-----------------------------------------------------+----------------------------------------------+
+| CUDA Driver (Optional to accelerate quantization)   | nvidia-410             
                      |
++-----------------------------------------------------+----------------------------------------------+
+| FPGA                                                | Not necessary on host  
                      |
++-----------------------------------------------------+----------------------------------------------+
+| Docker Version                                      | 19.03.1                
                      |
++-----------------------------------------------------+----------------------------------------------+
+
+Host setup and docker build
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1. Clone tvm repo
+
+   .. code:: bash
+
+      git clone --recursive https://github.com/apache/incubator-tvm.git
+2. Build and start the tvm runtime Vitis-AI Docker Container.
+
+   .. code:: bash
+
+      cd incubator-tvm 
+      bash incubator-tvm/docker/build.sh demo_vitis_ai bash
+      bash incubator-tvm/docker/bash.sh tvm.demo_vitis_ai
+   
+      #Setup inside container
+      . $VAI_ROOT/conda/etc/profile.d/conda.sh
+      conda activate vitis-ai-tensorflow
+   
+3. Install PyXIR
+
+   .. code:: bash
+

Review comment:
       ditto

##########
File path: docker/install/ubuntu_install_python.sh
##########
@@ -1,40 +0,0 @@
-#!/bin/bash

Review comment:
       why remove this file?

##########
File path: docker/bash.sh
##########
@@ -1,113 +0,0 @@
-#!/usr/bin/env bash

Review comment:
       why remove this file?

##########
File path: cmake/modules/contrib/VITISAI.cmake
##########
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+if(USE_VITIS_AI)
+  set(PYXIR_SHARED_LIB libpyxir.so)
+  find_package(PythonInterp 3.6 REQUIRED)

Review comment:
       Does it only work for Python 3.6?

##########
File path: docs/deploy/vitis_ai.rst
##########
@@ -0,0 +1,671 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+
+Vitis-AI Integration
+====================
+
+`Vitis-AI <https://github.com/Xilinx/Vitis-AI>`__ is Xilinx's
+development stack for hardware-accelerated AI inference on Xilinx
+platforms, including both edge devices and Alveo cards. It consists of
+optimized IP, tools, libraries, models, and example designs. It is
+designed with high efficiency and ease of use in mind, unleashing the
+full potential of AI acceleration on Xilinx FPGA and ACAP.
+
+The current Vitis-AI Byoc flow inside TVM enables acceleration of Neural
+Network model inference on edge and cloud. The identifiers for the
+supported edge and cloud Deep Learning Processor Units (DPU's) are
+DPUCZDX8G respectively DPUCADX8G. DPUCZDX8G and DPUCADX8G are hardware
+accelerators for convolutional neural networks (CNN's) on top of the
+Xilinx `Zynq Ultrascale+
+MPSoc 
<https://www.xilinx.com/products/silicon-devices/soc/zynq-ultrascale-mpsoc.html>`__
+respectively
+`Alveo <https://www.xilinx.com/products/boards-and-kits/alveo.html>`__
+(U200/U250) platforms. For more information about the DPU identifiers
+see the section on `DPU naming information <#dpu-naming-information>`__.
+
+On this page you will find information on how to
+`build <#build-instructions>`__ TVM with Vitis-AI and on how to `get
+started <#getting-started>`__ with an example.
+
+DPU naming information
+----------------------
+
++---------------------------------+-----------------+-------------------------------------------------------------------------+------------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------+
+| DPU                             | Application     | HW Platform              
                                               | Quantization Method            
                            | Quantization Bitwidth                             
| Design Target                                                            |
++=================================+=================+=========================================================================+============================================================+===================================================+==========================================================================+
+| Deep Learning Processing Unit   | C: CNN R: RNN   | AD: Alveo DDR AH: Alveo 
HBM VD: Versal DDR with AIE & PL ZD: Zynq DDR   | X: DECENT I: Integer 
threshold F: Float threshold R: RNN   | 4: 4-bit 8: 8-bit 16: 16-bit M: Mixed 
Precision   | G: General purpose H: High throughput L: Low latency C: Cost 
optimized   |
++---------------------------------+-----------------+-------------------------------------------------------------------------+------------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------+
+
+Build instructions
+------------------
+
+This section lists the instructions for building TVM with Vitis-AI for
+both `cloud <#cloud-dpucadx8g>`__ and `edge <#edge-dpuczdx8g>`__.
+
+Cloud (DPUCADX8G)
+~~~~~~~~~~~~~~~~~
+
+For Vitis-AI acceleration in the cloud TVM has to be built on top of the
+Xilinx Alveo platform.
+
+System requirements
+^^^^^^^^^^^^^^^^^^^
+
+The following table lists system requirements for running docker
+containers as well as Alveo cards.
+
++-----------------------------------------------------+----------------------------------------------------------+
+| **Component**                                       | **Requirement**        
                                  |
++=====================================================+==========================================================+
+| Motherboard                                         | PCI Express 
3.0-compliant with one dual-width x16 slot   |
++-----------------------------------------------------+----------------------------------------------------------+
+| System Power Supply                                 | 225W                   
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| Operating System                                    | Ubuntu 16.04, 18.04    
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+|                                                     | CentOS 7.4, 7.5        
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+|                                                     | RHEL 7.4, 7.5          
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| CPU                                                 | Intel i3/i5/i7/i9/Xeon 
64-bit CPU                        |
++-----------------------------------------------------+----------------------------------------------------------+
+| GPU (Optional to accelerate quantization)           | NVIDIA GPU with a 
compute capability > 3.0               |
++-----------------------------------------------------+----------------------------------------------------------+
+| CUDA Driver (Optional to accelerate quantization)   | nvidia-410             
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| FPGA                                                | Xilinx Alveo U200 or 
U250                                |
++-----------------------------------------------------+----------------------------------------------------------+
+| Docker Version                                      | 19.03.1                
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+
+Hardware setup and docker build
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1. Clone the Vitis AI repository:
+
+   .. code:: bash
+
+   git clone --recurse-submodules https://github.com/Xilinx/Vitis-AI
+   
+2. Install Docker, and add the user to the docker group. Link the user
+   to docker installation instructions from the following docker's
+   website:
+   
+
+   -  https://docs.docker.com/install/linux/docker-ce/ubuntu/
+   -  https://docs.docker.com/install/linux/docker-ce/centos/
+   -  https://docs.docker.com/install/linux/linux-postinstall/
+
+3. Download the latest Vitis AI Docker with the following command. This 
container runs on CPU.
+
+   .. code:: bash
+   
+   
+      docker pull xilinx/vitis-ai:latest
+    
+   To accelerate the quantization, you can optionally use the Vitis-AI GPU 
docker image. Use the below commands to build the Vitis-AI GPU docker container:
+   
+    
+   .. code:: bash
+    
+    
+    cd Vitis-AI/docker
+    ./docker_build_gpu.sh
+
+
+4. Set up Vitis AI to target Alveo cards. To target Alveo cards with
+   Vitis AI for machine learning workloads, you must install the
+   following software components:
+
+   -  Xilinx Runtime (XRT)
+   -  Alveo Deployment Shells (DSAs)
+   -  Xilinx Resource Manager (XRM) (xbutler)
+   -  Xilinx Overlaybins (Accelerators to Dynamically Load - binary
+      programming files)
+
+   While it is possible to install all of these software components
+   individually, a script has been provided to automatically install
+   them at once. To do so:
+
+   -  Run the following commands:
+   .. code:: bash
+      
+      cd Vitis-AI/alveo/packages
+      sudo su
+      ./install.sh
+      
+   -  Power cycle the system.
+   
+5. Clone tvm repo and pyxir repo
+
+   .. code:: bash
+   

Review comment:
       ditto
   
   This applies to several other places in this file as well.

##########
File path: python/tvm/contrib/target/vitis_ai.py
##########
@@ -0,0 +1,116 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# pylint: disable=invalid-name, unused-argument, import-outside-toplevel
+"""Utility to compile Vitis-AI models"""
+
+import os
+
+from tvm.relay.expr import Tuple, Call, TupleGetItem
+import tvm._ffi
+
+import pyxir
+import pyxir.frontend.tvm
+
+
+class CodegenVitisAI:
+    """
+    Traverse Relay expression and convert into PyXIR XGraph format
+    """
+    def __init__(self, model_name, function):
+        self.model_name = model_name
+        self.function = function
+        self.params = {}
+
+    def convert_pyxir(self, target):

Review comment:
       Can we rely on relay's annotation and partitioning, and then offload the 
partitioned graph to pyxir?

##########
File path: docs/deploy/vitis_ai.rst
##########
@@ -0,0 +1,671 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+
+Vitis-AI Integration
+====================
+
+`Vitis-AI <https://github.com/Xilinx/Vitis-AI>`__ is Xilinx's
+development stack for hardware-accelerated AI inference on Xilinx
+platforms, including both edge devices and Alveo cards. It consists of
+optimized IP, tools, libraries, models, and example designs. It is
+designed with high efficiency and ease of use in mind, unleashing the
+full potential of AI acceleration on Xilinx FPGA and ACAP.
+
+The current Vitis-AI Byoc flow inside TVM enables acceleration of Neural
+Network model inference on edge and cloud. The identifiers for the
+supported edge and cloud Deep Learning Processor Units (DPU's) are
+DPUCZDX8G respectively DPUCADX8G. DPUCZDX8G and DPUCADX8G are hardware
+accelerators for convolutional neural networks (CNN's) on top of the
+Xilinx `Zynq Ultrascale+
+MPSoc 
<https://www.xilinx.com/products/silicon-devices/soc/zynq-ultrascale-mpsoc.html>`__
+respectively
+`Alveo <https://www.xilinx.com/products/boards-and-kits/alveo.html>`__
+(U200/U250) platforms. For more information about the DPU identifiers
+see the section on `DPU naming information <#dpu-naming-information>`__.
+
+On this page you will find information on how to
+`build <#build-instructions>`__ TVM with Vitis-AI and on how to `get
+started <#getting-started>`__ with an example.
+
+DPU naming information
+----------------------
+
++---------------------------------+-----------------+-------------------------------------------------------------------------+------------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------+
+| DPU                             | Application     | HW Platform              
                                               | Quantization Method            
                            | Quantization Bitwidth                             
| Design Target                                                            |
++=================================+=================+=========================================================================+============================================================+===================================================+==========================================================================+
+| Deep Learning Processing Unit   | C: CNN R: RNN   | AD: Alveo DDR AH: Alveo 
HBM VD: Versal DDR with AIE & PL ZD: Zynq DDR   | X: DECENT I: Integer 
threshold F: Float threshold R: RNN   | 4: 4-bit 8: 8-bit 16: 16-bit M: Mixed 
Precision   | G: General purpose H: High throughput L: Low latency C: Cost 
optimized   |
++---------------------------------+-----------------+-------------------------------------------------------------------------+------------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------+
+
+Build instructions
+------------------
+
+This section lists the instructions for building TVM with Vitis-AI for
+both `cloud <#cloud-dpucadx8g>`__ and `edge <#edge-dpuczdx8g>`__.
+
+Cloud (DPUCADX8G)
+~~~~~~~~~~~~~~~~~
+
+For Vitis-AI acceleration in the cloud TVM has to be built on top of the
+Xilinx Alveo platform.
+
+System requirements
+^^^^^^^^^^^^^^^^^^^
+
+The following table lists system requirements for running docker
+containers as well as Alveo cards.
+
++-----------------------------------------------------+----------------------------------------------------------+
+| **Component**                                       | **Requirement**        
                                  |
++=====================================================+==========================================================+
+| Motherboard                                         | PCI Express 
3.0-compliant with one dual-width x16 slot   |
++-----------------------------------------------------+----------------------------------------------------------+
+| System Power Supply                                 | 225W                   
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| Operating System                                    | Ubuntu 16.04, 18.04    
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+|                                                     | CentOS 7.4, 7.5        
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+|                                                     | RHEL 7.4, 7.5          
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| CPU                                                 | Intel i3/i5/i7/i9/Xeon 
64-bit CPU                        |
++-----------------------------------------------------+----------------------------------------------------------+
+| GPU (Optional to accelerate quantization)           | NVIDIA GPU with a 
compute capability > 3.0               |
++-----------------------------------------------------+----------------------------------------------------------+
+| CUDA Driver (Optional to accelerate quantization)   | nvidia-410             
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| FPGA                                                | Xilinx Alveo U200 or 
U250                                |
++-----------------------------------------------------+----------------------------------------------------------+
+| Docker Version                                      | 19.03.1                
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+
+Hardware setup and docker build
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1. Clone the Vitis AI repository:
+
+   .. code:: bash
+
+   git clone --recurse-submodules https://github.com/Xilinx/Vitis-AI
+   
+2. Install Docker, and add the user to the docker group. Link the user
+   to docker installation instructions from the following docker's
+   website:
+   
+
+   -  https://docs.docker.com/install/linux/docker-ce/ubuntu/
+   -  https://docs.docker.com/install/linux/docker-ce/centos/
+   -  https://docs.docker.com/install/linux/linux-postinstall/
+
+3. Download the latest Vitis AI Docker with the following command. This 
container runs on CPU.
+
+   .. code:: bash
+   
+   
+      docker pull xilinx/vitis-ai:latest
+    
+   To accelerate the quantization, you can optionally use the Vitis-AI GPU 
docker image. Use the below commands to build the Vitis-AI GPU docker container:
+   
+    
+   .. code:: bash
+    

Review comment:
       remove one newline?

##########
File path: src/runtime/contrib/vitis_ai/vitis_ai_runtime.cc
##########
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file vitis_ai_runtime.cc
+ */
+#include <tvm/runtime/registry.h>
+#include <tvm/ir/transform.h>
+
+#include "vitis_ai_runtime.h"
+
+namespace tvm {
+namespace runtime {
+
+TVM_REGISTER_PASS_CONFIG_OPTION("relay.ext.vitis_ai.options.target", String);
+TVM_REGISTER_PASS_CONFIG_OPTION("relay.ext.vitis_ai.options.build_dir", 
String);
+
+std::shared_ptr<pyxir::graph::XGraph> load_xgraph_model(const std::string& 
model_path) {
+  std::string model_name = model_path + "/" + "dpu_xgraph.json";
+  std::string model_weights = model_path + "/" + "dpu_xgraph.h5";
+  return pyxir::load(model_name, model_weights);
+}
+
+void VitisAIRuntime::Init(const std::string& model_path, const std::string& 
target) {
+  model_path_ = model_path;
+  target_ = target;
+  xgraph_ = load_xgraph_model(model_path_);
+  in_tensor_names_ = xgraph_->get_input_names();
+  out_tensor_names_ =  xgraph_->get_meta_attr("tvm_out_tensors").get_strings();
+  pyxir::partition(xgraph_, std::vector<std::string>{target}, "");
+  pyxir::RunOptionsHolder run_options(new pyxir::runtime::RunOptions());
+  run_options->on_the_fly_quantization = true;
+  rt_mod_ = pyxir::build_rt(xgraph_, target_ , in_tensor_names_, 
out_tensor_names_,
+                                                                "vai", 
run_options);
+}
+
+
+Module VitisAIRuntimeCreate(const std::string& name,
+                            const std::string& model_path,
+                            const std::string& target) {
+  Array<String> const_vars;
+  auto exec = make_object<VitisAIRuntime>(name, const_vars);
+  exec->Init(model_path, target);
+  return Module(exec);
+}
+
+
+
+TVM_REGISTER_GLOBAL("tvm.vitis_ai_runtime.create").set_body([](TVMArgs args, 
TVMRetValue* rv) {
+  *rv = VitisAIRuntimeCreate(args[0], args[1], args[2]);
+});
+
+Module VitisAIRuntimeLoadFromBinary(void* strm ) {
+    dmlc::Stream* stream = static_cast<dmlc::Stream*>(strm);
+
+    std::string model_path;
+    std::string symbol_name;
+    std::vector<std::string> const_vars;
+    std::string target;
+    stream->Read(&model_path);
+    stream->Read(&target);
+    stream->Read(&symbol_name);
+    stream->Read(&const_vars);
+    Array<String> const_names;
+    for (const auto& it : const_vars) {
+      const_names.push_back(it);
+    }
+    auto exec = make_object<VitisAIRuntime>(symbol_name, const_names);
+    exec->Init(model_path, target);
+    return Module(exec);
+  }
+
+TVM_REGISTER_GLOBAL("runtime.module.loadbinary_VitisAIRuntime")
+                  .set_body_typed(VitisAIRuntimeLoadFromBinary);
+
+void VitisAIRuntime::SaveToBinary(dmlc::Stream* stream)  {
+  stream->Write(this-> model_path_);
+  stream->Write(this-> target_);
+  stream->Write(this->symbol_name_);
+  std::vector<std::string> consts;
+  for (const auto& it : const_names_) {
+    consts.push_back(it);
+    }
+  stream->Write(consts);
+  }
+
+
+PackedFunc VitisAIRuntime::GetFunction(const std::string& name,
+                                      const ObjectPtr<Object>& sptr_to_self) {
+  if (name == "get_symbol") {
+      return PackedFunc(
+          [sptr_to_self, this](TVMArgs args, TVMRetValue* rv) { *rv = 
this->symbol_name_; });
+    } else if (name == "get_const_vars") {
+      return PackedFunc(
+          [sptr_to_self, this](TVMArgs args, TVMRetValue* rv) { *rv = 
this->const_names_; });
+    } else if ("__init_" + this->symbol_name_ == name) {
+      // The function to initialize constant tensors.
+      return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
+        CHECK_EQ(args.size(), 1U);
+        this->initialized_ = true;
+        *rv = 0;
+      });
+    } else {

Review comment:
       what's the handle for this? It seems this is for execution.  I think you 
need to have a check here, e.g. `if (name == "xxx")`. Otherwise, we may return 
a wrong packed function.

##########
File path: docs/deploy/vitis_ai.rst
##########
@@ -0,0 +1,671 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+
+Vitis-AI Integration
+====================
+
+`Vitis-AI <https://github.com/Xilinx/Vitis-AI>`__ is Xilinx's
+development stack for hardware-accelerated AI inference on Xilinx
+platforms, including both edge devices and Alveo cards. It consists of
+optimized IP, tools, libraries, models, and example designs. It is
+designed with high efficiency and ease of use in mind, unleashing the
+full potential of AI acceleration on Xilinx FPGA and ACAP.
+
+The current Vitis-AI Byoc flow inside TVM enables acceleration of Neural
+Network model inference on edge and cloud. The identifiers for the
+supported edge and cloud Deep Learning Processor Units (DPU's) are
+DPUCZDX8G respectively DPUCADX8G. DPUCZDX8G and DPUCADX8G are hardware
+accelerators for convolutional neural networks (CNN's) on top of the
+Xilinx `Zynq Ultrascale+
+MPSoc 
<https://www.xilinx.com/products/silicon-devices/soc/zynq-ultrascale-mpsoc.html>`__
+respectively
+`Alveo <https://www.xilinx.com/products/boards-and-kits/alveo.html>`__
+(U200/U250) platforms. For more information about the DPU identifiers
+see the section on `DPU naming information <#dpu-naming-information>`__.
+
+On this page you will find information on how to
+`build <#build-instructions>`__ TVM with Vitis-AI and on how to `get
+started <#getting-started>`__ with an example.
+
+DPU naming information
+----------------------
+
++---------------------------------+-----------------+-------------------------------------------------------------------------+------------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------+
+| DPU                             | Application     | HW Platform              
                                               | Quantization Method            
                            | Quantization Bitwidth                             
| Design Target                                                            |
++=================================+=================+=========================================================================+============================================================+===================================================+==========================================================================+
+| Deep Learning Processing Unit   | C: CNN R: RNN   | AD: Alveo DDR AH: Alveo 
HBM VD: Versal DDR with AIE & PL ZD: Zynq DDR   | X: DECENT I: Integer 
threshold F: Float threshold R: RNN   | 4: 4-bit 8: 8-bit 16: 16-bit M: Mixed 
Precision   | G: General purpose H: High throughput L: Low latency C: Cost 
optimized   |
++---------------------------------+-----------------+-------------------------------------------------------------------------+------------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------+
+
+Build instructions
+------------------
+
+This section lists the instructions for building TVM with Vitis-AI for
+both `cloud <#cloud-dpucadx8g>`__ and `edge <#edge-dpuczdx8g>`__.
+
+Cloud (DPUCADX8G)
+~~~~~~~~~~~~~~~~~
+
+For Vitis-AI acceleration in the cloud TVM has to be built on top of the
+Xilinx Alveo platform.
+
+System requirements
+^^^^^^^^^^^^^^^^^^^
+
+The following table lists system requirements for running docker
+containers as well as Alveo cards.
+
++-----------------------------------------------------+----------------------------------------------------------+
+| **Component**                                       | **Requirement**        
                                  |
++=====================================================+==========================================================+
+| Motherboard                                         | PCI Express 
3.0-compliant with one dual-width x16 slot   |
++-----------------------------------------------------+----------------------------------------------------------+
+| System Power Supply                                 | 225W                   
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| Operating System                                    | Ubuntu 16.04, 18.04    
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+|                                                     | CentOS 7.4, 7.5        
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+|                                                     | RHEL 7.4, 7.5          
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| CPU                                                 | Intel i3/i5/i7/i9/Xeon 
64-bit CPU                        |
++-----------------------------------------------------+----------------------------------------------------------+
+| GPU (Optional to accelerate quantization)           | NVIDIA GPU with a 
compute capability > 3.0               |
++-----------------------------------------------------+----------------------------------------------------------+
+| CUDA Driver (Optional to accelerate quantization)   | nvidia-410             
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| FPGA                                                | Xilinx Alveo U200 or 
U250                                |
++-----------------------------------------------------+----------------------------------------------------------+
+| Docker Version                                      | 19.03.1                
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+
+Hardware setup and docker build
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1. Clone the Vitis AI repository:
+
+   .. code:: bash
+
+   git clone --recurse-submodules https://github.com/Xilinx/Vitis-AI
+   
+2. Install Docker, and add the user to the docker group. Link the user
+   to docker installation instructions from the following docker's
+   website:
+   
+
+   -  https://docs.docker.com/install/linux/docker-ce/ubuntu/
+   -  https://docs.docker.com/install/linux/docker-ce/centos/
+   -  https://docs.docker.com/install/linux/linux-postinstall/
+
+3. Download the latest Vitis AI Docker with the following command. This 
container runs on CPU.
+
+   .. code:: bash
+   
+   
+      docker pull xilinx/vitis-ai:latest
+    
+   To accelerate the quantization, you can optionally use the Vitis-AI GPU 
docker image. Use the below commands to build the Vitis-AI GPU docker container:
+   
+    
+   .. code:: bash
+    
+    
+    cd Vitis-AI/docker
+    ./docker_build_gpu.sh
+
+
+4. Set up Vitis AI to target Alveo cards. To target Alveo cards with
+   Vitis AI for machine learning workloads, you must install the
+   following software components:
+
+   -  Xilinx Runtime (XRT)
+   -  Alveo Deployment Shells (DSAs)
+   -  Xilinx Resource Manager (XRM) (xbutler)
+   -  Xilinx Overlaybins (Accelerators to Dynamically Load - binary
+      programming files)
+
+   While it is possible to install all of these software components
+   individually, a script has been provided to automatically install
+   them at once. To do so:
+
+   -  Run the following commands:
+   .. code:: bash
+      
+      cd Vitis-AI/alveo/packages
+      sudo su
+      ./install.sh
+      
+   -  Power cycle the system.
+   
+5. Clone tvm repo and pyxir repo
+
+   .. code:: bash
+   
+   
+      git clone --recursive https://github.com/apache/incubator-tvm.git
+      git clone --recursive https://github.com/Xilinx/pyxir.git
+   
+6. Build and start the tvm runtime Vitis-AI Docker Container.
+
+   .. code:: bash
+
+      bash incubator-tvm/docker/build.sh demo_vitis_ai bash
+      bash incubator-tvm/docker/bash.sh tvm.demo_vitis_ai
+         
+      #Setup inside container
+      source /opt/xilinx/xrt/setup.sh
+      . $VAI_ROOT/conda/etc/profile.d/conda.sh
+      conda activate vitis-ai-tensorflow
+      
+7. Install PyXIR
+
+   .. code:: bash
+
+     cd pyxir
+     python3 setup.py install --use_vai_rt_dpucadx8g --user
+
+   
+8. Build TVM inside the container with Vitis-AI
+
+   .. code:: bash
+
+
+      cd incubator-tvm
+      mkdir build
+      cp cmake/config.cmake build
+      cd build  
+      echo set\(USE_LLVM ON\) >> config.cmake
+      echo set\(USE_VITIS_AI ON\) >> config.cmake
+      cmake ..
+      make -j$(nproc)
+   
+9.  Install TVM
+
+    .. code:: bash
+
+      cd incubator-tvm/python
+      pip3 install -e . --user
+      
+Edge (DPUCZDX8G)
+^^^^^^^^^^^^^^^^
+
+
+For edge deployment we make use of two systems referred to as host and
+edge. The `host <#host-requirements>`__ system is responsible for
+quantization and compilation of the neural network model in a first
+offline step. Afterwards, the model will de deployed on the
+`edge <#edge-requirements>`__ system.
+
+Host requirements
+^^^^^^^^^^^^^^^^^
+
+The following table lists system requirements for running the TVM -
+Vitis-AI docker container.
+
++-----------------------------------------------------+----------------------------------------------+
+| **Component**                                       | **Requirement**        
                      |
++=====================================================+==============================================+
+| Operating System                                    | Ubuntu 16.04, 18.04    
                      |
++-----------------------------------------------------+----------------------------------------------+
+|                                                     | CentOS 7.4, 7.5        
                      |
++-----------------------------------------------------+----------------------------------------------+
+|                                                     | RHEL 7.4, 7.5          
                      |
++-----------------------------------------------------+----------------------------------------------+
+| CPU                                                 | Intel i3/i5/i7/i9/Xeon 
64-bit CPU            |
++-----------------------------------------------------+----------------------------------------------+
+| GPU (Optional to accelerate quantization)           | NVIDIA GPU with a 
compute capability > 3.0   |
++-----------------------------------------------------+----------------------------------------------+
+| CUDA Driver (Optional to accelerate quantization)   | nvidia-410             
                      |
++-----------------------------------------------------+----------------------------------------------+
+| FPGA                                                | Not necessary on host  
                      |
++-----------------------------------------------------+----------------------------------------------+
+| Docker Version                                      | 19.03.1                
                      |
++-----------------------------------------------------+----------------------------------------------+
+
+Host setup and docker build
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1. Clone tvm repo
+
+   .. code:: bash
+
+      git clone --recursive https://github.com/apache/incubator-tvm.git
+2. Build and start the tvm runtime Vitis-AI Docker Container.
+
+   .. code:: bash
+
+      cd incubator-tvm 
+      bash incubator-tvm/docker/build.sh demo_vitis_ai bash
+      bash incubator-tvm/docker/bash.sh tvm.demo_vitis_ai
+   
+      #Setup inside container
+      . $VAI_ROOT/conda/etc/profile.d/conda.sh
+      conda activate vitis-ai-tensorflow
+   
+3. Install PyXIR
+
+   .. code:: bash
+
+
+      git clone --recursive https://github.com/Xilinx/pyxir.git
+      cd pyxir
+      python3 setup.py install --user
+   
+   
+4. Build TVM inside the container with Vitis-AI.
+
+   .. code:: bash
+
+      cd incubator-tvm 
+      mkdir build
+      cp cmake/config.cmake build
+      cd build
+      echo set\(USE_LLVM ON\) >> config.cmake
+      echo set\(USE_VITIS_AI ON\) >> config.cmake
+      cmake ..
+      make -j$(nproc)
+   
+5. Install TVM
+
+   .. code:: bash
+
+      cd incubator-tvm/python
+      pip3 install -e . --user
+
+Edge requirements
+^^^^^^^^^^^^^^^^^
+
+The DPUCZDX8G can be deployed on the `Zynq Ultrascale+
+MPSoc 
<https://www.xilinx.com/products/silicon-devices/soc/zynq-ultrascale-mpsoc.html>`__
+platform. The following development boards can be used out-of-the-box:
+
++--------------------+----------------------+-----------------------------------------------------------------------+
+| **Target board**   | **TVM identifier**   | **Info**                         
                                     |
++====================+======================+=======================================================================+
+| Ultra96            | DPUCZDX8G-ultra96    | 
https://www.xilinx.com/products/boards-and-kits/1-vad4rl.html         |
++--------------------+----------------------+-----------------------------------------------------------------------+
+| ZCU104             | DPUCZDX8G-zcu104     | 
https://www.xilinx.com/products/boards-and-kits/zcu104.html           |
++--------------------+----------------------+-----------------------------------------------------------------------+
+| ZCU102             | DPUCZDX8G-zcu102     | 
https://www.xilinx.com/products/boards-and-kits/ek-u1-zcu102-g.html   |
++--------------------+----------------------+-----------------------------------------------------------------------+
+
+Edge hardware setup
+^^^^^^^^^^^^^^^^^^^
+.. note:: 
+
+  This section provides instructions for setting up with the `Pynq 
<http://www.pynq.io/>`__ platform but 
+  Petalinux based flows are also supported. 
+
+1. Download the Pynq v2.5 image for your target (use Z1 or Z2 for
+   Ultra96 target depending on board version) Link to image:
+   https://github.com/Xilinx/PYNQ/releases/tag/v2.5
+2. Follow Pynq instructions for setting up the board: `pynq
+   setup <https://pynq.readthedocs.io/en/latest/getting_started.html>`__
+3. After connecting to the board, make sure to run as root. Execute
+   ``su``
+4. Set up DPU on Pynq by following the steps here: `DPU Pynq
+   setup <https://github.com/Xilinx/DPU-PYNQ>`__
+5. Run the following command to download the DPU bitstream:
+
+   .. code:: bash
+
+     python3 -c 'from pynq_dpu import DpuOverlay ; overlay = 
DpuOverlay("dpu.bit")'
+  
+6. Check whether the DPU kernel is alive:
+
+   .. code:: bash
+
+     dexplorer -w
+
+Edge TVM setup
+^^^^^^^^^^^^^^
+
+.. note:: 
+
+  When working on Petalinux instead of Pynq, the following steps might take 
more manual work (e.g building     
+  hdf5 from source). Also, TVM has a scipy dependency which you then might 
have to build from source or 
+  circumvent. We don't depend on scipy in our flow.
+
+Building TVM depends on the Xilinx
+`PyXIR <https://github.com/Xilinx/pyxir>`__ package. PyXIR acts as an
+interface between TVM and Vitis-AI tools.
+
+1. First install the PyXIR h5py and pydot dependencies:
+
+   .. code:: bash:
+
+
+      apt-get install libhdf5-dev
+      pip3 install pydot h5py
+2. Install PyXIR
+
+   .. code:: bash:
+
+
+      git clone --recursive https://github.com/Xilinx/pyxir.git
+      cd pyxir
+      sudo python3 setup.py install --use_vai_rt_dpuczdx8g
+   
+3. Build TVM with Vitis-AI
+
+   .. code:: bash:
+
+
+      git clone --recursive https://github.com/apache/incubator-tvm
+      cd incubator-tvm
+      mkdir build
+      cp cmake/config.cmake build
+      cd build
+      echo set\(USE_VITIS_AI ON\) >> config.cmake
+      cmake ..     
+      make
+   
+4. Install TVM
+
+   .. code:: bash:
+
+      cd incubator-tvm/python
+      pip3 install -e . --user
+
+5. Check whether the setup was successful in the Python shell:
+
+   .. code:: bash:
+
+      python3 -c 'import pyxir; import tvm'
+
+
+Getting started
+---------------
+
+This section shows how to use TVM with Vitis-AI. For this it's important
+to understand that neural network models are quantized for Vitis-AI
+execution in fixed point arithmetic. The approach we take here is to
+quantize on-the-fly using the first N inputs as explained in the next
+section.
+
+On-the-fly quantization
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Usually, to be able to accelerate inference of Neural Network models
+with Vitis-AI DPU accelerators, those models need to quantized upfront.
+In TVM - Vitis-AI flow, we make use of on-the-fly quantization to remove
+this additional preprocessing step. In this flow, one doesn't need to
+quantize his/her model upfront but can make use of the typical inference
+execution calls (module.run) to quantize the model on-the-fly using the
+first N inputs that are provided (see more information below). This will
+set up and calibrate the Vitis-AI DPU and from that point onwards
+inference will be accelerated for all next inputs. Note that the edge
+flow deviates slightly from the explained flow in that inference won't
+be accelerated after the first N inputs but the model will have been
+quantized and compiled and can be moved to the edge device for
+deployment. Please check out the `edge <#Edge%20usage>`__ usage
+instructions below for more information.
+
+Config/Settings
+~~~~~~~~~~~~~~~
+
+A couple of environment variables can be used to customize the Vitis-AI
+Byoc flow.
+
++----------------------------+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| **Environment Variable**   | **Default if unset**                   | 
**Explanation**                                                                 
                                                                                
                                                                                
                                                                                
           |
++============================+========================================+============================================================================================================================================================================================================================================================================================================================================+
+| PX\_QUANT\_SIZE            | 128                                    | The 
number of inputs that will be used for quantization (necessary for Vitis-AI 
acceleration)                                                                   
                                                                                
                                                                                
           |
++----------------------------+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| PX\_BUILD\_DIR             | Use the on-the-fly quantization flow   | Loads 
the quantization and compilation information from the provided build directory 
and immediately starts Vitis-AI hardware acceleration. This configuration can 
be used if the model has been executed before using on-the-fly quantization 
during which the quantization and comilation information was cached in a build 
directory.   |
++----------------------------+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+
+Cloud usage
+~~~~~~~~~~~
+
+This section shows how to accelerate a convolutional neural network
+model in TVM with Vitis-AI on the cloud.
+
+To be able to target the Vitis-AI cloud DPUCADX8G target we first have
+to import the target in PyXIR. This PyXIR package is the interface being
+used by TVM to integrate with the Vitis-AI stack. Additionaly, import
+the typical TVM and Relay modules and the Vitis-AI contrib module inside
+TVM.
+
+.. code:: bash

Review comment:
       should the following blocks be python? Same to other places below

##########
File path: docs/deploy/vitis_ai.rst
##########
@@ -0,0 +1,671 @@
+..  Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+..    http://www.apache.org/licenses/LICENSE-2.0
+
+..  Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+
+Vitis-AI Integration
+====================
+
+`Vitis-AI <https://github.com/Xilinx/Vitis-AI>`__ is Xilinx's
+development stack for hardware-accelerated AI inference on Xilinx
+platforms, including both edge devices and Alveo cards. It consists of
+optimized IP, tools, libraries, models, and example designs. It is
+designed with high efficiency and ease of use in mind, unleashing the
+full potential of AI acceleration on Xilinx FPGA and ACAP.
+
+The current Vitis-AI Byoc flow inside TVM enables acceleration of Neural
+Network model inference on edge and cloud. The identifiers for the
+supported edge and cloud Deep Learning Processor Units (DPU's) are
+DPUCZDX8G respectively DPUCADX8G. DPUCZDX8G and DPUCADX8G are hardware
+accelerators for convolutional neural networks (CNN's) on top of the
+Xilinx `Zynq Ultrascale+
+MPSoc 
<https://www.xilinx.com/products/silicon-devices/soc/zynq-ultrascale-mpsoc.html>`__
+respectively
+`Alveo <https://www.xilinx.com/products/boards-and-kits/alveo.html>`__
+(U200/U250) platforms. For more information about the DPU identifiers
+see the section on `DPU naming information <#dpu-naming-information>`__.
+
+On this page you will find information on how to
+`build <#build-instructions>`__ TVM with Vitis-AI and on how to `get
+started <#getting-started>`__ with an example.
+
+DPU naming information
+----------------------
+
++---------------------------------+-----------------+-------------------------------------------------------------------------+------------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------+
+| DPU                             | Application     | HW Platform              
                                               | Quantization Method            
                            | Quantization Bitwidth                             
| Design Target                                                            |
++=================================+=================+=========================================================================+============================================================+===================================================+==========================================================================+
+| Deep Learning Processing Unit   | C: CNN R: RNN   | AD: Alveo DDR AH: Alveo 
HBM VD: Versal DDR with AIE & PL ZD: Zynq DDR   | X: DECENT I: Integer 
threshold F: Float threshold R: RNN   | 4: 4-bit 8: 8-bit 16: 16-bit M: Mixed 
Precision   | G: General purpose H: High throughput L: Low latency C: Cost 
optimized   |
++---------------------------------+-----------------+-------------------------------------------------------------------------+------------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------+
+
+Build instructions
+------------------
+
+This section lists the instructions for building TVM with Vitis-AI for
+both `cloud <#cloud-dpucadx8g>`__ and `edge <#edge-dpuczdx8g>`__.
+
+Cloud (DPUCADX8G)
+~~~~~~~~~~~~~~~~~
+
+For Vitis-AI acceleration in the cloud TVM has to be built on top of the
+Xilinx Alveo platform.
+
+System requirements
+^^^^^^^^^^^^^^^^^^^
+
+The following table lists system requirements for running docker
+containers as well as Alveo cards.
+
++-----------------------------------------------------+----------------------------------------------------------+
+| **Component**                                       | **Requirement**        
                                  |
++=====================================================+==========================================================+
+| Motherboard                                         | PCI Express 
3.0-compliant with one dual-width x16 slot   |
++-----------------------------------------------------+----------------------------------------------------------+
+| System Power Supply                                 | 225W                   
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| Operating System                                    | Ubuntu 16.04, 18.04    
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+|                                                     | CentOS 7.4, 7.5        
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+|                                                     | RHEL 7.4, 7.5          
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| CPU                                                 | Intel i3/i5/i7/i9/Xeon 
64-bit CPU                        |
++-----------------------------------------------------+----------------------------------------------------------+
+| GPU (Optional to accelerate quantization)           | NVIDIA GPU with a 
compute capability > 3.0               |
++-----------------------------------------------------+----------------------------------------------------------+
+| CUDA Driver (Optional to accelerate quantization)   | nvidia-410             
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+| FPGA                                                | Xilinx Alveo U200 or 
U250                                |
++-----------------------------------------------------+----------------------------------------------------------+
+| Docker Version                                      | 19.03.1                
                                  |
++-----------------------------------------------------+----------------------------------------------------------+
+
+Hardware setup and docker build
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1. Clone the Vitis AI repository:
+
+   .. code:: bash
+
+   git clone --recurse-submodules https://github.com/Xilinx/Vitis-AI
+   
+2. Install Docker, and add the user to the docker group. Link the user
+   to docker installation instructions from the following docker's
+   website:
+   
+
+   -  https://docs.docker.com/install/linux/docker-ce/ubuntu/
+   -  https://docs.docker.com/install/linux/docker-ce/centos/
+   -  https://docs.docker.com/install/linux/linux-postinstall/
+
+3. Download the latest Vitis AI Docker with the following command. This 
container runs on CPU.
+
+   .. code:: bash
+   
+   
+      docker pull xilinx/vitis-ai:latest
+    
+   To accelerate the quantization, you can optionally use the Vitis-AI GPU 
docker image. Use the below commands to build the Vitis-AI GPU docker container:
+   
+    
+   .. code:: bash
+    
+    
+    cd Vitis-AI/docker
+    ./docker_build_gpu.sh
+
+
+4. Set up Vitis AI to target Alveo cards. To target Alveo cards with
+   Vitis AI for machine learning workloads, you must install the
+   following software components:
+
+   -  Xilinx Runtime (XRT)
+   -  Alveo Deployment Shells (DSAs)
+   -  Xilinx Resource Manager (XRM) (xbutler)
+   -  Xilinx Overlaybins (Accelerators to Dynamically Load - binary
+      programming files)
+
+   While it is possible to install all of these software components
+   individually, a script has been provided to automatically install
+   them at once. To do so:
+
+   -  Run the following commands:
+   .. code:: bash
+      
+      cd Vitis-AI/alveo/packages
+      sudo su
+      ./install.sh
+      
+   -  Power cycle the system.
+   
+5. Clone tvm repo and pyxir repo
+
+   .. code:: bash
+   
+   
+      git clone --recursive https://github.com/apache/incubator-tvm.git
+      git clone --recursive https://github.com/Xilinx/pyxir.git
+   
+6. Build and start the tvm runtime Vitis-AI Docker Container.
+
+   .. code:: bash
+
+      bash incubator-tvm/docker/build.sh demo_vitis_ai bash
+      bash incubator-tvm/docker/bash.sh tvm.demo_vitis_ai
+         
+      #Setup inside container
+      source /opt/xilinx/xrt/setup.sh
+      . $VAI_ROOT/conda/etc/profile.d/conda.sh
+      conda activate vitis-ai-tensorflow
+      
+7. Install PyXIR
+
+   .. code:: bash
+
+     cd pyxir
+     python3 setup.py install --use_vai_rt_dpucadx8g --user
+
+   
+8. Build TVM inside the container with Vitis-AI
+
+   .. code:: bash
+
+
+      cd incubator-tvm
+      mkdir build
+      cp cmake/config.cmake build
+      cd build  
+      echo set\(USE_LLVM ON\) >> config.cmake
+      echo set\(USE_VITIS_AI ON\) >> config.cmake
+      cmake ..
+      make -j$(nproc)
+   
+9.  Install TVM
+
+    .. code:: bash
+
+      cd incubator-tvm/python
+      pip3 install -e . --user
+      
+Edge (DPUCZDX8G)
+^^^^^^^^^^^^^^^^
+
+
+For edge deployment we make use of two systems referred to as host and
+edge. The `host <#host-requirements>`__ system is responsible for
+quantization and compilation of the neural network model in a first
+offline step. Afterwards, the model will de deployed on the
+`edge <#edge-requirements>`__ system.
+
+Host requirements
+^^^^^^^^^^^^^^^^^
+
+The following table lists system requirements for running the TVM -
+Vitis-AI docker container.
+
++-----------------------------------------------------+----------------------------------------------+
+| **Component**                                       | **Requirement**        
                      |
++=====================================================+==============================================+
+| Operating System                                    | Ubuntu 16.04, 18.04    
                      |
++-----------------------------------------------------+----------------------------------------------+
+|                                                     | CentOS 7.4, 7.5        
                      |
++-----------------------------------------------------+----------------------------------------------+
+|                                                     | RHEL 7.4, 7.5          
                      |
++-----------------------------------------------------+----------------------------------------------+
+| CPU                                                 | Intel i3/i5/i7/i9/Xeon 
64-bit CPU            |
++-----------------------------------------------------+----------------------------------------------+
+| GPU (Optional to accelerate quantization)           | NVIDIA GPU with a 
compute capability > 3.0   |
++-----------------------------------------------------+----------------------------------------------+
+| CUDA Driver (Optional to accelerate quantization)   | nvidia-410             
                      |
++-----------------------------------------------------+----------------------------------------------+
+| FPGA                                                | Not necessary on host  
                      |
++-----------------------------------------------------+----------------------------------------------+
+| Docker Version                                      | 19.03.1                
                      |
++-----------------------------------------------------+----------------------------------------------+
+
+Host setup and docker build
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1. Clone tvm repo
+
+   .. code:: bash
+
+      git clone --recursive https://github.com/apache/incubator-tvm.git
+2. Build and start the tvm runtime Vitis-AI Docker Container.
+
+   .. code:: bash
+
+      cd incubator-tvm 
+      bash incubator-tvm/docker/build.sh demo_vitis_ai bash
+      bash incubator-tvm/docker/bash.sh tvm.demo_vitis_ai
+   
+      #Setup inside container
+      . $VAI_ROOT/conda/etc/profile.d/conda.sh
+      conda activate vitis-ai-tensorflow
+   
+3. Install PyXIR
+
+   .. code:: bash
+
+
+      git clone --recursive https://github.com/Xilinx/pyxir.git
+      cd pyxir
+      python3 setup.py install --user
+   
+   
+4. Build TVM inside the container with Vitis-AI.
+
+   .. code:: bash
+
+      cd incubator-tvm 
+      mkdir build
+      cp cmake/config.cmake build
+      cd build
+      echo set\(USE_LLVM ON\) >> config.cmake
+      echo set\(USE_VITIS_AI ON\) >> config.cmake
+      cmake ..
+      make -j$(nproc)
+   
+5. Install TVM
+
+   .. code:: bash
+
+      cd incubator-tvm/python
+      pip3 install -e . --user
+
+Edge requirements
+^^^^^^^^^^^^^^^^^
+
+The DPUCZDX8G can be deployed on the `Zynq Ultrascale+
+MPSoc 
<https://www.xilinx.com/products/silicon-devices/soc/zynq-ultrascale-mpsoc.html>`__
+platform. The following development boards can be used out-of-the-box:
+
++--------------------+----------------------+-----------------------------------------------------------------------+
+| **Target board**   | **TVM identifier**   | **Info**                         
                                     |
++====================+======================+=======================================================================+
+| Ultra96            | DPUCZDX8G-ultra96    | 
https://www.xilinx.com/products/boards-and-kits/1-vad4rl.html         |
++--------------------+----------------------+-----------------------------------------------------------------------+
+| ZCU104             | DPUCZDX8G-zcu104     | 
https://www.xilinx.com/products/boards-and-kits/zcu104.html           |
++--------------------+----------------------+-----------------------------------------------------------------------+
+| ZCU102             | DPUCZDX8G-zcu102     | 
https://www.xilinx.com/products/boards-and-kits/ek-u1-zcu102-g.html   |
++--------------------+----------------------+-----------------------------------------------------------------------+
+
+Edge hardware setup
+^^^^^^^^^^^^^^^^^^^
+.. note:: 
+
+  This section provides instructions for setting up with the `Pynq 
<http://www.pynq.io/>`__ platform but 
+  Petalinux based flows are also supported. 
+
+1. Download the Pynq v2.5 image for your target (use Z1 or Z2 for
+   Ultra96 target depending on board version) Link to image:
+   https://github.com/Xilinx/PYNQ/releases/tag/v2.5
+2. Follow Pynq instructions for setting up the board: `pynq
+   setup <https://pynq.readthedocs.io/en/latest/getting_started.html>`__
+3. After connecting to the board, make sure to run as root. Execute
+   ``su``
+4. Set up DPU on Pynq by following the steps here: `DPU Pynq
+   setup <https://github.com/Xilinx/DPU-PYNQ>`__
+5. Run the following command to download the DPU bitstream:
+
+   .. code:: bash
+
+     python3 -c 'from pynq_dpu import DpuOverlay ; overlay = 
DpuOverlay("dpu.bit")'
+  
+6. Check whether the DPU kernel is alive:
+
+   .. code:: bash
+
+     dexplorer -w
+
+Edge TVM setup
+^^^^^^^^^^^^^^
+
+.. note:: 
+
+  When working on Petalinux instead of Pynq, the following steps might take 
more manual work (e.g building     
+  hdf5 from source). Also, TVM has a scipy dependency which you then might 
have to build from source or 
+  circumvent. We don't depend on scipy in our flow.
+
+Building TVM depends on the Xilinx
+`PyXIR <https://github.com/Xilinx/pyxir>`__ package. PyXIR acts as an
+interface between TVM and Vitis-AI tools.
+
+1. First install the PyXIR h5py and pydot dependencies:
+
+   .. code:: bash:
+
+
+      apt-get install libhdf5-dev
+      pip3 install pydot h5py
+2. Install PyXIR
+
+   .. code:: bash:
+
+
+      git clone --recursive https://github.com/Xilinx/pyxir.git
+      cd pyxir
+      sudo python3 setup.py install --use_vai_rt_dpuczdx8g
+   
+3. Build TVM with Vitis-AI
+
+   .. code:: bash:
+
+
+      git clone --recursive https://github.com/apache/incubator-tvm
+      cd incubator-tvm
+      mkdir build
+      cp cmake/config.cmake build
+      cd build
+      echo set\(USE_VITIS_AI ON\) >> config.cmake
+      cmake ..     
+      make
+   
+4. Install TVM
+
+   .. code:: bash:
+
+      cd incubator-tvm/python
+      pip3 install -e . --user
+
+5. Check whether the setup was successful in the Python shell:
+
+   .. code:: bash:
+
+      python3 -c 'import pyxir; import tvm'
+
+
+Getting started
+---------------
+
+This section shows how to use TVM with Vitis-AI. For this it's important
+to understand that neural network models are quantized for Vitis-AI
+execution in fixed point arithmetic. The approach we take here is to
+quantize on-the-fly using the first N inputs as explained in the next
+section.
+
+On-the-fly quantization
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Usually, to be able to accelerate inference of Neural Network models
+with Vitis-AI DPU accelerators, those models need to quantized upfront.
+In TVM - Vitis-AI flow, we make use of on-the-fly quantization to remove
+this additional preprocessing step. In this flow, one doesn't need to
+quantize his/her model upfront but can make use of the typical inference
+execution calls (module.run) to quantize the model on-the-fly using the
+first N inputs that are provided (see more information below). This will
+set up and calibrate the Vitis-AI DPU and from that point onwards
+inference will be accelerated for all next inputs. Note that the edge
+flow deviates slightly from the explained flow in that inference won't
+be accelerated after the first N inputs but the model will have been
+quantized and compiled and can be moved to the edge device for
+deployment. Please check out the `edge <#Edge%20usage>`__ usage
+instructions below for more information.
+
+Config/Settings
+~~~~~~~~~~~~~~~
+
+A couple of environment variables can be used to customize the Vitis-AI
+Byoc flow.
+
++----------------------------+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| **Environment Variable**   | **Default if unset**                   | 
**Explanation**                                                                 
                                                                                
                                                                                
                                                                                
           |
++============================+========================================+============================================================================================================================================================================================================================================================================================================================================+
+| PX\_QUANT\_SIZE            | 128                                    | The 
number of inputs that will be used for quantization (necessary for Vitis-AI 
acceleration)                                                                   
                                                                                
                                                                                
           |
++----------------------------+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| PX\_BUILD\_DIR             | Use the on-the-fly quantization flow   | Loads 
the quantization and compilation information from the provided build directory 
and immediately starts Vitis-AI hardware acceleration. This configuration can 
be used if the model has been executed before using on-the-fly quantization 
during which the quantization and comilation information was cached in a build 
directory.   |
++----------------------------+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+
+Cloud usage
+~~~~~~~~~~~
+
+This section shows how to accelerate a convolutional neural network
+model in TVM with Vitis-AI on the cloud.
+
+To be able to target the Vitis-AI cloud DPUCADX8G target we first have
+to import the target in PyXIR. This PyXIR package is the interface being
+used by TVM to integrate with the Vitis-AI stack. Additionaly, import
+the typical TVM and Relay modules and the Vitis-AI contrib module inside
+TVM.
+
+.. code:: bash
+
+   import pyxir
+   import pyxir.contrib.target.DPUCADX8G
+
+   import tvm
+   import tvm.relay as relay
+   from tvm.contrib.target import vitis_ai
+   from tvm.relay.build_module import bind_params_by_name
+   from tvm.relay.op.contrib.vitis_ai import annotation
+
+After importing a convolutional neural network model using the usual
+Relay API's, annotate the Relay expression for the given Vitis-AI DPU
+target and partition the graph.
+
+.. code:: bash
+
+   mod["main"] = bind_params_by_name(mod["main"], params)
+   mod = annotation(mod, params, target)
+   mod = relay.transform.MergeCompilerRegions()(mod)
+   mod = relay.transform.PartitionGraph()(mod)
+
+Now, we can build the TVM runtime library for executing the model. The
+TVM target is 'llvm' as the operations that can't be handled by the DPU
+are executed on the CPU. The Vitis-AI target is DPUCADX8G as we are
+targeting the cloud DPU and this target is passed as a config to the TVM
+build call.
+
+.. code:: bash
+
+   tvm_target = 'llvm'
+   target='DPUCADX8G'
+
+   with tvm.transform.PassContext(opt_level=3, config= 
{'relay.ext.vitis_ai.options.target': target}):   
+      graph, lib, params = relay.build(mod, tvm_target, params=params)
+
+As one more step before we can accelerate a model with Vitis-AI in TVM
+we have to quantize and compile the model for execution on the DPU. We
+make use of on-the-fly quantization for this. Using this method one
+doesn’t need to quantize their model upfront and can make use of the
+typical inference execution calls (module.run) to calibrate the model
+on-the-fly using the first N inputs that are provided. After the first N
+iterations, computations will be accelerated on the DPU. So now we will
+feed N inputs to the TVM runtime module. Note that these first N inputs
+will take a substantial amount of time.
+
+.. code:: bash:
+
+   module = tvm.contrib.graph_runtime.create(graph, lib, tvm.cpu())
+   module.set_input(**params)
+
+   # First N (default = 128) inputs are used for quantization calibration and 
will
+   # be executed on the CPU
+   # This config can be changed by setting the 'PX_QUANT_SIZE' (e.g. export 
PX_QUANT_SIZE=64)
+   for i in range(128):
+      module.set_input(input_name, inputs[i]) 
+      module.run()
+
+Afterwards, inference will be accelerated on the DPU.
+
+.. code:: bash
+
+   module.set_input(name, data)
+   module.run()
+
+To save and load the built module, one can use the typical TVM API's:
+
+.. code:: bash
+
+   # save the graph, lib and params into separate files
+   from tvm.contrib import util
+
+   temp = util.tempdir()
+   path_lib = temp.relpath("deploy_lib.so")
+   lib.export_library(path_lib)
+   with open(temp.relpath("deploy_graph.json"), "w") as fo:
+      fo.write(graph)
+   with open(temp.relpath("deploy_param.params"), "wb") as fo:
+      fo.write(relay.save_param_dict(params))
+
+Load the module from compiled files and run inference
+
+.. code:: bash
+
+   # load the module into memory
+   loaded_json = open(temp.relpath("deploy_graph.json")).read()
+   loaded_lib = tvm.runtime.load_module(path_lib)
+   loaded_params = bytearray(open(temp.relpath("deploy_param.params"), 
"rb").read())
+
+   module = tvm.contrib.graph_runtime.create(loaded_json, loaded_lib, ctx)
+   module.load_params(loaded_params)
+   module.set_input(name, data)
+   module.run()
+
+Edge usage
+~~~~~~~~~~
+
+This section shows how to accelerate a convolutional neural network
+model in TVM with Vitis-AI at the edge. The first couple of steps will
+have to be run on the host machine and take care of quantization and
+compilation for deployment at the edge.
+
+Host steps
+^^^^^^^^^^
+
+To be able to target the Vitis-AI cloud DPUCZDX8G target we first have
+to import the target in PyXIR. This PyXIR package is the interface being
+used by TVM to integrate with the Vitis-AI stack. Additionaly, import
+the typical TVM and Relay modules and the Vitis-AI contrib module inside
+TVM.
+
+.. code:: bash
+
+   import pyxir
+   import pyxir.contrib.target.DPUCZDX8G
+
+   import tvm
+   import tvm.relay as relay
+   from tvm.contrib.target import vitis_ai
+   from tvm.relay.build_module import bind_params_by_name
+   from tvm.relay.op.contrib.vitis_ai import annotation
+
+After importing a convolutional neural network model using the usual
+Relay API's, annotate the Relay expression for the given Vitis-AI DPU
+target and partition the graph.
+
+.. code:: bash
+
+   mod["main"] = bind_params_by_name(mod["main"], params)
+   mod = annotation(mod, params, target)
+   mod = relay.transform.MergeCompilerRegions()(mod)
+   mod = relay.transform.PartitionGraph()(mod)
+
+Now, we can build the TVM runtime library for executing the model. The
+TVM target is 'llvm' as the operations that can't be handled by the DPU
+are executed on the CPU. At this point that means the CPU on the host.
+The Vitis-AI target is DPUCZDX8G-zcu104 as we are targeting the edge DPU
+on the ZCU104 board and this target is passed as a config to the TVM
+build call. Note that different identifiers can be passed for different
+targets, see `edge targets info <#edge-requirements>`__.
+
+.. code:: bash
+
+   tvm_target = 'llvm'
+   target='DPUCZDX8G-zcu104'
+
+   with tvm.transform.PassContext(opt_level=3, config= 
{'relay.ext.vitis_ai.options.target': target}):   
+      graph, lib, params = relay.build(mod, tvm_target, params=params)
+
+Additionaly, already build the deployment module for the ARM CPU target
+and serialize:
+
+.. code:: bash
+
+   # Export lib for aarch64 target
+
+   tvm_target = tvm.target.arm_cpu('ultra96')
+   lib_kwargs = {
+        'fcompile': contrib.cc.create_shared,
+        'cc': "/usr/aarch64-linux-gnu/bin/ld"
+   }
+
+   with tvm.transform.PassContext(opt_level=3,
+                                   
config={'relay.ext.vitis_ai.options.target': target,
+                                           
'relay.ext.vitis_ai.options.build_dir': target + '_build'}):

Review comment:
       do we need to have config for the build dir? can we just use a temporary 
dir to do this?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to