2016-11-21 09:03:48 +03:00
|
|
|
ROOTDIR = $(CURDIR)
|
|
|
|
|
|
|
|
ifndef config
|
|
|
|
ifneq ("$(wildcard ./config.mk)", "")
|
|
|
|
config = config.mk
|
|
|
|
else
|
|
|
|
config = make/config.mk
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
include $(config)
|
|
|
|
|
2016-07-05 21:23:49 +03:00
|
|
|
export LDFLAGS = -pthread -lm
|
2017-01-27 01:22:17 +03:00
|
|
|
export CFLAGS = -std=c++11 -Wall -O2 -Iinclude -fPIC
|
2018-02-06 20:39:59 +03:00
|
|
|
CFLAGS += -Itvm/include -Itvm/dlpack/include -Itvm/HalideIR/src -Itvm/topi/include
|
2016-06-23 07:00:50 +03:00
|
|
|
|
2017-01-31 06:09:37 +03:00
|
|
|
ifdef DMLC_CORE_PATH
|
|
|
|
CFLAGS += -I$(DMLC_CORE_PATH)/include
|
|
|
|
else
|
|
|
|
CFLAGS += -I$(ROOTDIR)/dmlc-core/include
|
|
|
|
endif
|
|
|
|
|
2017-04-04 03:12:44 +03:00
|
|
|
ifdef DMLC_CORE_PATH
|
|
|
|
CFLAGS += -I$(DMLC_CORE_PATH)/include
|
|
|
|
else
|
|
|
|
CFLAGS += -I$(ROOTDIR)/dmlc-core/include
|
|
|
|
endif
|
|
|
|
|
2016-11-21 09:03:48 +03:00
|
|
|
ifneq ($(ADD_CFLAGS), NONE)
|
|
|
|
CFLAGS += $(ADD_CFLAGS)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(ADD_LDFLAGS), NONE)
|
2017-09-19 19:30:35 +03:00
|
|
|
LDFLAGS += $(ADD_LDFLAGS)
|
2016-11-21 09:03:48 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
# plugin
|
|
|
|
PLUGIN_OBJ =
|
|
|
|
include $(NNVM_PLUGINS)
|
|
|
|
|
2016-06-23 07:00:50 +03:00
|
|
|
# specify tensor path
|
2017-09-27 08:24:37 +03:00
|
|
|
.PHONY: clean all test lint cpplint pylint doc cython cython3 cyclean
|
2016-06-23 07:00:50 +03:00
|
|
|
|
2016-09-02 01:27:04 +03:00
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
|
|
|
|
ifeq ($(UNAME_S), Darwin)
|
2017-08-25 19:00:48 +03:00
|
|
|
SHARED_LIBRARY_SUFFIX := dylib
|
2016-09-02 04:33:14 +03:00
|
|
|
WHOLE_ARCH= -all_load
|
|
|
|
NO_WHOLE_ARCH= -noall_load
|
2017-09-19 19:30:35 +03:00
|
|
|
LDFLAGS += -undefined dynamic_lookup
|
2016-09-02 01:27:04 +03:00
|
|
|
else
|
2017-08-25 19:00:48 +03:00
|
|
|
SHARED_LIBRARY_SUFFIX := so
|
2016-09-02 01:27:04 +03:00
|
|
|
WHOLE_ARCH= --whole-archive
|
|
|
|
NO_WHOLE_ARCH= --no-whole-archive
|
|
|
|
endif
|
|
|
|
|
2017-09-30 02:43:53 +03:00
|
|
|
all: lib/libnnvm.a lib/libnnvm_compiler.$(SHARED_LIBRARY_SUFFIX)
|
2017-08-25 19:00:48 +03:00
|
|
|
|
2017-09-08 22:36:16 +03:00
|
|
|
SRC = $(wildcard src/*.cc src/c_api/*.cc src/core/*.cc src/pass/*.cc)
|
2018-04-06 07:53:29 +03:00
|
|
|
SRC_COMPILER = $(wildcard src/top/*/*.cc wildcard src/top/vision/*/*.cc src/compiler/*.cc src/compiler/*/*.cc)
|
2017-08-25 19:00:48 +03:00
|
|
|
ALL_OBJ = $(patsubst %.cc, build/%.o, $(SRC))
|
2017-09-30 02:43:53 +03:00
|
|
|
TOP_OBJ = $(patsubst %.cc, build/%.o, $(SRC_COMPILER))
|
2017-09-08 22:36:16 +03:00
|
|
|
ALL_DEP = $(ALL_OBJ)
|
2016-09-02 01:27:04 +03:00
|
|
|
|
2016-07-05 21:23:49 +03:00
|
|
|
include tests/cpp/unittest.mk
|
|
|
|
|
|
|
|
test: $(TEST)
|
2016-06-23 07:00:50 +03:00
|
|
|
|
2016-11-21 09:03:48 +03:00
|
|
|
build/src/%.o: src/%.cc
|
2016-06-23 07:00:50 +03:00
|
|
|
@mkdir -p $(@D)
|
2016-11-21 09:03:48 +03:00
|
|
|
$(CXX) $(CFLAGS) -MM -MT build/src/$*.o $< >build/src/$*.d
|
2016-06-23 07:00:50 +03:00
|
|
|
$(CXX) -c $(CFLAGS) -c $< -o $@
|
|
|
|
|
2016-07-10 20:55:50 +03:00
|
|
|
lib/libnnvm.a: $(ALL_DEP)
|
2016-07-05 21:23:49 +03:00
|
|
|
@mkdir -p $(@D)
|
2018-01-01 15:16:47 +03:00
|
|
|
$(AR) crv $@ $(filter %.o, $?)
|
2016-07-05 21:23:49 +03:00
|
|
|
|
2017-09-30 02:43:53 +03:00
|
|
|
lib/libnnvm_compiler.$(SHARED_LIBRARY_SUFFIX): lib/libnnvm.a ${TOP_OBJ}
|
2016-08-02 21:09:01 +03:00
|
|
|
@mkdir -p $(@D)
|
2017-09-08 22:36:16 +03:00
|
|
|
$(CXX) $(CFLAGS) -shared -o $@ $(filter %.o, $^) $(LDFLAGS) -Wl,${WHOLE_ARCH} lib/libnnvm.a -Wl,${NO_WHOLE_ARCH}
|
2016-06-23 07:00:50 +03:00
|
|
|
|
2016-07-16 02:57:51 +03:00
|
|
|
cython:
|
2016-07-15 22:42:48 +03:00
|
|
|
cd python; python setup.py build_ext --inplace
|
|
|
|
|
2016-07-16 02:57:51 +03:00
|
|
|
cython3:
|
|
|
|
cd python; python3 setup.py build_ext --inplace
|
|
|
|
|
2016-07-16 03:38:15 +03:00
|
|
|
cyclean:
|
2017-08-25 19:00:48 +03:00
|
|
|
rm -rf python/nnvm/*/*.so python/nnvm/*/*.dylib python/nnvm/*/*.cpp
|
2016-07-16 02:57:51 +03:00
|
|
|
|
2017-09-27 08:24:37 +03:00
|
|
|
lint: pylint cpplint
|
|
|
|
|
|
|
|
cpplint:
|
2017-09-08 22:36:16 +03:00
|
|
|
python dmlc-core/scripts/lint.py nnvm cpp include src
|
2016-07-02 21:21:10 +03:00
|
|
|
|
2017-09-18 08:12:59 +03:00
|
|
|
pylint:
|
|
|
|
pylint python/nnvm --rcfile=$(ROOTDIR)/tests/lint/pylintrc
|
|
|
|
|
2016-07-02 21:21:10 +03:00
|
|
|
doc:
|
|
|
|
doxygen docs/Doxyfile
|
|
|
|
|
2016-06-23 07:00:50 +03:00
|
|
|
clean:
|
2016-07-05 21:23:49 +03:00
|
|
|
$(RM) -rf build lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o cli_test
|
2016-06-23 07:00:50 +03:00
|
|
|
|
|
|
|
-include build/*.d
|
|
|
|
-include build/*/*.d
|
2017-05-26 00:36:10 +03:00
|
|
|
-include build/*/*/*.d
|