Skip to content

Commit

Permalink
Merge pull request apache#8 from precedenceguo/simple
Browse files Browse the repository at this point in the history
Merge dmlc/mxnet
  • Loading branch information
winstywang committed Jul 26, 2016
2 parents f39da2d + 6b70e09 commit e3ba141
Show file tree
Hide file tree
Showing 279 changed files with 16,067 additions and 3,953 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,10 @@ scala-package/*/*/target/
*.project
*.settings
!scala-package/*/bin
*.bak
*/node_modules/

# Eclipse project config
.project
.cproject
.pydevproject
45 changes: 28 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ mxnet_option(USE_OPENMP "Build with Openmp support" ON)
mxnet_option(USE_CUDNN "Build with cudnn support" ON) # one could set CUDNN_ROOT for search path
mxnet_option(USE_CUDA "Build with CUDA support" ON)
mxnet_option(USE_DIST_KVSTORE "Build with DIST_KVSTORE support" OFF)
mxnet_option(USE_PLUGINS_WARPCTC "Use WARPCTC Plugins" OFF)

SET(EXTRA_OPERATORS "" CACHE PATH "EXTRA OPERATORS PATH")


include(mshadow/cmake/mshadow.cmake)
include(mshadow/cmake/Utils.cmake)
include(mshadow/cmake/Cuda.cmake)

set(mxnet_LINKER_LIBS "")
list(APPEND mxnet_LINKER_LIBS ${mshadow_LINKER_LIBS})

include_directories("include")
include_directories("mshadow")
include_directories("dmlc-core/include")
Expand All @@ -29,7 +32,7 @@ if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DMXNET_EXPORTS)
set(CMAKE_C_FLAGS "/MP")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} /bigobj")
else(MSVC)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11)
Expand All @@ -44,7 +47,7 @@ if(USE_OPENCV)
find_package(OpenCV REQUIRED COMPONENTS core highgui imgproc)
endif()
include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS})
list(APPEND mshadow_LINKER_LIBS ${OpenCV_LIBS})
list(APPEND mxnet_LINKER_LIBS ${OpenCV_LIBS})
message(STATUS "OpenCV found (${OpenCV_CONFIG_PATH})")
add_definitions(-DMXNET_USE_OPENCV=1)
else(USE_OPENCV)
Expand All @@ -68,7 +71,7 @@ if(USE_CUDNN)
if(HAVE_CUDNN)
add_definitions(-DUSE_CUDNN)
include_directories(SYSTEM ${CUDNN_INCLUDE})
list(APPEND mshadow_LINKER_LIBS ${CUDNN_LIBRARY})
list(APPEND mxnet_LINKER_LIBS ${CUDNN_LIBRARY})
add_definitions(-DMSHADOW_USE_CUDNN=1)
endif()
endif()
Expand Down Expand Up @@ -115,12 +118,22 @@ mxnet_source_group("Source\\resource.cc" GLOB "src/resource.cc/*.cc")
mxnet_source_group("Source\\storage" GLOB "src/storage/*.cc")
mxnet_source_group("Source\\symbol" GLOB "src/symbol/*.cc")





FILE(GLOB_RECURSE SOURCE "src/*.cc" "src/*.h")
FILE(GLOB_RECURSE cuda "src/*.cu")
FILE(GLOB_RECURSE CUDA "src/*.cu")

if(USE_PLUGINS_WARPCTC)
set(WARPCTC_INCLUDE "" CACHE PATH "WARPCTC include")
set(WARPCTC_LIB "" CACHE FILEPATH "WARPCTC lib")
include_directories(SYSTEM ${WARPCTC_INCLUDE})
list(APPEND mxnet_LINKER_LIBS ${WARPCTC_LIB})
mxnet_source_group("Include\\plugin\\warpctc" GLOB "plugin/warpctc/*.h")
mxnet_source_group("Source\\plugin\\warpctc" GLOB "plugin/warpctc/*.cc")
mxnet_source_group("Cuda\\plugin\\warpctc" GLOB "plugin/warpctc/*.cu")
FILE(GLOB_RECURSE PLUGINS_SOURCE "plugin/warpctc/*.cc" "plugin/warpctc/*.h")
FILE(GLOB_RECURSE PLUGINS_CUSRC "plugin/warpctc/*.cu")
list(APPEND SOURCE ${PLUGINS_SOURCE})
list(APPEND CUDA ${PLUGINS_CUSRC})
endif()

if (NOT (EXTRA_OPERATORS STREQUAL ""))
mxnet_source_group("Extra" GLOB_RECURSE "${EXTRA_OPERATORS}/*.cc")
Expand All @@ -142,19 +155,18 @@ endif()

if(USE_CUDA)
# define preprocessor macro so that we will not include the generated forcelink header
mshadow_cuda_compile(cuda_objs ${cuda})
mshadow_cuda_compile(cuda_objs ${CUDA})
if(MSVC)
FIND_LIBRARY(CUDA_nvrtc_LIBRARY nvrtc "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" "${CUDA_TOOLKIT_ROOT_DIR}/lib/win32")
list(APPEND mshadow_LINKER_LIBS ${CUDA_nvrtc_LIBRARY})
list(APPEND mxnet_LINKER_LIBS ${CUDA_nvrtc_LIBRARY})
set(CUDA_cuda_LIBRARY "${CUDA_nvrtc_LIBRARY}/../cuda.lib")
list(APPEND mshadow_LINKER_LIBS ${CUDA_cuda_LIBRARY})
list(APPEND mxnet_LINKER_LIBS ${CUDA_cuda_LIBRARY})
else(MSVC)
list(APPEND mshadow_LINKER_LIBS nvrtc cuda)
list(APPEND mxnet_LINKER_LIBS nvrtc cuda)
endif()
list(APPEND SOURCE ${cuda_objs} ${cuda})
list(APPEND SOURCE ${cuda_objs} ${CUDA})
endif()


if(NOT MSVC)
# Only add c++11 flags and definitions after cuda compiling
add_definitions(-DDMLC_USE_CXX11)
Expand All @@ -170,10 +182,9 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
else()
add_library(mxnet SHARED ${SOURCE})
endif()
target_link_libraries(mxnet ${mshadow_LINKER_LIBS})
target_link_libraries(mxnet ${mxnet_LINKER_LIBS})
target_link_libraries(mxnet dmlccore)


if(MSVC)
set_target_properties(mxnet PROPERTIES OUTPUT_NAME "libmxnet")
endif()
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ List of Contributors
* [Yuqi Li](https://github.com/ziyeqinghan)
* [Depeng Liang](https://github.com/Ldpe2G)
* [Kiko Qiu](https://github.com/kikoqiu)
* [Yang Bo](https://github.com/Atry)
* [Jonas Amaro](https://github.com/jonasrla)
* [Yan Li](https://github.com/Godricly)
37 changes: 18 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ endif
include $(config)
include mshadow/make/mshadow.mk
include $(DMLC_CORE)/make/dmlc.mk
unexport NO_OPENMP

# all tge possible warning tread
WARNFLAGS= -Wall
Expand All @@ -37,9 +36,9 @@ endif
CFLAGS += -I$(ROOTDIR)/mshadow/ -I$(ROOTDIR)/dmlc-core/include -fPIC -Iinclude $(MSHADOW_CFLAGS)
LDFLAGS = -pthread $(MSHADOW_LDFLAGS) $(DMLC_LDFLAGS)
ifeq ($(DEBUG), 1)
NVCCFLAGS = -D_FORCE_INLINES -g -G -O0 -ccbin $(CXX) $(MSHADOW_NVCCFLAGS)
NVCCFLAGS = -std=c++11 -Xcompiler -D_FORCE_INLINES -g -G -O0 -ccbin $(CXX) $(MSHADOW_NVCCFLAGS)
else
NVCCFLAGS = -D_FORCE_INLINES -g -O3 -ccbin $(CXX) $(MSHADOW_NVCCFLAGS)
NVCCFLAGS = -std=c++11 -Xcompiler -D_FORCE_INLINES -g -O3 -ccbin $(CXX) $(MSHADOW_NVCCFLAGS)
endif

ifndef LINT_LANG
Expand Down Expand Up @@ -150,8 +149,8 @@ endif

build/src/%.o: src/%.cc
@mkdir -p $(@D)
$(CXX) -std=c++0x $(CFLAGS) -MM -MT build/src/$*.o $< >build/src/$*.d
$(CXX) -std=c++0x -c $(CFLAGS) -c $< -o $@
$(CXX) -std=c++11 $(CFLAGS) -MM -MT build/src/$*.o $< >build/src/$*.d
$(CXX) -std=c++11 -c $(CFLAGS) -c $< -o $@

build/src/%_gpu.o: src/%.cu
@mkdir -p $(@D)
Expand All @@ -160,20 +159,20 @@ build/src/%_gpu.o: src/%.cu

build/plugin/%.o: plugin/%.cc
@mkdir -p $(@D)
$(CXX) -std=c++0x $(CFLAGS) -MM -MT build/plugin/$*.o $< >build/plugin/$*.d
$(CXX) -std=c++0x -c $(CFLAGS) -c $< -o $@
$(CXX) -std=c++11 $(CFLAGS) -MM -MT build/plugin/$*.o $< >build/plugin/$*.d
$(CXX) -std=c++11 -c $(CFLAGS) -c $< -o $@

# 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
$(CXX) -std=c++11 $(CFLAGS) -MM -MT build/plugin/$*_gpu.o $< >build/plugin/$*_gpu.d
$(NVCC) -c -o $@ $(NVCCFLAGS) -Xcompiler "$(CFLAGS)" $<

$(EXTRA_OPERATORS)/build/%.o: $(EXTRA_OPERATORS)/%.cc
@mkdir -p $(@D)
$(CXX) -std=c++0x $(CFLAGS) -Isrc/operator -MM -MT $(EXTRA_OPERATORS)/build/$*.o $< >$(EXTRA_OPERATORS)/build/$*.d
$(CXX) -std=c++0x -c $(CFLAGS) -Isrc/operator -c $< -o $@
$(CXX) -std=c++11 $(CFLAGS) -Isrc/operator -MM -MT $(EXTRA_OPERATORS)/build/$*.o $< >$(EXTRA_OPERATORS)/build/$*.d
$(CXX) -std=c++11 -c $(CFLAGS) -Isrc/operator -c $< -o $@

$(EXTRA_OPERATORS)/build/%_gpu.o: $(EXTRA_OPERATORS)/%.cu
@mkdir -p $(@D)
Expand Down Expand Up @@ -201,7 +200,7 @@ bin/im2rec: tools/im2rec.cc $(ALL_DEP)

$(BIN) :
@mkdir -p $(@D)
$(CXX) $(CFLAGS) -std=c++0x -o $@ $(filter %.cpp %.o %.c %.a %.cc, $^) $(LDFLAGS)
$(CXX) $(CFLAGS) -std=c++11 -o $@ $(filter %.cpp %.o %.c %.a %.cc, $^) $(LDFLAGS)

include tests/cpp/unittest.mk

Expand Down Expand Up @@ -237,26 +236,26 @@ rpkg: roxygen
scalapkg:
(cd $(ROOTDIR)/scala-package; \
mvn clean package -P$(SCALA_PKG_PROFILE) -Dcxx="$(CXX)" \
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dlddeps="$(LIB_DEP)")
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dlddeps="$(LIB_DEP)")

scalatest:
(cd $(ROOTDIR)/scala-package; \
mvn verify -P$(SCALA_PKG_PROFILE) -Dcxx="$(CXX)" \
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dlddeps="$(LIB_DEP)" $(SCALA_TEST_ARGS))
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dlddeps="$(LIB_DEP)" $(SCALA_TEST_ARGS))

scalainstall:
(cd $(ROOTDIR)/scala-package; \
mvn install -P$(SCALA_PKG_PROFILE) -DskipTests -Dcxx="$(CXX)" \
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dlddeps="$(LIB_DEP)")
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dlddeps="$(LIB_DEP)")

scaladeploy:
(cd $(ROOTDIR)/scala-package; \
mvn deploy -Prelease,$(SCALA_PKG_PROFILE) -DskipTests -Dcxx="$(CXX)" \
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dlddeps="$(LIB_DEP)")
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dlddeps="$(LIB_DEP)")

jnilint:
python2 dmlc-core/scripts/lint.py mxnet-jnicpp cpp scala-package/native/src
Expand Down
6 changes: 6 additions & 0 deletions R-package/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export(mx.exec.update.arg.arrays)
export(mx.exec.update.aux.arrays)
export(mx.exec.update.grad.arrays)
export(mx.gpu)
export(mx.gru)
export(mx.gru.forward)
export(mx.gru.inference)
export(mx.init.Xavier)
export(mx.init.create)
export(mx.init.normal)
Expand Down Expand Up @@ -80,6 +83,9 @@ export(mx.nd.transpose)
export(mx.nd.zeros)
export(mx.opt.create)
export(mx.opt.get.updater)
export(mx.rnn)
export(mx.rnn.forward)
export(mx.rnn.inference)
export(mx.rnorm)
export(mx.runif)
export(mx.set.seed)
Expand Down
Loading

0 comments on commit e3ba141

Please sign in to comment.