Skip to content

Commit

Permalink
[BUILD][DOCS] Migrate VTA CI, test, build, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen committed Jul 12, 2018
1 parent 0af7131 commit 600d106
Show file tree
Hide file tree
Showing 80 changed files with 334 additions and 4,526 deletions.
26 changes: 5 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ include(cmake/util/FindVulkan.cmake)
include(cmake/util/FindLLVM.cmake)
include(cmake/util/FindROCM.cmake)


if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build/private/local_config.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/build/private/local_config.cmake)
endif()

if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
else()
Expand Down Expand Up @@ -40,6 +35,8 @@ tvm_option(USE_RTTI "Build with RTTI" ON)
tvm_option(USE_MSVC_MT "Build with MT" OFF)
tvm_option(INSTALL_DEV "Install compiler infrastructure" OFF)

tvm_option(USE_VTA_CFG "Use a specific json file for VTA runtime" "")

# Contrib library options
tvm_option(USE_BLAS "The blas library to be linked" none)
tvm_option(USE_MKL_PATH "MKL root path when use MKL blas" none)
Expand All @@ -52,8 +49,9 @@ tvm_option(USE_NNPACK "Build with nnpack support" OFF)
tvm_option(USE_RANDOM "Build with random support" OFF)

# include directories
include_directories(BEFORE "nnvm/include")
include_directories("include")
include_directories("nnvm/include")
include_directories("dmlc-core/include")
include_directories("HalideIR/src")
include_directories("dlpack/include")
include_directories("topi/include")
Expand Down Expand Up @@ -148,20 +146,8 @@ if(USE_GRAPH_RUNTIME)
endif(USE_GRAPH_RUNTIME_DEBUG)
endif(USE_GRAPH_RUNTIME)

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/dmlc-core/CMakeLists.txt)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dmlc-core/include)
if (INSTALL_DEV)
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/dmlc-core/include/." DESTINATION "include"
FILES_MATCHING
PATTERN "*.h"
)
endif()
elseif(DMLC_CORE_PATH)
include_directories(${DMLC_CORE_PATH}/include)
endif()

# Module rules
include(cmake/modules/VTA.cmake)
include(cmake/modules/CUDA.cmake)
include(cmake/modules/OpenCL.cmake)
include(cmake/modules/OpenGL.cmake)
Expand All @@ -174,7 +160,6 @@ include(cmake/modules/contrib/Random.cmake)
include(cmake/modules/contrib/Sort.cmake)
include(cmake/modules/contrib/NNPack.cmake)

# Target rrules
add_library(tvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS})
add_library(tvm_topi SHARED ${TOPI_SRCS})
add_library(tvm_runtime SHARED ${RUNTIME_SRCS})
Expand Down Expand Up @@ -207,7 +192,6 @@ endif()
# Custom targets
add_custom_target(runtime DEPENDS tvm_runtime)


# Installation rulse
install(TARGETS tvm_runtime DESTINATION lib${LIB_SUFFIX})
if(WIN32)
Expand Down
4 changes: 3 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tvm_runtime = "build/libtvm_runtime.so, build/config.cmake"
tvm_lib = "build/libtvm.so, " + tvm_runtime
// LLVM upstream lib
tvm_multilib = "build/libtvm.so, " +
"build/libtvm_topi.so, build/libnnvm_compiler.so, " + tvm_runtime
"build/libvta.so, build/libtvm_topi.so, build/libnnvm_compiler.so, " + tvm_runtime

// command to start a docker container
docker_run = 'docker/build.sh'
Expand Down Expand Up @@ -134,6 +134,7 @@ stage('Build') {
pack_lib('cpu', tvm_lib)
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} ci_cpu ./tests/scripts/task_cpp_unittest.sh"
sh "${docker_run} ci_cpu ./tests/scripts/task_python_vta.sh"
}
}
}
Expand Down Expand Up @@ -179,6 +180,7 @@ stage('Unit Test') {
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} ci_i386 ./tests/scripts/task_python_unittest.sh"
sh "${docker_run} ci_i386 ./tests/scripts/task_python_integration.sh"
sh "${docker_run} ci_i386 ./tests/scripts/task_python_vta.sh"
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ROOTDIR = $(CURDIR)

.PHONY: clean all test doc pylint cpplint lint\
cython cython2 cython3 web runtime
cython cython2 cython3 web runtime vta

ifndef DMLC_CORE_PATH
DMLC_CORE_PATH = $(ROOTDIR)/dmlc-core
Expand All @@ -20,9 +20,11 @@ all:
@mkdir -p build && cd build && cmake .. && $(MAKE)

runtime:

@mkdir -p build && cd build && cmake .. && $(MAKE) runtime

vta:
@mkdir -p build && cd build && cmake .. && $(MAKE) vta

cpptest:
@mkdir -p build && cd build && cmake .. && $(MAKE) cpptest

Expand All @@ -48,6 +50,7 @@ build/libtvm_web_runtime.js: build/libtvm_web_runtime.bc

# Lint scripts
cpplint:
python3 dmlc-core/scripts/lint.py vta cpp vta/include vta/src
python3 dmlc-core/scripts/lint.py topi cpp topi/include;
python3 dmlc-core/scripts/lint.py nnvm cpp nnvm/include nnvm/src;
python3 dmlc-core/scripts/lint.py tvm cpp include src verilog\
Expand All @@ -57,6 +60,7 @@ pylint:
python3 -m pylint python/tvm --rcfile=$(ROOTDIR)/tests/lint/pylintrc
python3 -m pylint topi/python/topi --rcfile=$(ROOTDIR)/tests/lint/pylintrc
python3 -m pylint nnvm/python/nnvm --rcfile=$(ROOTDIR)/tests/lint/pylintrc
python3 -m pylint vta/python/vta --rcfile=$(ROOTDIR)/tests/lint/pylintrc

jnilint:
python3 dmlc-core/scripts/lint.py tvm4j-jni cpp jvm/native/src
Expand Down
5 changes: 5 additions & 0 deletions apps/pynq_rpc/start_rpc_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
PROJROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../" && pwd )"

export PYTHONPATH=${PYTHONPATH}:${PROJROOT}/python:${PROJROOT}/vta/python
python -m vta.exec.rpc_server
51 changes: 51 additions & 0 deletions cmake/modules/VTA.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# CMake Build rules for VTA
find_program(PYTHON python)

if(MSVC)
message(STATUS "VTA build is skipped in Windows..")
elseif(PYTHON)
set(VTA_CONFIG ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/vta/config/vta_config.py)

if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/vta_config.json)
message(STATUS "Use VTA config " ${CMAKE_CURRENT_BINARY_DIR}/vta_config.json)
set(VTA_CONFIG ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/vta/config/vta_config.py
--use-cfg=${CMAKE_CURRENT_BINARY_DIR}/vta_config.json)
endif()

execute_process(COMMAND ${VTA_CONFIG} --target OUTPUT_VARIABLE __vta_target)
string(STRIP ${__vta_target} VTA_TARGET)

message(STATUS "Build VTA runtime with target: " ${VTA_TARGET})

execute_process(COMMAND ${VTA_CONFIG} --defs OUTPUT_VARIABLE __vta_defs)

string(REGEX MATCHALL "(^| )-D[A-Za-z0-9_=.]*" VTA_DEFINITIONS "${__vta_defs}")

file(GLOB VTA_RUNTIME_SRCS vta/src/*.cc)
file(GLOB __vta_target_srcs vta/src/${VTA_TARGET}/*.cc)
list(APPEND VTA_RUNTIME_SRCS ${__vta_target_srcs})

add_library(vta SHARED ${VTA_RUNTIME_SRCS})

target_include_directories(vta PUBLIC vta/include)

foreach(__def ${VTA_DEFINITIONS})
string(SUBSTRING ${__def} 3 -1 __strip_def)
target_compile_definitions(vta PUBLIC ${__strip_def})
endforeach()

if(APPLE)
set_target_properties(vta PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif(APPLE)

# PYNQ rules
if(${VTA_TARGET} STREQUAL "pynq")
find_library(__sds_lib NAMES sds_lib PATHS /usr/lib)
find_library(__dma_lib NAMES dma PATHS
"/opt/python3.6/lib/python3.6/site-packages/pynq/drivers/"
"/opt/python3.6/lib/python3.6/site-packages/pynq/lib/")
target_link_libraries(vta ${__sds_lib} ${__dma_lib})
endif()
else()
message(STATUS "Cannot found python in env, VTA build is skipped..")
endif()
2 changes: 1 addition & 1 deletion docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.

INPUT = include/tvm topi/include/topi nnvm/include/nnvm
INPUT = include/tvm topi/include/topi nnvm/include/nnvm vta/include/vta

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
2 changes: 2 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ help:
clean:
rm -rf $(BUILDDIR)/*
rm -rf gen_modules
rm -rf tutorials
rm -rf vta/tutorials

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
Expand Down
26 changes: 24 additions & 2 deletions docs/README.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
The documentation of tvm is generated with recommonmark and sphinx.
TVM Documentations
==================
This folder contains the source of TVM documents

- A hosted version of doc is at http://docs.tvm.ai
- pip install sphinx>=1.5.5 sphinx-gallery sphinx_rtd_theme matplotlib Image recommonmark
- pip install sphinx>=1.5.5 sphinx-gallery sphinx_rtd_theme matplotlib Image recommonmark Pillow
- Build tvm first in the root folder.
- To build locally, you need to enable USE_CUDA, USE_OPENCL, LLVM_CONFIG in config.mk and then type "make html" in this folder.

Only Execute Specified Tutorials
--------------------------------
The document build process will execute all the tutorials in the sphinx gallery.
This will cause failure in some cases when certain machines do not have necessary
environment. You can set ```TVM_TUTORIAL_EXEC_PATTERN``` to only execute
the path that matches the regular expression pattern.

For example, to only build tutorials under /vta/tutorials, run

```bash
TVM_TUTORIAL_EXEC_PATTERN=/vta/tutorials make html
```

To only build one specific file, do

```bash
# The slash \ is used to get . in regular expression
TVM_TUTORIAL_EXEC_PATTERN=file_name\.py make html
```
4 changes: 0 additions & 4 deletions docs/api/python/hybrid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ tvm.hybrid

tvm.hybrid.parse
tvm.hybrid.script
tvm.hybrid.popcount
tvm.hybrid.sigmoid

.. autofunction:: tvm.hybrid.parse
.. autofunction:: tvm.hybrid.script
.. autofunction:: tvm.hybrid.popcount
.. autofunction:: tvm.hybrid.sigmoid
1 change: 1 addition & 0 deletions docs/api/python/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ Python API
contrib
dev
topi
vta/index
nnvm/index
hybrid
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Python API
==========
VTA API
=======

This document contains the python API to VTA compiler toolchain.

Expand Down
10 changes: 6 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
sys.path.insert(0, os.path.join(curr_path, '../python/'))
sys.path.insert(0, os.path.join(curr_path, '../topi/python'))
sys.path.insert(0, os.path.join(curr_path, '../nnvm/python'))
sys.path.insert(0, os.path.join(curr_path, '../vta/python'))

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -184,16 +185,17 @@ def run_doxygen(folder):

from sphinx_gallery.sorting import ExplicitOrder

examples_dirs = ['../tutorials/']
gallery_dirs = ['tutorials']
examples_dirs = ["../tutorials/", "../vta/tutorials/"]
gallery_dirs = ["tutorials", "vta/tutorials"]

subsection_order = ExplicitOrder(
['../tutorials/language',
'../tutorials/optimize',
'../tutorials/vta',
'../tutorials/topi',
'../tutorials/deployment',
'../tutorials/nnvm'])


def generate_doxygen_xml(app):
"""Run the doxygen make commands if we're on the ReadTheDocs server"""
run_doxygen('..')
Expand All @@ -220,7 +222,7 @@ def setup(app):
'examples_dirs': examples_dirs,
'gallery_dirs': gallery_dirs,
'subsection_order': subsection_order,
'filename_pattern': os.environ.get("TVM_TUTORIAL_EXEC_PATTERN", ".py"),
'find_mayavi_figures': False,
'filename_pattern': '.py',
'expected_failing_examples': []
}
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Get Started

install/index
tutorials/index
vta/index
deploy/index
contribute/index
faq
Expand Down
1 change: 0 additions & 1 deletion docs/install/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Installation
============

To install TVM, please read :ref:`install-from-source`.
If you are interested in deploying to mobile/embedded devices,
you do not need to install the entire tvm stack on your device,
Expand Down
1 change: 1 addition & 0 deletions docs/vta/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tutorials
2 changes: 2 additions & 0 deletions docs/vta/hardware.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VTA Hardware Design Overview
============================
23 changes: 23 additions & 0 deletions docs/vta/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
VTA: Deep Learning Accelerator Stack
====================================
Specialized accelerators are key enablers of future deep learning workloads. TVM stack targets specialized accelerators.
VTA(versatile tensor accelerator) is a generic, modular open-source deep learning accelerator.
This page contains links to all the resources related to VTA:

.. toctree::
:maxdepth: 1

install
tutorials/index
hardware


Features
--------
VTA have the following key features:

- Generic, modular open-source hardware
- Streamlined workflow to deploy to FPGAs.
- Simulator support to protoype compilation passes on regular workstations.
- Driver and JIT runtime for both simulated and FPGA hardware backend.
- End to end TVM stack integration
Loading

0 comments on commit 600d106

Please sign in to comment.