Skip to content

Commit

Permalink
[DEPRECATION] Remove NNVM compiler (#4571)
Browse files Browse the repository at this point in the history
* Remove NNVM compiler
  • Loading branch information
tqchen committed Dec 23, 2019
1 parent 9bf2bee commit f9bc748
Show file tree
Hide file tree
Showing 201 changed files with 45 additions and 39,925 deletions.
28 changes: 3 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ else(MSVC)
endif(MSVC)

# add source group
FILE(GLOB_RECURSE GROUP_SOURCE "src/*.cc" "nnvm/src/*.cc")
FILE(GLOB_RECURSE GROUP_INCLUDE "src/*.h" "include/*.h"
"nnvm/src/*.h" "nnvm/include/*.h")
FILE(GLOB_RECURSE GROUP_SOURCE "src/*.cc")
FILE(GLOB_RECURSE GROUP_INCLUDE "src/*.h" "include/*.h")
assign_source_group("Source" ${GROUP_SOURCE})
assign_source_group("Include" ${GROUP_INCLUDE})

Expand Down Expand Up @@ -174,13 +173,6 @@ if(NOT MSVC)
list(APPEND COMPILER_SRCS ${COMPILER_VERILOG_SRCS})
endif()

file(GLOB_RECURSE NNVM_COMPILER_SRCS
nnvm/src/c_api/*.cc
nnvm/src/core/*.cc
nnvm/src/pass/*.cc
nnvm/src/compiler/*.cc
nnvm/src/top/*.cc
)

file(GLOB TOPI_SRCS
topi/src/*.cc
Expand Down Expand Up @@ -294,7 +286,6 @@ if(NOT USE_SGX STREQUAL "OFF")
add_dependencies(tvm_runtime sgx_edl tvm_t)
install(TARGETS tvm_t ARCHIVE DESTINATION lib${LIB_SUFFIX})
endif()
add_library(nnvm_compiler SHARED ${NNVM_COMPILER_SRCS})

if(USE_THREADS)
message(STATUS "Build with thread support...")
Expand All @@ -304,13 +295,11 @@ if(USE_THREADS)
target_link_libraries(tvm Threads::Threads)
target_link_libraries(tvm_topi Threads::Threads)
target_link_libraries(tvm_runtime Threads::Threads)
target_link_libraries(nnvm_compiler Threads::Threads)
endif(USE_THREADS)

target_link_libraries(tvm ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS})
target_link_libraries(tvm_topi tvm ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS})
target_link_libraries(tvm_runtime ${TVM_RUNTIME_LINKER_LIBS})
target_link_libraries(nnvm_compiler tvm)

if (HIDE_PRIVATE_SYMBOLS AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(HIDE_SYMBOLS_LINKER_FLAGS "-Wl,--exclude-libs,ALL")
Expand All @@ -320,7 +309,6 @@ if (HIDE_PRIVATE_SYMBOLS AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_link_libraries(tvm ${HIDE_SYMBOLS_LINKER_FLAGS})
target_link_libraries(tvm_topi ${HIDE_SYMBOLS_LINKER_FLAGS})
target_link_libraries(tvm_runtime ${HIDE_SYMBOLS_LINKER_FLAGS})
target_link_libraries(nnvm_compiler ${HIDE_SYMBOLS_LINKER_FLAGS})
endif()

# Related headers
Expand All @@ -330,10 +318,7 @@ target_include_directories(
target_include_directories(
tvm_topi
PUBLIC "topi/include")
target_include_directories(
nnvm_compiler
PUBLIC "nnvm/include"
PUBLIC "topi/include")


# Tests
set(TEST_EXECS "")
Expand Down Expand Up @@ -372,7 +357,6 @@ add_custom_target(runtime DEPENDS tvm_runtime)
install(TARGETS tvm DESTINATION lib${LIB_SUFFIX})
install(TARGETS tvm_topi DESTINATION lib${LIB_SUFFIX})
install(TARGETS tvm_runtime DESTINATION lib${LIB_SUFFIX})
install(TARGETS nnvm_compiler DESTINATION lib${LIB_SUFFIX})

if (INSTALL_DEV)
install(
Expand All @@ -395,11 +379,6 @@ if (INSTALL_DEV)
FILES_MATCHING
PATTERN "*.h"
)
install(
DIRECTORY "nnvm/include/." DESTINATION "include"
FILES_MATCHING
PATTERN "*.h"
)
else(INSTALL_DEV)
install(
DIRECTORY "include/tvm/runtime/." DESTINATION "include/tvm/runtime"
Expand All @@ -412,5 +391,4 @@ endif(INSTALL_DEV)
if(MSVC)
target_compile_definitions(tvm PRIVATE -DTVM_EXPORTS)
target_compile_definitions(tvm_runtime PRIVATE -DTVM_EXPORTS)
target_compile_definitions(nnvm_compiler PRIVATE -DNNVM_EXPORTS)
endif()
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,12 @@ build/libtvm_web_runtime.js: build/libtvm_web_runtime.bc
cpplint:
python3 3rdparty/dmlc-core/scripts/lint.py vta cpp vta/include vta/src
python3 3rdparty/dmlc-core/scripts/lint.py topi cpp topi/include;
python3 3rdparty/dmlc-core/scripts/lint.py nnvm cpp nnvm/include nnvm/src;
python3 3rdparty/dmlc-core/scripts/lint.py tvm cpp include src \
examples/extension/src examples/graph_executor/src

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:
Expand Down
8 changes: 2 additions & 6 deletions conda/tvm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand All @@ -26,7 +26,3 @@ cd ..
cd topi/python
$PYTHON setup.py install --single-version-externally-managed --record=/tmp/record.txt
cd ../..

cd nnvm/python
$PYTHON setup.py install --single-version-externally-managed --record=/tmp/record.txt
cd ../..
1 change: 0 additions & 1 deletion conda/tvm/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ test:
imports:
- tvm
- topi
- nnvm
requires:
- pytest
- scipy
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.demo_android
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ RUN cd /usr && \
make -j10

# Environment variables
ENV PYTHONPATH=/usr/tvm/python:/usr/tvm/topi/python:/usr/tvm/nnvm/python/:/usr/tvm/vta/python:${PYTHONPATH}
ENV PYTHONPATH=/usr/tvm/python:/usr/tvm/topi/python:/usr/tvm/vta/python:${PYTHONPATH}
ENV ANDROID_HOME=/opt/android-sdk-linux/
2 changes: 1 addition & 1 deletion docker/Dockerfile.demo_cpu
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ COPY install/install_tvm_cpu.sh /install/install_tvm_cpu.sh
RUN bash /install/install_tvm_cpu.sh

# Environment variables
ENV PYTHONPATH=/usr/tvm/python:/usr/tvm/topi/python:/usr/tvm/nnvm/python/:/usr/tvm/vta/python:${PYTHONPATH}
ENV PYTHONPATH=/usr/tvm/python:/usr/tvm/topi/python:/usr/tvm/vta/python:${PYTHONPATH}
2 changes: 1 addition & 1 deletion docker/Dockerfile.demo_gpu
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ COPY install/install_tvm_gpu.sh /install/install_tvm_gpu.sh
RUN bash /install/install_tvm_gpu.sh

# Environment variables
ENV PYTHONPATH=/usr/tvm/python:/usr/tvm/topi/python:/usr/tvm/nnvm/python/:/usr/tvm/vta/python:${PYTHONPATH}
ENV PYTHONPATH=/usr/tvm/python:/usr/tvm/topi/python:/usr/tvm/vta/python:${PYTHONPATH}
ENV PATH=/usr/local/nvidia/bin:${PATH}
ENV PATH=/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/nvidia/lib64:${LD_LIBRARY_PATH}
3 changes: 1 addition & 2 deletions docker/Dockerfile.demo_opencl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ RUN mkdir -p ${TVM_BUILD_DIR} && \
make -j6

RUN echo "Building Python package"
ENV PYTHONPATH=${TVM_HOME}/python:${TVM_HOME}/topi/python:${TVM_HOME}/nnvm/python:${PYTHONPATH}
ENV PYTHONPATH=${TVM_HOME}/python:${TVM_HOME}/topi/python:${PYTHONPATH}
RUN cd ${TVM_HOME}/python && python3 setup.py install --user
RUN cd ${TVM_HOME}/topi/python && python3 setup.py install --user
RUN cd ${TVM_HOME}/nnvm/python && python3 setup.py install --user
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class GraphRuntime {
/**
* Create a runtime executor module given a graph and module.
* @param graphJson The graph deployed in json format output by nnvm graph.
* @param graphJson The graph deployed in json format output by compiler.
* @param libmod The module of the corresponding function.
* @param ctx The local or remote context to deploy the module.
* @return Runtime graph module that can be used to execute the graph.
Expand Down
5 changes: 2 additions & 3 deletions nnvm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ TVMPATH = ..

export LDFLAGS = -pthread -lm
export CFLAGS = -std=c++11 -Wall -O2 -Iinclude -fPIC
CFLAGS += -I$(TVMPATH)/include -I$(TVMPATH)/3rdparty/dlpack/include -I$(TVMPATH)/3rdparty/HalideIR/src -I$(TVMPATH)/topi/include

ifdef DMLC_CORE_PATH
CFLAGS += -I$(DMLC_CORE_PATH)/include
Expand Down Expand Up @@ -66,7 +65,7 @@ else
NO_WHOLE_ARCH= --no-whole-archive
endif

all: lib/libnnvm.a lib/libnnvm_compiler.$(SHARED_LIBRARY_SUFFIX)
all: lib/libnnvm.a lib/libnnvm.$(SHARED_LIBRARY_SUFFIX)

SRC = $(wildcard src/*.cc src/c_api/*.cc src/core/*.cc src/pass/*.cc)
SRC_COMPILER = $(wildcard src/top/*/*.cc wildcard src/top/vision/*/*.cc src/compiler/*.cc src/compiler/*/*.cc)
Expand All @@ -87,7 +86,7 @@ lib/libnnvm.a: $(ALL_DEP)
@mkdir -p $(@D)
$(AR) crv $@ $(filter %.o, $?)

lib/libnnvm_compiler.$(SHARED_LIBRARY_SUFFIX): lib/libnnvm.a ${TOP_OBJ}
lib/libnnvm.$(SHARED_LIBRARY_SUFFIX): lib/libnnvm.a ${TOP_OBJ}
@mkdir -p $(@D)
$(CXX) $(CFLAGS) -shared -o $@ $(filter %.o, $^) $(LDFLAGS) -Wl,${WHOLE_ARCH} lib/libnnvm.a -Wl,${NO_WHOLE_ARCH}

Expand Down
38 changes: 4 additions & 34 deletions nnvm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,8 @@
<!--- specific language governing permissions and limitations -->
<!--- under the License. -->

# NNVM Compiler Module of TVM Stack
# NNVM

```python
import tvm
from tvm.contrib import graph_runtime, rpc
import nnvm.frontend
import nnvm.compiler

# GET model from frameworks
# change xyz to supported framework name.
graph, params = nnvm.frontend.from_xyz(...)

# OPTIMIZE and COMPILE the graph to get a deployable module
# target can be "opencl", "llvm", "metal" or any target supported by tvm
target = "cuda"
graph, lib, params = nnvm.compiler.build(graph, target, {"data", data_shape}, params=params)

# DEPLOY and run on gpu(0)
module = graph_runtime.create(graph, lib, tvm.gpu(0))
module.set_input(**params)
module.run(data=data_array)
output = tvm.nd.empty(out_shape, ctx=tvm.gpu(0))
module.get_output(0, output)

# DEPLOY to REMOTE mobile/rasp/browser with minimum tvm rpc runtime
# useful for quick experiments on mobile devices
remote = rpc.connect(remote_host, remote_port)
lib.export_library("mylib.so")
remote.upload("mylib.so")
rlib = rpc.load_module("mylib.so")
# run on remote device
rmodule = graph_runtime.create(graph, rlib, remote.gpu(0))
rmodule.set_input(**params)
rmodule.run()
```
NNVM is a graph level IR for neural networks.
We are moving towards Relay IR, a better unified IR that support wider range of programs.
Please use relay instead.
22 changes: 20 additions & 2 deletions nnvm/include/nnvm/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -46,6 +46,24 @@ using dmlc::get;
/*!\brief "unsafe" getter function of any type */
using dmlc::unsafe_get;

enum TypeFlag {
kFloat32 = 0,
kFloat64 = 1,
kFloat16 = 2,
kUint8 = 3,
kInt32 = 4,
kInt8 = 5,
kInt64 = 6,
// kBool = 7,
// 7 is reserved for kBool, in order to keep consistency with MXNet TypeFlag defined in
// https://github.com/apache/incubator-mxnet/blob/master/3rdparty/mshadow/mshadow/base.h#L314
kInt16 = 8,
kUint16 = 9,
kUint32 = 10,
kUint64 = 11,
kBfloat16 = 12,
};

} // namespace nnvm

// describe op registration point
Expand Down
Loading

0 comments on commit f9bc748

Please sign in to comment.