Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HARDWARE] VTA Specialised Accelerator Stack #1423

Merged
merged 40 commits into from
Jul 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a1f80a0
Initial commit
tmoreau89 Mar 1, 2018
8498335
hardware compilation flow, and driver tests
tmoreau89 Mar 16, 2018
0c8f0fc
doxygen path update
tmoreau89 Mar 16, 2018
971b615
[DOCS] Initial docs (#4)
tqchen Mar 17, 2018
43c451a
[REFACTOR] Code base refactoring (#5)
tmoreau89 Mar 18, 2018
f8df32c
[REFACTOR] Macro standardization, lint tests (#7)
tmoreau89 Mar 19, 2018
9129ed6
[PYTHON, TVM] Python TVM library, unit tests and end to end example
tmoreau89 Mar 23, 2018
dca87fe
fixing URL; adding () to print (#17)
gfursin Apr 8, 2018
092460c
Upgrade TVM to latest version
tqchen Apr 8, 2018
5d15b16
[RPC][RUNTIME] Support dynamic reload of runtime API according to con…
tqchen Apr 9, 2018
2fc7621
[SCHEDULER, HW] Auto scheduler for conv2d, hardware generation (#20)
tmoreau89 Apr 9, 2018
8eae56a
[COMPILER] Refactor compiler to enable configuration (#21)
tqchen Apr 11, 2018
38fa9fa
[DRIVER][RUNTIME] Make runtime fully device agnostic (#23)
tqchen Apr 11, 2018
226b929
[DRIVER] Add simulator, unify testcase to unittest (#25)
tqchen Apr 13, 2018
b4cf76a
[RUNTIME] Simplify dynamic library and code path. (#27)
tqchen Apr 14, 2018
dbb656d
[INFRASTRUCTURE] Migrate to json based config. Move gemm test to inte…
tqchen Apr 15, 2018
9a679d2
Refactor, refactor code structure, fix pynq rpc (#29)
tqchen Apr 15, 2018
9d50d46
[TEST] CI infrastructure (#30)
tqchen Apr 15, 2018
6b7da4d
fix jenkins (#31)
tqchen Apr 15, 2018
aaae8b5
[COMPILER] Upgrade to meet latest TVM IR pragma convention (#32)
tqchen Apr 15, 2018
bacd72d
[PYTHON] Enable environment scoping (#33)
tqchen May 1, 2018
240475e
[HARDWARE, TEST] Fixed hardware generation flow (#34)
tmoreau89 May 3, 2018
3fa87c3
[TOPI] Automated schedule in conv2d TOPI lib, moving to GEMM intrinsi…
tmoreau89 May 12, 2018
c8526d7
Update Graph Support for Batching, Fix Swapping (#37)
tqchen May 21, 2018
a9ff493
[BITSTREAM SERVER] Bitstream server integration (#38)
tmoreau89 May 23, 2018
fb4256c
[INIT] Allow proper throw in compiler (#39)
tqchen May 24, 2018
8f7a569
[EXAMPLE] Fix example for simulator (#40)
tqchen May 24, 2018
87d8c98
[DOC, EXAMPLE] Updated READMEs, tests, etc. (#41)
tmoreau89 May 25, 2018
92d109b
VTA and TVM on PYTHONPATH, also pass to sudo (#42)
maltanar May 29, 2018
f2653c8
Update TVM Version and CI scripts (#46)
tqchen Jun 19, 2018
24e9428
Update Jenkinsfile
tqchen Jun 20, 2018
5c8177b
[DOC] VTA installation & basic tutorials (#47)
tmoreau89 Jun 20, 2018
a81a167
[UTILS, DOC] Use TVM file downloading utility, conv2d tutorial (#48)
tmoreau89 Jun 22, 2018
680c6e4
[DOCKER] Cleanup docker image (#50)
tqchen Jun 24, 2018
420bdb7
[DOC, TVM] ResNet tutorial, updated TVM (#51)
tmoreau89 Jun 28, 2018
9f3f4fb
[TVM] Upgrade TVM Support
tqchen Jul 2, 2018
53399ed
[NNVM] Make param file python version agnostic
tqchen Jul 3, 2018
54668a1
[TUTORIAL] Resnet-18 end to end tutorial example (#55)
tmoreau89 Jul 3, 2018
d267eb1
[TOPI] Fix the CPU op perf (#56)
tqchen Jul 5, 2018
03a12ab
[BUILD][DOCS] Migrate VTA CI, test, build, docs
tqchen Jul 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
28 changes: 28 additions & 0 deletions docs/api/python/vta/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
VTA API
=======

This document contains the python API to VTA compiler toolchain.

.. automodule:: vta

Hardware Information
--------------------

.. autofunction:: vta.Environment
.. autofunction:: vta.get_env

RPC Utilities
-------------

.. autofunction:: vta.reconfig_runtime
.. autofunction:: vta.program_fpga


Compiler API
------------
We program VTA using TVM, so the compiler API in vta package
is only a thin wrapper to provide VTA specific extensions.

.. autofunction:: vta.build_config
.. autofunction:: vta.build
.. autofunction:: vta.lower
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