Skip to content

Commit

Permalink
Merge branch 'main' into relay_matmul_op
Browse files Browse the repository at this point in the history
  • Loading branch information
jcf94 committed Jun 28, 2021
2 parents 5300840 + 4ff5cef commit 49ffbd1
Show file tree
Hide file tree
Showing 114 changed files with 2,438 additions and 594 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ We do encourage everyone to work anything they are interested in.
- [Luis Vega](https://github.com/vegaluisjose): @vegaluisjose
- [Thomas Viehmann](https://github.com/t-vi): @t-vi
- [Yao Wang](https://github.com/kevinthesun): @kevinthesun
- [Yuchen Wang](https://github.com/wyc-ruiker): @wyc-ruiker
- [Leyuan Wang](https://github.com/Laurawly): @Laurawly
- [Alex Weaver](https://github.com/alex-weaver): @alex-weaver
- [Logan Weber](https://github.com/weberlo): @weberlo
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
//

// NOTE: these lines are scanned by docker/dev_common.sh. Please update the regex as needed. -->
ci_lint = "tlcpack/ci-lint:v0.65"
ci_lint = "tlcpack/ci-lint:v0.66"
ci_gpu = "tlcpack/ci-gpu:v0.75"
ci_cpu = "tlcpack/ci-cpu:v0.74"
ci_wasm = "tlcpack/ci-wasm:v0.71"
Expand Down
159 changes: 95 additions & 64 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,68 +15,89 @@
# specific language governing permissions and limitations
# under the License.


.PHONY: all \
runtime vta cpptest crttest \
lint pylint cpplint scalalint \
doc \
web webclean \
cython cython3 cyclean \
clean

.SECONDEXPANSION:

# Remember the root directory, to be usable by submake invocation.
ROOTDIR = $(CURDIR)
# Specify an alternate output directory relative to ROOTDIR. Default build
OUTPUTDIR = $(if $(OUTDIR), $(OUTDIR), build)

.PHONY: clean all test doc pylint cpplint scalalint lint\
cython cython2 cython3 web runtime vta
# Specify an alternate output directory relative to ROOTDIR. Defaults
# to "build". Can also be a space-separated list of build
# directories, each with a different configuation.
TVM_BUILD_PATH ?= build
TVM_BUILD_PATH := $(abspath $(TVM_BUILD_PATH))

ifndef DMLC_CORE_PATH
DMLC_CORE_PATH = $(ROOTDIR)/3rdparty/dmlc-core
endif
# Allow environment variables for 3rd-party libraries, default to
# packaged version.
DMLC_CORE_PATH ?= $(ROOTDIR)/3rdparty/dmlc-core
DLPACK_PATH ?= $(ROOTDIR)/3rdparty/dlpack
VTA_HW_PATH ?= $(ROOTDIR)/3rdparty/vta-hw

ifndef DLPACK_PATH
DLPACK_PATH = $(ROOTDIR)/3rdparty/dlpack
endif

ifndef VTA_HW_PATH
VTA_HW_PATH = $(ROOTDIR)/3rdparty/vta-hw
endif

INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include
PKG_CFLAGS = -std=c++11 -Wall -O2 $(INCLUDE_FLAGS) -fPIC
PKG_LDFLAGS =

all: $(addsuffix /all,$(TVM_BUILD_PATH))

all:
@mkdir -p $(OUTPUTDIR) && cd $(OUTPUTDIR) && cmake .. && $(MAKE)
runtime: $(addsuffix /runtime,$(TVM_BUILD_PATH))
vta: $(addsuffix /vta,$(TVM_BUILD_PATH))
cpptest: $(addsuffix /cpptest,$(TVM_BUILD_PATH))
crttest: $(addsuffix /crttest,$(TVM_BUILD_PATH))

runtime:
@mkdir -p $(OUTPUTDIR) && cd $(OUTPUTDIR) && cmake .. && $(MAKE) runtime
# If there is a config.cmake in the tvm directory, preferentially use
# it. Otherwise, copy the default cmake/config.cmake.
ifeq ($(wildcard config.cmake),config.cmake)
%/config.cmake: | config.cmake
@echo "No config.cmake found in $(TVM_BUILD_PATH), using config.cmake in root tvm directory"
@mkdir -p $(@D)
else
# filter-out used to avoid circular dependency
%/config.cmake: | $$(filter-out %/config.cmake,$(ROOTDIR)/cmake/config.cmake)
@echo "No config.cmake found in $(TVM_BUILD_PATH), using default config.cmake"
@mkdir -p $(@D)
@cp $| $@
endif

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

cpptest:
@mkdir -p $(OUTPUTDIR) && cd $(OUTPUTDIR) && cmake .. && $(MAKE) cpptest
# Cannot use .PHONY with a pattern rule, using FORCE instead. For
# now, force cmake to be re-run with each compile to mimic previous
# behavior. This may be relaxed in the future with the
# CONFIGURE_DEPENDS option for GLOB (requres cmake >= 3.12).
FORCE:
%/CMakeCache.txt: %/config.cmake FORCE
@cd $(@D) && cmake $(ROOTDIR)

crttest:
@mkdir -p $(OUTPUTDIR) && cd $(OUTPUTDIR) && cmake .. && $(MAKE) crttest

# EMCC; Web related scripts
EMCC_FLAGS= -std=c++11\
-Oz -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1\
-s TOTAL_MEMORY=1073741824\
-s EXTRA_EXPORTED_RUNTIME_METHODS="['addFunction','cwrap','getValue','setValue']"\
-s USE_GLFW=3 -s USE_WEBGL2=1 -lglfw\
$(INCLUDE_FLAGS)
# Since the pattern stem is already being used for the directory name,
# cannot also have it refer to the command passed to cmake.
# Therefore, explicitly listing out the delegated.
CMAKE_TARGETS = all runtime vta cpptest crttest

web: $(OUTPUTDIR)/libtvm_web_runtime.js $(OUTPUTDIR)/libtvm_web_runtime.bc
define GEN_CMAKE_RULE
%/$(CMAKE_TARGET): %/CMakeCache.txt
@$$(MAKE) -C $$(@D) $(CMAKE_TARGET)
endef
$(foreach CMAKE_TARGET,$(CMAKE_TARGETS),$(eval $(GEN_CMAKE_RULE)))

$(OUTPUTDIR)/libtvm_web_runtime.bc: web/web_runtime.cc
@mkdir -p $(OUTPUTDIR)/web
@mkdir -p $(@D)
emcc $(EMCC_FLAGS) -MM -MT $(OUTPUTDIR)/libtvm_web_runtime.bc $< >$(OUTPUTDIR)/web/web_runtime.d
emcc $(EMCC_FLAGS) -o $@ web/web_runtime.cc

$(OUTPUTDIR)/libtvm_web_runtime.js: $(OUTPUTDIR)/libtvm_web_runtime.bc
@mkdir -p $(@D)
emcc $(EMCC_FLAGS) -o $@ $(OUTPUTDIR)/libtvm_web_runtime.bc

# Lint scripts
# NOTE: lint scripts that are executed in the CI should be in tests/lint. This allows docker/lint.sh
# to behave similarly to the CI.
# Dev tools for formatting, linting, and documenting. NOTE: lint
# scripts that are executed in the CI should be in tests/lint. This
# allows docker/lint.sh to behave similarly to the CI.
format:
./tests/lint/git-clang-format.sh -i origin/main
black .
cd rust && which cargo && cargo fmt --all

lint: cpplint pylint jnilint

cpplint:
tests/lint/cpplint.sh

Expand All @@ -89,26 +110,36 @@ jnilint:
scalalint:
make -C $(VTA_HW_PATH)/hardware/chisel lint

lint: cpplint pylint jnilint

mypy:
tests/scripts/task_mypy.sh

doc:
doxygen docs/Doxyfile

javadoc:
# build artifact is in jvm/core/target/site/apidocs
cd jvm && mvn javadoc:javadoc -Dnotimestamp=true

# Cython build
cython:
cd python; python3 setup.py build_ext --inplace

cython3:
cython cython3:
cd python; python3 setup.py build_ext --inplace

cyclean:
rm -rf python/tvm/*/*/*.so python/tvm/*/*/*.dylib python/tvm/*/*/*.cpp



# EMCC; Web related scripts
web:
$(MAKE) -C $(ROOTDIR)/web

webclean:
$(MAKE) -C $(ROOTDIR)/web clean


# JVM build rules
INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include
PKG_CFLAGS = -std=c++11 -Wall -O2 $(INCLUDE_FLAGS) -fPIC
PKG_LDFLAGS =

ifeq ($(OS),Windows_NT)
JVM_PKG_PROFILE := windows
SHARED_LIBRARY_SUFFIX := dll
Expand All @@ -123,24 +154,24 @@ else
endif
endif

JVM_TEST_ARGS := $(if $(JVM_TEST_ARGS),$(JVM_TEST_ARGS),-DskipTests -Dcheckstyle.skip=true)
JVM_TEST_ARGS ?= -DskipTests -Dcheckstyle.skip=true

# Built java docs are in jvm/core/target/site/apidocs
javadoc:
(cd $(ROOTDIR)/jvm; \
mvn "javadoc:javadoc" -Dnotimestamp=true)

jvmpkg:
(cd $(ROOTDIR)/jvm; \
mvn clean package -P$(JVM_PKG_PROFILE) -Dcxx="$(CXX)" \
-Dcflags="$(PKG_CFLAGS)" -Dldflags="$(PKG_LDFLAGS)" \
-Dcurrent_libdir="$(ROOTDIR)/$(OUTPUTDIR)" $(JVM_TEST_ARGS))
-Dcurrent_libdir="$(TVM_BUILD_PATH)" $(JVM_TEST_ARGS))

jvminstall:
(cd $(ROOTDIR)/jvm; \
mvn install -P$(JVM_PKG_PROFILE) -Dcxx="$(CXX)" \
-Dcflags="$(PKG_CFLAGS)" -Dldflags="$(PKG_LDFLAGS)" \
-Dcurrent_libdir="$(ROOTDIR)/$(OUTPUTDIR)" $(JVM_TEST_ARGS))
format:
./tests/lint/git-clang-format.sh -i origin/main
black .
cd rust; which cargo && cargo fmt --all; cd ..

-Dcurrent_libdir="$(TVM_BUILD_PATH)" $(JVM_TEST_ARGS))

# clean rule
clean:
@mkdir -p $(OUTPUTDIR) && cd $(OUTPUTDIR) && cmake .. && $(MAKE) clean
# Final cleanup rules, delegate to more specific rules.
clean: cmake_clean cyclean webclean
20 changes: 19 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,33 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import tvm.testing
import pytest
from pytest import ExitCode

import tvm
import tvm.testing


def pytest_configure(config):
print("enabled targets:", "; ".join(map(lambda x: x[0], tvm.testing.enabled_targets())))
print("pytest marker:", config.option.markexpr)


@pytest.fixture
def dev(target):
return tvm.device(target)


def pytest_generate_tests(metafunc):
tvm.testing._auto_parametrize_target(metafunc)
tvm.testing._parametrize_correlated_parameters(metafunc)


def pytest_collection_modifyitems(config, items):
tvm.testing._count_num_fixture_uses(items)
tvm.testing._remove_global_fixture_definitions(items)


def pytest_sessionfinish(session, exitstatus):
# Don't exit with an error if we select a subset of tests that doesn't
# include anything
Expand Down
8 changes: 4 additions & 4 deletions docker/Dockerfile.ci_cpu
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ RUN bash /install/ubuntu_install_sbt.sh
COPY install/ubuntu_install_verilator.sh /install/ubuntu_install_verilator.sh
RUN bash /install/ubuntu_install_verilator.sh

# TFLite deps
COPY install/ubuntu_install_tflite.sh /install/ubuntu_install_tflite.sh
RUN bash /install/ubuntu_install_tflite.sh

# TensorFlow deps
COPY install/ubuntu_install_tensorflow.sh /install/ubuntu_install_tensorflow.sh
RUN bash /install/ubuntu_install_tensorflow.sh

# TFLite deps
COPY install/ubuntu_install_tflite.sh /install/ubuntu_install_tflite.sh
RUN bash /install/ubuntu_install_tflite.sh

# Compute Library
COPY install/ubuntu_download_arm_compute_lib_binaries.sh /install/ubuntu_download_arm_compute_lib_binaries.sh
RUN bash /install/ubuntu_download_arm_compute_lib_binaries.sh
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.ci_lint
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN bash /install/ubuntu1804_install_python.sh

RUN apt-get update && apt-get install -y doxygen graphviz

RUN pip3 install cpplint pylint==2.4.4 mypy black==20.8b1
RUN pip3 install cpplint pylint==2.4.4 mypy==0.902 black==20.8b1

# java deps for rat
COPY install/ubuntu_install_java.sh /install/ubuntu_install_java.sh
Expand Down
8 changes: 4 additions & 4 deletions docker/Dockerfile.ci_qemu
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ RUN bash /install/ubuntu_install_redis.sh
COPY install/ubuntu_install_java.sh /install/ubuntu_install_java.sh
RUN bash /install/ubuntu_install_java.sh

# TFLite deps
COPY install/ubuntu_install_tflite.sh /install/ubuntu_install_tflite.sh
RUN bash /install/ubuntu_install_tflite.sh

# TensorFlow deps
COPY install/ubuntu_install_tensorflow.sh /install/ubuntu_install_tensorflow.sh
RUN bash /install/ubuntu_install_tensorflow.sh

# TFLite deps
COPY install/ubuntu_install_tflite.sh /install/ubuntu_install_tflite.sh
RUN bash /install/ubuntu_install_tflite.sh

# QEMU deps
COPY install/ubuntu_install_qemu.sh /install/ubuntu_install_qemu.sh
RUN bash /install/ubuntu_install_qemu.sh
Expand Down
4 changes: 4 additions & 0 deletions docker/install/ubuntu_install_nodejs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ set -u
set -o pipefail

apt-get update
# Please do not remove 'curl' package installation from here, as this
# script runs in some images (e.g. ci_lint) that keep a very mininal
# set of packages installed by default.
apt-get install -y curl

# The node install script fetched and executed here will update the
# apt source list, hence the second apt-get update is necessary.
Expand Down
2 changes: 1 addition & 1 deletion docker/install/ubuntu_install_sphinx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ set -u
set -o pipefail

# NOTE: install docutils < 0.17 to work around https://github.com/readthedocs/sphinx_rtd_theme/issues/1115
pip3 install sphinx sphinx-gallery==0.4.0 autodocsumm sphinx_rtd_theme sphinx_autodoc_annotation matplotlib Image "commonmark>=0.7.3" "docutils>=0.11" "docutils<0.17"
pip3 install sphinx sphinx-gallery==0.4.0 autodocsumm sphinx_rtd_theme sphinx_autodoc_annotation matplotlib Image "commonmark>=0.7.3" "docutils>=0.11,<0.17"
1 change: 1 addition & 0 deletions docs/api/python/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Python API
==========


.. toctree::
:maxdepth: 2

Expand Down
1 change: 1 addition & 0 deletions docs/api/python/relay/image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ tvm.relay.image
.. automodule:: tvm.relay.image
:members:
:imported-members:
:exclude-members: Expr, Constant
:autosummary:
1 change: 1 addition & 0 deletions docs/api/python/relay/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ tvm.relay
TypeVar, GlobalTypeVar, TypeConstraint, FuncType, TupleType, IncompleteType,
TypeCall, TypeRelation, TensorType, RelayRefType, GlobalVar, SourceName,
Span, Var, Op, Constructor
:noindex: TypeData
:autosummary:
1 change: 1 addition & 0 deletions docs/api/python/tir.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ tvm.tir.analysis
.. automodule:: tvm.tir.analysis
:members:
:imported-members:
:noindex: Buffer, Stmt
:autosummary:


Expand Down
1 change: 1 addition & 0 deletions docs/api/python/topi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tvm.topi
.. automodule:: tvm.topi
:members:
:imported-members:
:noindex: AssertStmt
:autosummary:

tvm.topi.nn
Expand Down
1 change: 1 addition & 0 deletions docs/dev/device_target_interactions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
specific language governing permissions and limitations
under the License.
.. _tvm-target-specific-overview:

Device/Target Interactions
Expand Down
Loading

0 comments on commit 49ffbd1

Please sign in to comment.