You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/04/24 02:21:18 UTC

[GitHub] [tvm] mherkazandjian opened a new pull request #7917: allow libbacktrace to be used when cross compiling the runtime

mherkazandjian opened a new pull request #7917:
URL: https://github.com/apache/tvm/pull/7917


   This PR fixes issue #7916
   
   to build for aarch64 the cmake variable  ``-DCMAKE_HOST=aarch64-linux-gnu`` should be passed that
   is in turn propagated to the autotools (configure step)  for libbacktrace.
   
   ````bash
   cmake .. \
       -DCMAKE_SYSTEM_NAME=Linux \
       -DCMAKE_SYSTEM_VERSION=1 \
       -DCMAKE_C_COMPILER=/usr/bin/aarch64-linux-gnu-gcc-8 \
       -DCMAKE_CXX_COMPILER=/usr/bin/aarch64-linux-gnu-g++-8 \
       -DCMAKE_FIND_ROOT_PATH=/usr/aarch64-linux-gnu \
       -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
       -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
       -DCMAKE_HOST=aarch64-linux-gnu  
   ````
   
   I tested this to build the runtime for ``aarch64``  and ``riscv64``, the runtime ``.so`` was produced in both
   cases with no errors displayed during the build.
   


-- 
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:
users@infra.apache.org



[GitHub] [tvm] tkonolige commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
tkonolige commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-828608218


   @mherkazandjian We should not require `MACHINE_NAME` be passed in as part of the build. The cmake script should check if it is set and then add the correct configure flags.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-829431133


   > My apologies for the late docs review. Thanks for pinging me on it.
   
   no worries. tnx for the feedback. i'll check your feedback in a bit.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] leandron commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
leandron commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-826689569


   > On another note, i think an end to end example on inference on a remote machine would be great.
   i could probably contribute that end to end example if it does not exist, does it?
   
   Yes, that would be really useful, specially if it uses TVMC rather than low level APIs, IMHO.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] leandron commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
leandron commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r620130294



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -21,7 +21,16 @@ ExternalProject_Add(project_libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"

Review comment:
       Maybe this should actually point to the CXX version?
   
   ```suggestion
                       "CPP=${CMAKE_CXX_COMPILER} -E"
   ```




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r637406792



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -16,12 +16,28 @@
 # under the License.
 include(ExternalProject)
 
+

Review comment:
       done, tnx.




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r621069723



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -21,7 +21,16 @@ ExternalProject_Add(project_libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"
+                    "NM=${CMAKE_NM}"
+                    "STRIP=${CMAKE_STRIP}"
+                    "CPPFLAGS=${CMAKE_C_FLAGS}"
+                    "--host=${MACHINE_NAME}"

Review comment:
       yes, it should be specified when executing cmake
   
   ![image](https://user-images.githubusercontent.com/3264637/116225445-1ff15a80-a752-11eb-9ae5-fac0eac7236b.png)
   




-- 
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:
users@infra.apache.org



[GitHub] [tvm] hogepodge commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
hogepodge commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r623212796



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a Raspberry Pi. Producing the runtime library can be done much faster on 
+hosts that have beefy processors (such as laptops, workstation) instead of target

Review comment:
       I would avoid using jargon like "beefy" and prefer phrases like "higher performance".




-- 
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:
users@infra.apache.org



[GitHub] [tvm] leandron commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
leandron commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r621585598



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a raspberry pi. Producing the runtime library can be done much faster on 
+hosts that have beefy processors (such as laptops, workstation) instead of target
+devices such as a raspberry pi. In-order to cross compile the runtime the toolchain
+for the target device must be installed. After installing the correct toolchain
+the main difference compared to compiling natively is to pass a bunch of command
+line argument to cmake that specify the compiler(s) to be used. For reference
+building the TVM runtime library on a modern laptop (using 8 threads) for ``aarch64``
+takes around 20 seconds vs ~10 min to build the runtime on a raspberry pi 4.
+
+cross-compile for aarch64
+"""""""""""""""""""""""""
+
+.. code-block:: bash
+
+   sudo apt-get update
+   sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
+
+.. code-block:: bash
+
+    cmake .. \
+        -DCMAKE_SYSTEM_NAME=Linux \
+        -DCMAKE_SYSTEM_VERSION=1 \
+        -DCMAKE_C_COMPILER=/usr/bin/aarch64-linux-gnu-gcc \
+        -DCMAKE_CXX_COMPILER=/usr/bin/aarch64-linux-gnu-g++ \
+        -DCMAKE_FIND_ROOT_PATH=/usr/aarch64-linux-gnu \
+        -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
+        -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
+        -DMACHINE_NAME=aarch64-linux-gnu 
+
+    make -j$(nproc) runtime
+
+For bare metal ARM devices the following toolchain is quite handy to install instead of gcc-aarch64-linux-*
+
+.. code-block:: bash
+
+   sudo apt-get install gcc-multilib-arm-linux-gnueabihf g++-multilib-arm-linux-gnueabihf
+
+
+cross-compile for RISC-V
+"""""""""""""""""""""""""
+
+.. code-block:: bash
+
+   sudo apt-get update
+   sudo apt-get install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu
+
+
+.. code-block:: bash
+
+    cmake .. \
+        -DCMAKE_SYSTEM_NAME=Linux \
+        -DCMAKE_SYSTEM_VERSION=1 \
+        -DCMAKE_C_COMPILER=/usr/bin/riscv64-linux-gnu-gcc \
+        -DCMAKE_CXX_COMPILER=/usr/bin/riscv64-linux-gnu-g++ \
+        -DCMAKE_FIND_ROOT_PATH=/usr/riscv64-linux-gnu \
+        -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
+        -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
+        -DMACHINE_NAME=riscv64-linux-gnu 
+
+    make -j$(nproc) runtime
+
+The ``file`` command can be used to query the architecture of the produced runtime.
+
+
+.. code-block:: bash
+
+   file file libtvm_runtime.so

Review comment:
       Is `file file` here intentional?

##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a raspberry pi. Producing the runtime library can be done much faster on 
+hosts that have beefy processors (such as laptops, workstation) instead of target
+devices such as a raspberry pi. In-order to cross compile the runtime the toolchain
+for the target device must be installed. After installing the correct toolchain
+the main difference compared to compiling natively is to pass a bunch of command
+line argument to cmake that specify the compiler(s) to be used. For reference
+building the TVM runtime library on a modern laptop (using 8 threads) for ``aarch64``
+takes around 20 seconds vs ~10 min to build the runtime on a raspberry pi 4.

Review comment:
       ```suggestion
   takes around 20 seconds vs ~10 min to build the runtime on a Raspberry Pi 4.
   ```

##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a raspberry pi. Producing the runtime library can be done much faster on 
+hosts that have beefy processors (such as laptops, workstation) instead of target
+devices such as a raspberry pi. In-order to cross compile the runtime the toolchain
+for the target device must be installed. After installing the correct toolchain
+the main difference compared to compiling natively is to pass a bunch of command

Review comment:
       ```suggestion
   the main difference compared to compiling natively is to pass some additional command
   ```

##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a raspberry pi. Producing the runtime library can be done much faster on 
+hosts that have beefy processors (such as laptops, workstation) instead of target
+devices such as a raspberry pi. In-order to cross compile the runtime the toolchain

Review comment:
       ```suggestion
   devices such as a Raspberry Pi. In-order to cross compile the runtime, the toolchain
   ```

##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a raspberry pi. Producing the runtime library can be done much faster on 
+hosts that have beefy processors (such as laptops, workstation) instead of target
+devices such as a raspberry pi. In-order to cross compile the runtime the toolchain
+for the target device must be installed. After installing the correct toolchain
+the main difference compared to compiling natively is to pass a bunch of command
+line argument to cmake that specify the compiler(s) to be used. For reference

Review comment:
       ```suggestion
   line argument to cmake that specify a toolchain to be used. For reference,
   ```

##########
File path: docs/install/from_source.rst
##########
@@ -51,27 +51,31 @@ Build the Shared Library
 
 Our goal is to build the shared libraries:
 
-- On Linux the target library are `libtvm.so`
-- On macOS the target library are `libtvm.dylib`
-- On Windows the target library are `libtvm.dll`
+   - On Linux the target library are `libtvm.so` and `libtvm_runtime.so`
+   - On macOS the target library are `libtvm.dylib` and `libtvm_runtime.dylib` 
+   - On Windows the target library are `libtvm.dll` and `libtvm_runtime.dll` 
 
+It is also possible to :ref:`build the runtime <deploy-and-integration>` library only.
+
+The minimal building requirements for the ``TVM`` libraries are:
+
+   - A recent c++ compiler supporting C++ 14 (g++-5 or higher)
+   - CMake 3.5 or higher
+   - We highly recommend to build with LLVM to enable all the features.
+   - If you want to use CUDA, CUDA toolkit version >= 8.0 is required. If you are upgrading from an older version, make sure you purge the older version and reboot after installation.
+   - On macOS, you may want to install `Homebrew <https://brew.sh>` to easily install and manage dependencies.
+
+To install the these minimal pre-requisites on Ubuntu/Debian like
+linux operating systems, execute (in a terminal):
 
 .. code:: bash
 
     sudo apt-get update
     sudo apt-get install -y python3 python3-dev python3-setuptools gcc libtinfo-dev zlib1g-dev build-essential cmake libedit-dev libxml2-dev
 
-The minimal building requirements are
-
-- A recent c++ compiler supporting C++ 14 (g++-5 or higher)
-- CMake 3.5 or higher
-- We highly recommend to build with LLVM to enable all the features.
-- If you want to use CUDA, CUDA toolkit version >= 8.0 is required. If you are upgrading from an older version, make sure you purge the older version and reboot after installation.
-- On macOS, you may want to install `Homebrew <https://brew.sh>` to easily install and manage dependencies.
-
 
 We use cmake to build the library.
-The configuration of TVM can be modified by `config.cmake`.
+The configuration of TVM can be modified by `config.cmake` (and/or by passing cmake flags to the command line):

Review comment:
       ```suggestion
   The configuration of TVM can be modified by `config.cmake` and/or by passing cmake flags to the command line:
   ```

##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a raspberry pi. Producing the runtime library can be done much faster on 
+hosts that have beefy processors (such as laptops, workstation) instead of target
+devices such as a raspberry pi. In-order to cross compile the runtime the toolchain
+for the target device must be installed. After installing the correct toolchain

Review comment:
       ```suggestion
   for the target device must be installed. After installing the correct toolchain,
   ```

##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a raspberry pi. Producing the runtime library can be done much faster on 

Review comment:
       ```suggestion
   compiled on a Raspberry Pi. Producing the runtime library can be done much faster on 
   ```




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian edited a comment on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian edited a comment on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-828873940


   @tqchen it looks like the docker daemon did not start in the CI instance
   https://ci.tlcpack.ai/blue/organizations/jenkins/tvm/detail/PR-7917/9/pipeline/259
   how can one re-trigger the build? it looks like an issue with the CI machine/vm itself.
   ( i can just push a dummy commit to re-trigger...)


-- 
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:
users@infra.apache.org



[GitHub] [tvm] tqchen commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
tqchen commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-847031676


   @areusch @leandron @tkonolige @hogepodge please take another look and https://tvm.apache.org/docs/contribute/code_review.html?highlight=approve#approve-and-request-changes-explicitly


-- 
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:
users@infra.apache.org



[GitHub] [tvm] tkonolige commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
tkonolige commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-826937491


   btw, I tried these same changes when debugging #7705 but they did not fix it.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r622014336



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a raspberry pi. Producing the runtime library can be done much faster on 
+hosts that have beefy processors (such as laptops, workstation) instead of target
+devices such as a raspberry pi. In-order to cross compile the runtime the toolchain
+for the target device must be installed. After installing the correct toolchain

Review comment:
       done




-- 
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:
users@infra.apache.org



[GitHub] [tvm] tkonolige commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
tkonolige commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-829460968


   @mherkazandjian That snippet will fix the issue. `/usr/bin/cc` looks at the environment variable `SDKROOT` and uses the `cc` in that directory. So if the user switches their `SDKROOT` between configuring and building tvm, then they will have an issue.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] hogepodge commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
hogepodge commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-830266638


   We put images into the https://github.com/tlc-pack/web-data repository.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-828873940


   @tqchen it looks like the docker daemon did not start in the CI instance
   https://ci.tlcpack.ai/blue/organizations/jenkins/tvm/detail/PR-7917/9/pipeline/259
   how can one re-trigger the build? it looks like an issue with the CI machine/vm itself.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-831090459


   @hogepodge did you get a chance to look at the changes? i think this PR is good to go (the CI tests pass too)


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r620138520



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -21,7 +21,16 @@ ExternalProject_Add(project_libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"

Review comment:
       Hi @leandron 
   
   I think you are right, i'll do the changes and also update the documention.
   On another note, i think an end to end example on inference on a remote machine would be great. 
   i could probably contribute that end to end example if it does not exist, does it?




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r622014889



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a raspberry pi. Producing the runtime library can be done much faster on 
+hosts that have beefy processors (such as laptops, workstation) instead of target
+devices such as a raspberry pi. In-order to cross compile the runtime the toolchain
+for the target device must be installed. After installing the correct toolchain
+the main difference compared to compiling natively is to pass a bunch of command

Review comment:
       done




-- 
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:
users@infra.apache.org



[GitHub] [tvm] hogepodge commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
hogepodge commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-829399526


   My apologies for the late docs review. Thanks for pinging me on it.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-829383992


   > @mherkazandjian i think the CI is having some trouble now, feel free to push an empty commit to retriever
   
   cool. i did a dummy commit to trigger the build, the CI checks pass. I am not sure @tkonolige is ok with merging but 
   i don't see any macOS issues in the CI (maybe i am missing something). Please feel free to merge whenever you want.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] tkonolige commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
tkonolige commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-828562180


   @mherkazandjian I'm sorry it took me so long to remember this, but I don't think this PR will work on macOS. Here is what I had in my version of this:
   
   ```
   # On MacOS, the default C compiler (/usr/bin/cc) is actually a small script that dispatches to a
   # compiler the default SDK (usually /Library/Developer/CommandLineTools/usr/bin/ or
   # /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/). CMake
   # automatically detects what is being dispatched and uses it instead along with all the flags it
   # needs. CMake makes this second compiler avaliable through the CMAKE_C_COMPILER variable, but it
   # does not make the necessary flags available. This leads to configuration errors in libbacktrace
   # because it can't find system libraries. Our solution is to detect if CMAKE_C_COMPILER lives in
   # /Library or /Applications and switch to the default compiler instead.
   if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND (CMAKE_C_COMPILER MATCHES "^/Library"
     OR CMAKE_C_COMPILER MATCHES "^/Applications"))
     set(c_compiler "/usr/bin/cc")
   else()
     set(c_compiler "${CMAKE_C_COMPILER}")
   endif()
   ```
   
   Note that this solution is not quite correct. You probably want to set the sdk path to whatever the user set it to.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r622011506



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a raspberry pi. Producing the runtime library can be done much faster on 

Review comment:
       done, tnx




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r622012841



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a raspberry pi. Producing the runtime library can be done much faster on 
+hosts that have beefy processors (such as laptops, workstation) instead of target
+devices such as a raspberry pi. In-order to cross compile the runtime the toolchain

Review comment:
       done




-- 
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:
users@infra.apache.org



[GitHub] [tvm] tqchen commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
tqchen commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-838776952


   gentle ping @mherkazandjian please follow up on the review comments and let us merge soon !


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-830122243


   > @mherkazandjian That snippet will fix the issue. `/usr/bin/cc` looks at the environment variable `SDKROOT` and uses the `cc` in that directory. So if the user switches their `SDKROOT` between configuring and building tvm, then they will have an issue.
   
   i added the snippet to the cmake config of libbacktrace.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-828355243


   > I happy to approve this PR. Did you check @tkonolige's comment about building with debug flags?
   
   great. thank you.
   i looked into the comment of @tkonolige but i thought it is not strictly related to this issue in the sense that 
   this PR would not affect that issue negatively. I will look into it closely.
   
   i have a question though, in the CI it looks like the arm build is failing
   https://ci.tlcpack.ai/blue/organizations/jenkins/tvm/detail/PR-7917/7/pipeline/#step-163-log-112
   should i try to fix it? please advise.
   


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r624187174



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling

Review comment:
       thank you @tqchen  for merging https://github.com/tlc-pack/web-data/pull/5 
   i updated the url, the doc build looks good locally.




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r624064901



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling

Review comment:
       @hogepodge it seems that it is not allowed to have ``.svg`` files in the repo, where should i put the image?




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r621346999



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -21,7 +21,16 @@ ExternalProject_Add(project_libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"
+                    "NM=${CMAKE_NM}"
+                    "STRIP=${CMAKE_STRIP}"
+                    "CPPFLAGS=${CMAKE_C_FLAGS}"
+                    "--host=${MACHINE_NAME}"

Review comment:
       yes, working on it, i will push in a few sec.




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r624067311



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling

Review comment:
       ok, if you are ok with the image i can send a PR there.




-- 
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:
users@infra.apache.org



[GitHub] [tvm] leandron commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
leandron commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r620145762



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -21,7 +21,16 @@ ExternalProject_Add(project_libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"
+                    "NM=${CMAKE_NM}"
+                    "STRIP=${CMAKE_STRIP}"
+                    "CPPFLAGS=${CMAKE_C_FLAGS}"

Review comment:
       Just noticed this one probably needs updating as well.
   ```suggestion
                       "CPPFLAGS=${CMAKE_CXX_FLAGS}"
   ```




-- 
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:
users@infra.apache.org



[GitHub] [tvm] tqchen commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
tqchen commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-826088430


   @areusch @tkonolige @leandron please help to review this PR


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-846452920


   @tqchen i finished all the requested changes :) 


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r622013896



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a raspberry pi. Producing the runtime library can be done much faster on 
+hosts that have beefy processors (such as laptops, workstation) instead of target
+devices such as a raspberry pi. In-order to cross compile the runtime the toolchain
+for the target device must be installed. After installing the correct toolchain
+the main difference compared to compiling natively is to pass a bunch of command
+line argument to cmake that specify the compiler(s) to be used. For reference

Review comment:
       done




-- 
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:
users@infra.apache.org



[GitHub] [tvm] tkonolige commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
tkonolige commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r625176936



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -16,12 +16,28 @@
 # under the License.
 include(ExternalProject)
 
+
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND (CMAKE_C_COMPILER MATCHES "^/Library"
+  OR CMAKE_C_COMPILER MATCHES "^/Applications"))
+    set(c_compiler "/usr/bin/cc")
+  else()
+    set(c_compiler "${CMAKE_C_COMPILER}")
+endif()
+
 ExternalProject_Add(project_libbacktrace
   PREFIX libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"

Review comment:
       ```suggestion
                       "CC=${c_compiler}"
   ```
   You need this change to match the lines above.

##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -16,12 +16,28 @@
 # under the License.
 include(ExternalProject)
 
+
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND (CMAKE_C_COMPILER MATCHES "^/Library"
+  OR CMAKE_C_COMPILER MATCHES "^/Applications"))
+    set(c_compiler "/usr/bin/cc")
+  else()
+    set(c_compiler "${CMAKE_C_COMPILER}")
+endif()
+
 ExternalProject_Add(project_libbacktrace
   PREFIX libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"

Review comment:
       ```suggestion
                       "CPP=${c_compiler} -E"
   ```

##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -16,12 +16,28 @@
 # under the License.
 include(ExternalProject)
 
+

Review comment:
       Could you add this comment:
   
   ```
   # On MacOS, the default C compiler (/usr/bin/cc) is actually a small script that dispatches to a
   # compiler the default SDK (usually /Library/Developer/CommandLineTools/usr/bin/ or
   # /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/). CMake
   # automatically detects what is being dispatched and uses it instead along with all the flags it
   # needs. CMake makes this second compiler avaliable through the CMAKE_C_COMPILER variable, but it
   # does not make the necessary flags available. This leads to configuration errors in libbacktrace
   # because it can't find system libraries. Our solution is to detect if CMAKE_C_COMPILER lives in
   # /Library or /Applications and switch to the default compiler instead.
   ```




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-839666378


   > gentle ping @mherkazandjian please follow up on the review comments and let us merge soon !
   
   Hi @tqchen 
   sorry got distracted with some other work. I'll wrap this up before the end of the week.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] hogepodge commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
hogepodge commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r623211513



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling

Review comment:
       It would be helpful to describe why you would want to cross compile the runtime, and the difference between cross-compiling the runtime and cross-compiling the model.




-- 
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:
users@infra.apache.org



[GitHub] [tvm] tqchen merged pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
tqchen merged pull request #7917:
URL: https://github.com/apache/tvm/pull/7917


   


-- 
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:
users@infra.apache.org



[GitHub] [tvm] areusch commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
areusch commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-828910834


   @mherkazandjian i think the CI is having some trouble now, feel free to push an empty commit to retriever


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r621354544



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -21,7 +21,16 @@ ExternalProject_Add(project_libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"
+                    "NM=${CMAKE_NM}"
+                    "STRIP=${CMAKE_STRIP}"
+                    "CPPFLAGS=${CMAKE_C_FLAGS}"
+                    "--host=${MACHINE_NAME}"

Review comment:
       done, i built the doc locally and it is rendered ok




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r621038916



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -21,7 +21,16 @@ ExternalProject_Add(project_libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"

Review comment:
       i looked into the github repo of  [libbacktrace](https://github.com/ianlancetaylor/libbacktrace) and it seems here ``CPP``
   refers to the C preprocess (not C++), so it think it is correct to keep it as is.




-- 
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:
users@infra.apache.org



[GitHub] [tvm] tqchen commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
tqchen commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-851736364


   Thank you @mherkazandjian ! Thanks @tkonolige @hogepodge @areusch @leandron for reviewing


-- 
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:
users@infra.apache.org



[GitHub] [tvm] areusch commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
areusch commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r621345165



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -21,7 +21,16 @@ ExternalProject_Add(project_libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"
+                    "NM=${CMAKE_NM}"
+                    "STRIP=${CMAKE_STRIP}"
+                    "CPPFLAGS=${CMAKE_C_FLAGS}"
+                    "--host=${MACHINE_NAME}"

Review comment:
       okay cool. would it be possible for you to add the steps you took to cross-compile to the [install from source](https://tvm.apache.org/docs/install/from_source.html) docs?




-- 
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:
users@infra.apache.org



[GitHub] [tvm] hogepodge commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
hogepodge commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r623211513



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling

Review comment:
       It would be helpful to describe why you would want to cross compile the runtime.




-- 
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:
users@infra.apache.org



[GitHub] [tvm] hogepodge commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
hogepodge commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r638069401



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -14,14 +14,39 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+
+# On MacOS, the default C compiler (/usr/bin/cc) is actually a small script that dispatches to a
+# compiler the default SDK (usually /Library/Developer/CommandLineTools/usr/bin/ or

Review comment:
       On MacOS, the default C compiler (/usr/bin/cc) is script that dispatches to the compiler
   provided by the default SDK (usually /Library/Developer/CommandLineTools/usr/bin/ or

##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -14,14 +14,39 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+
+# On MacOS, the default C compiler (/usr/bin/cc) is actually a small script that dispatches to a
+# compiler the default SDK (usually /Library/Developer/CommandLineTools/usr/bin/ or
+# /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/). CMake
+# automatically detects what is being dispatched and uses it instead along with all the flags it
+# needs. CMake makes this second compiler avaliable through the CMAKE_C_COMPILER variable, but it
+# does not make the necessary flags available. This leads to configuration errors in libbacktrace
+# because it can't find system libraries. Our solution is to detect if CMAKE_C_COMPILER lives in
+# /Library or /Applications and switch to the default compiler instead.

Review comment:
       Our solution is to detect if CMAKE_C_COMPILER is installed in

##########
File path: docs/deploy/index.rst
##########
@@ -25,12 +25,20 @@ as well as how to integrate it with your project.
 
 .. image::  https://tvm.apache.org/images/release/tvm_flexible.png
 
+Build the TVM runtime library
+-----------------------------
+
+.. _build-tvm-runtime-on-target-device:
+
 Unlike traditional deep learning frameworks. TVM stack is divided into two major components:
 
-- TVM compiler, which does all the compilation and optimizations
+- TVM compiler, which does all the compilation and optimizations of the model
 - TVM runtime, which runs on the target devices.
 
-In order to integrate the compiled module, we **do not** need to build entire TVM on the target device. You only need to build the TVM compiler stack on your desktop and use that to cross-compile modules that are deployed on the target device.
+In order to integrate the compiled module, we **do not** need to build entire
+TVM on the target device. You only need to build the TVM compiler stack on your 

Review comment:
       we **do not** need to build the entire TVM project on the target device. Rather, we only need to build the TVM compiler stack on a host device and use that to cross-compile modules that can be deployed to a target device.




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-828597754


   > btw, I tried these same changes when debugging #7705 but they did not fix it.
   
   hi @tkonolige 
   
   
   > @mherkazandjian I'm sorry it took me so long to remember this, but I don't think this PR will work on macOS. Here is what I had in my version of this:
   > 
   > ```
   > # On MacOS, the default C compiler (/usr/bin/cc) is actually a small script that dispatches to a
   > # compiler the default SDK (usually /Library/Developer/CommandLineTools/usr/bin/ or
   > # /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/). CMake
   > # automatically detects what is being dispatched and uses it instead along with all the flags it
   > # needs. CMake makes this second compiler avaliable through the CMAKE_C_COMPILER variable, but it
   > # does not make the necessary flags available. This leads to configuration errors in libbacktrace
   > # because it can't find system libraries. Our solution is to detect if CMAKE_C_COMPILER lives in
   > # /Library or /Applications and switch to the default compiler instead.
   > if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND (CMAKE_C_COMPILER MATCHES "^/Library"
   >   OR CMAKE_C_COMPILER MATCHES "^/Applications"))
   >   set(c_compiler "/usr/bin/cc")
   > else()
   >   set(c_compiler "${CMAKE_C_COMPILER}")
   > endif()
   > ```
   > 
   > Note that this solution is not quite correct. You probably want to set the sdk path to whatever the user set it to.
   
   ok tnx for the update.
   Actually the CI is failing for all the builds (see below) not just for arm as i was thinking.
   ![image](https://user-images.githubusercontent.com/3264637/116439353-bc4d5700-a84f-11eb-801e-bdfbe7ef34f1.png)
   i think we need to pass ``-DMACHINE_NAME`` to cmake in the CI build scripts too.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r624171235



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling

Review comment:
       https://github.com/tlc-pack/web-data/pull/5




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-828872802


   > @mherkazandjian We should not require `MACHINE_NAME` be passed in as part of the build. The cmake script should check if it is set and then add the correct configure flags.
   
   @tkonolige i fixed the issue with the CI, the ``CPPFLAGS=${CMAKE_CXX_FLAGS}`` was the cause, I removed it since
   ``g++`` is not used/needed for libbacktrace (it is written in C).
   
   the macOS build seems to be passing 
   ![image](https://user-images.githubusercontent.com/3264637/116488928-eaed2100-a893-11eb-9f8c-725439b967df.png)
   
   following up on your comment https://github.com/apache/tvm/pull/7917#issuecomment-828562180 
   you mean including the snippet below in ``Libbacktrace.cmake`` (although ) fixes the issue for macOS? what did you mean
   by "although not correct?" 
   i do not have access to a mac.
   
   ````cmake
   if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND (CMAKE_C_COMPILER MATCHES "^/Library"
     OR CMAKE_C_COMPILER MATCHES "^/Applications"))
     set(c_compiler "/usr/bin/cc")
   else()
     set(c_compiler "${CMAKE_C_COMPILER}")
   endif()
   ````
   


-- 
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:
users@infra.apache.org



[GitHub] [tvm] hogepodge commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
hogepodge commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r624066350



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling

Review comment:
       https://github.com/tlc-pack/web-data




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r623911391



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a Raspberry Pi. Producing the runtime library can be done much faster on 
+hosts that have beefy processors (such as laptops, workstation) instead of target

Review comment:
       done




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r622010014



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compile the TVM runtime for other architectures
+-----------------------------------------------------
+
+In the example :ref:`above <build-tvm-runtime-on-target-device>` the runtime library was 
+compiled on a raspberry pi. Producing the runtime library can be done much faster on 
+hosts that have beefy processors (such as laptops, workstation) instead of target
+devices such as a raspberry pi. In-order to cross compile the runtime the toolchain
+for the target device must be installed. After installing the correct toolchain
+the main difference compared to compiling natively is to pass a bunch of command
+line argument to cmake that specify the compiler(s) to be used. For reference
+building the TVM runtime library on a modern laptop (using 8 threads) for ``aarch64``
+takes around 20 seconds vs ~10 min to build the runtime on a raspberry pi 4.
+
+cross-compile for aarch64
+"""""""""""""""""""""""""
+
+.. code-block:: bash
+
+   sudo apt-get update
+   sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
+
+.. code-block:: bash
+
+    cmake .. \
+        -DCMAKE_SYSTEM_NAME=Linux \
+        -DCMAKE_SYSTEM_VERSION=1 \
+        -DCMAKE_C_COMPILER=/usr/bin/aarch64-linux-gnu-gcc \
+        -DCMAKE_CXX_COMPILER=/usr/bin/aarch64-linux-gnu-g++ \
+        -DCMAKE_FIND_ROOT_PATH=/usr/aarch64-linux-gnu \
+        -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
+        -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
+        -DMACHINE_NAME=aarch64-linux-gnu 
+
+    make -j$(nproc) runtime
+
+For bare metal ARM devices the following toolchain is quite handy to install instead of gcc-aarch64-linux-*
+
+.. code-block:: bash
+
+   sudo apt-get install gcc-multilib-arm-linux-gnueabihf g++-multilib-arm-linux-gnueabihf
+
+
+cross-compile for RISC-V
+"""""""""""""""""""""""""
+
+.. code-block:: bash
+
+   sudo apt-get update
+   sudo apt-get install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu
+
+
+.. code-block:: bash
+
+    cmake .. \
+        -DCMAKE_SYSTEM_NAME=Linux \
+        -DCMAKE_SYSTEM_VERSION=1 \
+        -DCMAKE_C_COMPILER=/usr/bin/riscv64-linux-gnu-gcc \
+        -DCMAKE_CXX_COMPILER=/usr/bin/riscv64-linux-gnu-g++ \
+        -DCMAKE_FIND_ROOT_PATH=/usr/riscv64-linux-gnu \
+        -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
+        -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
+        -DMACHINE_NAME=riscv64-linux-gnu 
+
+    make -j$(nproc) runtime
+
+The ``file`` command can be used to query the architecture of the produced runtime.
+
+
+.. code-block:: bash
+
+   file file libtvm_runtime.so

Review comment:
       fixed




-- 
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:
users@infra.apache.org



[GitHub] [tvm] tqchen commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
tqchen commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-826088430


   @areusch @tkonolige @leandron please help to review this PR


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-828323209


   @leandron tnx for the feedback. actually the CI build is failing, i think the in the CI we (I) should modify the cmake flags so that
   libbacktrace now builds (it is failing in the CI). I will do it now.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] areusch commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
areusch commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r620458713



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -21,7 +21,16 @@ ExternalProject_Add(project_libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"
+                    "NM=${CMAKE_NM}"
+                    "STRIP=${CMAKE_STRIP}"
+                    "CPPFLAGS=${CMAKE_C_FLAGS}"
+                    "--host=${MACHINE_NAME}"

Review comment:
       I don't see this one documented in cmake, do you need to supply it with `cmake -DMACHINE_NAME=`?




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r623913069



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,105 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling

Review comment:
       i added a few lines on that and also i added a diagram the visually describes the process, i think that 
   improved the clarify compared to describing it by words
   
   this is how that is rendered in the documentation
   
   ![image](https://user-images.githubusercontent.com/3264637/116707916-7b7c4c00-a9cf-11eb-902f-c8aee573ee99.png)
   
   please let me know if it is ok to include the figure in ``deploy/images`` (i added that folder) in some other places figures
   are directly included from github rather than from files stores in the repo.
   




-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r621070046



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -21,7 +21,16 @@ ExternalProject_Add(project_libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"
+                    "NM=${CMAKE_NM}"
+                    "STRIP=${CMAKE_STRIP}"
+                    "CPPFLAGS=${CMAKE_C_FLAGS}"
+                    "--host=${MACHINE_NAME}"

Review comment:
       actually i am not sure is ``-DCMAKE_HOST`` is neccessary, but it does not hurt (i guess)




-- 
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:
users@infra.apache.org



[GitHub] [tvm] junrushao1994 commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
junrushao1994 commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-826128636


   CC @tkonolige @xiebaiyuan The issue is possibly related to #7705.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r622016346



##########
File path: docs/install/from_source.rst
##########
@@ -51,27 +51,31 @@ Build the Shared Library
 
 Our goal is to build the shared libraries:
 
-- On Linux the target library are `libtvm.so`
-- On macOS the target library are `libtvm.dylib`
-- On Windows the target library are `libtvm.dll`
+   - On Linux the target library are `libtvm.so` and `libtvm_runtime.so`
+   - On macOS the target library are `libtvm.dylib` and `libtvm_runtime.dylib` 
+   - On Windows the target library are `libtvm.dll` and `libtvm_runtime.dll` 
 
+It is also possible to :ref:`build the runtime <deploy-and-integration>` library only.
+
+The minimal building requirements for the ``TVM`` libraries are:
+
+   - A recent c++ compiler supporting C++ 14 (g++-5 or higher)
+   - CMake 3.5 or higher
+   - We highly recommend to build with LLVM to enable all the features.
+   - If you want to use CUDA, CUDA toolkit version >= 8.0 is required. If you are upgrading from an older version, make sure you purge the older version and reboot after installation.
+   - On macOS, you may want to install `Homebrew <https://brew.sh>` to easily install and manage dependencies.
+
+To install the these minimal pre-requisites on Ubuntu/Debian like
+linux operating systems, execute (in a terminal):
 
 .. code:: bash
 
     sudo apt-get update
     sudo apt-get install -y python3 python3-dev python3-setuptools gcc libtinfo-dev zlib1g-dev build-essential cmake libedit-dev libxml2-dev
 
-The minimal building requirements are
-
-- A recent c++ compiler supporting C++ 14 (g++-5 or higher)
-- CMake 3.5 or higher
-- We highly recommend to build with LLVM to enable all the features.
-- If you want to use CUDA, CUDA toolkit version >= 8.0 is required. If you are upgrading from an older version, make sure you purge the older version and reboot after installation.
-- On macOS, you may want to install `Homebrew <https://brew.sh>` to easily install and manage dependencies.
-
 
 We use cmake to build the library.
-The configuration of TVM can be modified by `config.cmake`.
+The configuration of TVM can be modified by `config.cmake` (and/or by passing cmake flags to the command line):

Review comment:
       done




-- 
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:
users@infra.apache.org



[GitHub] [tvm] leandron commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
leandron commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r620145762



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -21,7 +21,16 @@ ExternalProject_Add(project_libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"
+                    "NM=${CMAKE_NM}"
+                    "STRIP=${CMAKE_STRIP}"
+                    "CPPFLAGS=${CMAKE_C_FLAGS}"

Review comment:
       Just noticed this one probably needs updating as well.




-- 
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:
users@infra.apache.org



[GitHub] [tvm] hogepodge commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
hogepodge commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r625179150



##########
File path: docs/deploy/index.rst
##########
@@ -46,20 +54,118 @@ on a Linux based embedded system such as Raspberry Pi:
     cmake ..
     make runtime
 
-Note that we type `make runtime` to only build the runtime library.
+Note that we type ``make runtime`` to only build the runtime library.
+
+It is also possible to cross compile the runtime. Cross compiling
+the runtime library should not be confused with cross compiling models
+for embedded devices.
+
 If you want to include additional runtime such as OpenCL,
-you can modify `config.cmake` to enable these options.
+you can modify ``config.cmake`` to enable these options.
 After you get the TVM runtime library, you can link the compiled library
 
+Cross compiling a TVM model should not be confused with cross compiling the runtime
+shared library. 

Review comment:
       Duplicated wording




-- 
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:
users@infra.apache.org



[GitHub] [tvm] junrushao1994 commented on pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
junrushao1994 commented on pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#issuecomment-826128636


   CC @tkonolige @xiebaiyuan The issue is possibly related to #7705.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] mherkazandjian commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

Posted by GitBox <gi...@apache.org>.
mherkazandjian commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r621039089



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -21,7 +21,16 @@ ExternalProject_Add(project_libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"
+                    "NM=${CMAKE_NM}"
+                    "STRIP=${CMAKE_STRIP}"
+                    "CPPFLAGS=${CMAKE_C_FLAGS}"

Review comment:
       > Just noticed this one probably needs updating as well.
   
   done




-- 
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:
users@infra.apache.org