diff --git a/Makefile b/Makefile index 3d554478b715..e60f57517ad0 100644 --- a/Makefile +++ b/Makefile @@ -89,8 +89,6 @@ ifeq ($(USE_DIST_KVSTORE), 1) LDFLAGS += $(PS_LDFLAGS_A) endif -include $(MXNET_PLUGINS) - .PHONY: clean all test lint doc clean_all rcpplint rcppexport roxygen all: lib/libmxnet.a lib/libmxnet.so $(BIN) @@ -100,6 +98,7 @@ OBJ = $(patsubst %.cc, build/%.o, $(SRC)) CUSRC = $(wildcard src/*/*.cu) CUOBJ = $(patsubst %.cu, build/%_gpu.o, $(CUSRC)) +# extra operators ifneq ($(EXTRA_OPERATORS),) EXTRA_SRC = $(wildcard $(EXTRA_OPERATORS)/*.cc $(EXTRA_OPERATORS)/*/*.cc) EXTRA_OBJ = $(patsubst $(EXTRA_OPERATORS)/%.cc, $(EXTRA_OPERATORS)/build/%.o, $(EXTRA_SRC)) @@ -113,21 +112,11 @@ else endif # plugin -ifeq ($(USE_TORCH), 1) - CFLAGS += -I$(TORCH_PATH)/install/include -I$(TORCH_PATH)/install/include/TH -I$(TORCH_PATH)/install/include/THC -DMXNET_USE_TORCH=1 - LDFLAGS += -L$(TORCH_PATH)/install/lib -lluajit -lluaT -lTH -lTHC -L$(TORCH_PATH)/install/lib/lua/5.1 -lpaths -ltorch -lnn - ifeq ($(USE_CUDA), 1) - LDFLAGS += -lcutorch -lcunn - endif - - TORCH_SRC = $(wildcard plugin/torch/*.cc) - PLUGIN_OBJ += $(patsubst %.cc, build/%.o, $(TORCH_SRC)) - TORCH_CUSRC = $(wildcard plugin/torch/*.cu) - PLUGIN_CUOBJ += $(patsubst %.cu, build/%_gpu.o, $(TORCH_CUSRC)) -else - CFLAGS += -DMXNET_USE_TORCH=0 -endif +PLUGIN_OBJ = +PLUGIN_CUOBJ = +include $(MXNET_PLUGINS) +# all dep LIB_DEP += $(DMLC_CORE)/libdmlc.a ALL_DEP = $(OBJ) $(EXTRA_OBJ) $(PLUGIN_OBJ) $(LIB_DEP) ifeq ($(USE_CUDA), 1) @@ -158,10 +147,11 @@ build/plugin/%.o: plugin/%.cc $(CXX) -std=c++0x $(CFLAGS) -MM -MT build/plugin/$*.o $< >build/plugin/$*.d $(CXX) -std=c++0x -c $(CFLAGS) -c $< -o $@ -# A nvcc bug cause this to generate "generic/xxx.h" dependencies from torch headers. -# $(NVCC) $(NVCCFLAGS) -Xcompiler "$(CFLAGS)" -M -MT build/plugin/$*_gpu.o $< >build/plugin/$*_gpu.d +# A nvcc bug cause it to generate "generic/xxx.h" dependencies from torch headers. +# Use CXX to generate dependency instead. build/plugin/%_gpu.o: plugin/%.cu @mkdir -p $(@D) + $(CXX) -std=c++0x $(CFLAGS) -MM -MT build/plugin/$*_gpu.o $< >build/plugin/$*_gpu.d $(NVCC) -c -o $@ $(NVCCFLAGS) -Xcompiler "$(CFLAGS)" $< $(EXTRA_OPERATORS)/build/%.o: $(EXTRA_OPERATORS)/%.cc diff --git a/make/config.mk b/make/config.mk index 484f60066a72..7bba2101de1f 100644 --- a/make/config.mk +++ b/make/config.mk @@ -112,8 +112,8 @@ EXTRA_OPERATORS = #---------------------------- # whether to use torch integration. This requires installing torch. -USE_TORCH = 0 -TORCH_PATH = $(HOME)/torch +# TORCH_PATH = $(HOME)/torch +# MXNET_PLUGINS += plugin/torch/torch.mk # whether to use sframe integration. This requires build sframe # git@github.com:dato-code/SFrame.git diff --git a/make/osx.mk b/make/osx.mk index 3995049e60b1..5a6f56cc8ca2 100644 --- a/make/osx.mk +++ b/make/osx.mk @@ -99,5 +99,5 @@ EXTRA_OPERATORS = #---------------------------- # whether to use torch integration. This requires installing torch. -USE_TORCH = 0 -TORCH_PATH = $(HOME)/torch +# TORCH_PATH = $(HOME)/torch +# MXNET_PLUGINS += plugin/torch/torch.mk diff --git a/plugin/torch/torch.mk b/plugin/torch/torch.mk new file mode 100644 index 000000000000..5eda7e0a015a --- /dev/null +++ b/plugin/torch/torch.mk @@ -0,0 +1,10 @@ +CFLAGS += -I$(TORCH_PATH)/install/include -DMXNET_USE_TORCH=1 +LDFLAGS += -L$(TORCH_PATH)/install/lib -lluajit -lluaT -lTH -lTHC -L$(TORCH_PATH)/install/lib/lua/5.1 -lpaths -ltorch -lnn +ifeq ($(USE_CUDA), 1) + LDFLAGS += -lcutorch -lcunn +endif + +TORCH_SRC = $(wildcard plugin/torch/*.cc) +PLUGIN_OBJ += $(patsubst %.cc, build/%.o, $(TORCH_SRC)) +TORCH_CUSRC = $(wildcard plugin/torch/*.cu) +PLUGIN_CUOBJ += $(patsubst %.cu, build/%_gpu.o, $(TORCH_CUSRC)) \ No newline at end of file diff --git a/plugin/torch/torch_base.h b/plugin/torch/torch_base.h index ecc6d67e6ed6..74ede4d4c1a1 100644 --- a/plugin/torch/torch_base.h +++ b/plugin/torch/torch_base.h @@ -7,23 +7,24 @@ #ifndef PLUGIN_TORCH_TORCH_BASE_H_ #define PLUGIN_TORCH_TORCH_BASE_H_ #include -#include extern "C" { #include #include #include -#include -#include +#include +#include } #if MXNET_USE_CUDA extern "C" { -#include -#include +#include +#include } #endif // MXNET_USE_CUDA +#include + namespace mxnet { class TorchState {