Commit ec9f38ec by Tianqi Chen Committed by GitHub

[TOPI] Fix cpp library dependency on MAC (#852)

parent 6d3a3adf
...@@ -27,6 +27,7 @@ LLVM_CFLAGS= -fno-rtti -DDMLC_ENABLE_RTTI=0 -DDMLC_USE_FOPEN64=0 ...@@ -27,6 +27,7 @@ LLVM_CFLAGS= -fno-rtti -DDMLC_ENABLE_RTTI=0 -DDMLC_USE_FOPEN64=0
LDFLAGS = -pthread -lm -ldl LDFLAGS = -pthread -lm -ldl
INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include -IHalideIR/src -Itopi/include INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include -IHalideIR/src -Itopi/include
CFLAGS = -std=c++11 -Wall -O2 $(INCLUDE_FLAGS) -fPIC CFLAGS = -std=c++11 -Wall -O2 $(INCLUDE_FLAGS) -fPIC
PKG_LDFLAGS =
FRAMEWORKS = FRAMEWORKS =
OBJCFLAGS = -fno-objc-arc OBJCFLAGS = -fno-objc-arc
EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\ EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\
...@@ -80,6 +81,10 @@ ALL_DEP = $(CC_OBJ) $(CONTRIB_OBJ) $(LIB_HALIDEIR) ...@@ -80,6 +81,10 @@ ALL_DEP = $(CC_OBJ) $(CONTRIB_OBJ) $(LIB_HALIDEIR)
RUNTIME_DEP = $(RUNTIME_OBJ) RUNTIME_DEP = $(RUNTIME_OBJ)
TOPI_DEP = $(TOPI_OBJ) TOPI_DEP = $(TOPI_OBJ)
ifeq ($(UNAME_S), Darwin)
PKG_LDFLAGS += -undefined dynamic_lookup
endif
# Dependency specific rules # Dependency specific rules
ifdef CUDA_PATH ifdef CUDA_PATH
NVCC=$(CUDA_PATH)/bin/nvcc NVCC=$(CUDA_PATH)/bin/nvcc
...@@ -201,7 +206,10 @@ else ...@@ -201,7 +206,10 @@ else
JVM_PKG_PROFILE := $(JVM_PKG_PROFILE)-cpu JVM_PKG_PROFILE := $(JVM_PKG_PROFILE)-cpu
endif endif
BUILD_TARGETS ?= lib/libtvm.$(SHARED_LIBRARY_SUFFIX) lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX) lib/libtvm_topi.$(SHARED_LIBRARY_SUFFIX) BUILD_TARGETS ?= lib/libtvm.$(SHARED_LIBRARY_SUFFIX) \
lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX) \
lib/libtvm_topi.$(SHARED_LIBRARY_SUFFIX)
all: ${BUILD_TARGETS} all: ${BUILD_TARGETS}
runtime: lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX) runtime: lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX)
web: lib/libtvm_web_runtime.js lib/libtvm_web_runtime.bc web: lib/libtvm_web_runtime.js lib/libtvm_web_runtime.bc
...@@ -235,29 +243,18 @@ build/src/%.o: topi/src/%.cc ...@@ -235,29 +243,18 @@ build/src/%.o: topi/src/%.cc
$(CXX) $(CFLAGS) -MM -MT build/src/$*.o $< >build/src/$*.d $(CXX) $(CFLAGS) -MM -MT build/src/$*.o $< >build/src/$*.d
$(CXX) -c $(CFLAGS) -c $< -o $@ $(CXX) -c $(CFLAGS) -c $< -o $@
lib/libtvm.dylib: $(ALL_DEP) $(RUNTIME_DEP) lib/libtvm.${SHARED_LIBRARY_SUFFIX}: $(ALL_DEP) $(RUNTIME_DEP)
@mkdir -p $(@D) @mkdir -p $(@D)
$(CXX) $(CFLAGS) $(FRAMEWORKS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS) $(CXX) $(CFLAGS) $(FRAMEWORKS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS)
lib/libtvm_topi.dylib: lib/libtvm.so $(TOPI_DEP) lib/libtvm_topi.${SHARED_LIBRARY_SUFFIX}: $(TOPI_DEP)
@mkdir -p $(@D)
$(CXX) $(CFLAGS) $(FRAMEWORKS) -L./lib -ltvm -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS)
lib/libtvm_runtime.dylib: $(RUNTIME_DEP)
@mkdir -p $(@D) @mkdir -p $(@D)
$(CXX) $(CFLAGS) $(FRAMEWORKS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS) $(CXX) $(CFLAGS) $(FRAMEWORKS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS) $(PKG_LDFLAGS)
lib/libtvm.so: $(ALL_DEP) $(RUNTIME_DEP) lib/libtvm_runtime.${SHARED_LIBRARY_SUFFIX}: $(RUNTIME_DEP)
@mkdir -p $(@D) @mkdir -p $(@D)
$(CXX) $(CFLAGS) $(FRAMEWORKS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS) $(CXX) $(CFLAGS) $(FRAMEWORKS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS)
lib/libtvm_topi.so: lib/libtvm.so $(TOPI_DEP)
@mkdir -p $(@D)
$(CXX) $(CFLAGS) $(FRAMEWORKS) -L./lib -ltvm -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS)
lib/libtvm_runtime.so: $(RUNTIME_DEP)
@mkdir -p $(@D)
$(CXX) $(CFLAGS) $(FRAMEWORKS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS)
lib/libtvm_web_runtime.bc: web/web_runtime.cc lib/libtvm_web_runtime.bc: web/web_runtime.cc
@mkdir -p build/web @mkdir -p build/web
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
from __future__ import absolute_import from __future__ import absolute_import
import sys import sys
import os import os
import warnings
def find_lib_path(name=None, search_path=None, optional=False): def find_lib_path(name=None, search_path=None, optional=False):
"""Find dynamic library files. """Find dynamic library files.
...@@ -91,9 +91,7 @@ def find_lib_path(name=None, search_path=None, optional=False): ...@@ -91,9 +91,7 @@ def find_lib_path(name=None, search_path=None, optional=False):
str('\n'.join(lib_dll_path + runtime_dll_path))) str('\n'.join(lib_dll_path + runtime_dll_path)))
if not optional: if not optional:
raise RuntimeError(message) raise RuntimeError(message)
else: return None
warnings.warn(message)
return None
if use_runtime: if use_runtime:
sys.stderr.write("Loading runtime library %s... exec only\n" % lib_found[0]) sys.stderr.write("Loading runtime library %s... exec only\n" % lib_found[0])
......
...@@ -110,7 +110,7 @@ Expr pack_buffer(Buffer buf) { ...@@ -110,7 +110,7 @@ Expr pack_buffer(Buffer buf) {
buf->data, buf->data,
shape, shape,
strides, strides,
make_const(Int(32), buf->shape.size()), make_const(Int(32), static_cast<int64_t>(buf->shape.size())),
make_const(buf->dtype, 0), make_const(buf->dtype, 0),
buf->elem_offset buf->elem_offset
}; };
...@@ -125,7 +125,7 @@ Expr pack_buffer(Buffer buf) { ...@@ -125,7 +125,7 @@ Expr pack_buffer(Buffer buf) {
* by the arguments to pass to the PackedFunc when called. The first element of the * by the arguments to pass to the PackedFunc when called. The first element of the
* array must be a constant string expression. * array must be a constant string expression.
* *
* \return An expression representing the invocation * \return An expression representing the invocation
*/ */
Expr call_packed(Array<Expr> args) { Expr call_packed(Array<Expr> args) {
return tvm::ir::Call::make(Int(32), tvm::ir::intrinsic::tvm_call_packed, return tvm::ir::Call::make(Int(32), tvm::ir::intrinsic::tvm_call_packed,
......
...@@ -4,7 +4,6 @@ import tvm ...@@ -4,7 +4,6 @@ import tvm
import topi import topi
from topi.util import get_const_tuple from topi.util import get_const_tuple
from tvm.contrib.pickle_memoize import memoize from tvm.contrib.pickle_memoize import memoize
from util import make_vector
def verify_clip(N, a_min, a_max, dtype): def verify_clip(N, a_min, a_max, dtype):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment