Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
add nnvm cmake with windows (#3255)
Browse files Browse the repository at this point in the history
  • Loading branch information
yajiedesign authored and piiswrong committed Dec 29, 2016
1 parent e027f1c commit fbc6910
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
30 changes: 28 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mxnet_option(USE_MXNET_LIB_NAMING "Use MXNet library naming conventions." ON)

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

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

Expand All @@ -24,6 +24,7 @@ list(APPEND mxnet_LINKER_LIBS ${mshadow_LINKER_LIBS})

include_directories("include")
include_directories("mshadow")
include_directories("nnvm/include")
include_directories("dmlc-core/include")

if(MSVC)
Expand All @@ -33,6 +34,8 @@ if(MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DMXNET_EXPORTS)
add_definitions(-DNNVM_EXPORTS)
add_definitions(-DDMLC_STRICT_CXX11)
set(CMAKE_C_FLAGS "/MP")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} /bigobj")
else(MSVC)
Expand Down Expand Up @@ -79,7 +82,7 @@ if(USE_OPENMP)
endif()

# cudnn detection
if(USE_CUDNN)
if(USE_CUDNN AND USE_CUDA)
detect_cuDNN()
if(HAVE_CUDNN)
add_definitions(-DUSE_CUDNN)
Expand All @@ -89,7 +92,9 @@ if(USE_CUDNN)
endif()
endif()


add_subdirectory("dmlc-core")

if(USE_DIST_KVSTORE)
add_subdirectory("ps-lite")
endif()
Expand All @@ -105,6 +110,7 @@ mxnet_source_group("Include\\optimizer" GLOB "src/optimizer/*.h")
mxnet_source_group("Include\\resource.cc" GLOB "src/resource.cc/*.h")
mxnet_source_group("Include\\storage" GLOB "src/storage/*.h")
mxnet_source_group("Include\\symbol" GLOB "src/symbol/*.h")
mxnet_source_group("Include\\executor" GLOB "src/executor/*.h")

mxnet_source_group("Cuda\\common" GLOB "src/common/*.cu")
mxnet_source_group("Cuda\\c_api" GLOB "src/c_api/*.cu")
Expand All @@ -130,10 +136,29 @@ mxnet_source_group("Source\\optimizer" GLOB "src/optimizer/*.cc")
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")
mxnet_source_group("Source\\executor" GLOB "src/executor/*.cc")
mxnet_source_group("Source\\nnvm" GLOB "src/nnvm/*.cc")


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

# add nnvm to source

mxnet_source_group("NNVM\\Include\\c_api" GLOB "nnvm/src/c_api/*.h")
mxnet_source_group("NNVM\\Include\\core" GLOB "nnvm/src/core/*.h")
mxnet_source_group("NNVM\\Include\\pass" GLOB "nnvm/src/pass/*.h")
mxnet_source_group("NNVM\\Include\\nnvm" GLOB "nnvm/include/nnvm/*.h")
mxnet_source_group("NNVM\\Include\\dmlc" GLOB "nnvm/include/dmlc/*.h")

mxnet_source_group("NNVM\\Source" GLOB "nnvm/src/*.cc")
mxnet_source_group("NNVM\\Source\\c_api" GLOB "nnvm/src/c_api/*.cc")
mxnet_source_group("NNVM\\Source\\core" GLOB "nnvm/src/core/*.cc")
mxnet_source_group("NNVM\\Source\\pass" GLOB "nnvm/src/pass/*.cc")

FILE(GLOB_RECURSE NNVMSOURCE "nnvm/src/*.cc" "nnvm/src/*.h" "nnvm/include/*.h")
list(APPEND SOURCE ${NNVMSOURCE})

if(USE_PLUGINS_WARPCTC)
set(WARPCTC_INCLUDE "" CACHE PATH "WARPCTC include")
set(WARPCTC_LIB "" CACHE FILEPATH "WARPCTC lib")
Expand Down Expand Up @@ -241,6 +266,7 @@ target_link_libraries(mxnet dmlccore)

if(MSVC AND USE_MXNET_LIB_NAMING)
set_target_properties(mxnet PROPERTIES OUTPUT_NAME "libmxnet")

endif()

if(USE_DIST_KVSTORE)
Expand Down
4 changes: 2 additions & 2 deletions python/mxnet/cython/symbol.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ cdef class SymbolBase:
cdef SymbolHandle chandle

cdef _set_handle(self, handle):
cdef unsigned long ptr
cdef unsigned long long ptr
if handle is None:
self.chandle = NULL
else:
Expand All @@ -71,7 +71,7 @@ cdef class SymbolBase:
if self.chandle == NULL:
return None
else:
return _ctypes.cast(<unsigned long>self.chandle, _ctypes.c_void_p)
return _ctypes.cast(<unsigned long long>self.chandle, _ctypes.c_void_p)
def __set__(self, value):
self._set_handle(value)

Expand Down
4 changes: 3 additions & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ def config_cython():
if not fn.endswith(".pyx"):
continue
ret.append(Extension(
"mxnet/%s/%s" % (subdir, fn[:-4]),
"mxnet/%s/.%s" % (subdir, fn[:-4]),
["mxnet/cython/%s" % fn],
include_dirs=["../include/", "../nnvm/include"],
library_dirs=['mxnet'],
libraries=['libmxnet'],
language="c++"))
return cythonize(ret)
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion src/c_api/c_api_symbolic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ int MXSymbolCreateFromFile(const char *fname, SymbolHandle *out) {
std::unique_ptr<dmlc::Stream> fi(dmlc::Stream::Create(fname, "r"));
dmlc::istream is(fi.get());
s->outputs = nnvm::pass::LoadJSON(
std::string(std::istreambuf_iterator<char>(is), {})).outputs;
std::string(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>())).outputs;
*out = s;
is.set_stream(nullptr);
API_END_HANDLE_ERROR(delete s);
Expand Down
3 changes: 2 additions & 1 deletion src/executor/graph_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ void GraphExecutor::InitDataEntryMemory(const std::vector<NDArray>& shared_pool)
size_t nword = (bytes + 3) / 4;
CHECK_LE(nword, std::numeric_limits<index_t>::max());
// allocate float arrays
data_pool_.emplace_back(NDArray(TShape({index_t(nword)}), ctx));
TShape shape{index_t(nword)};
data_pool_.emplace_back(NDArray(shape, ctx));
}
}
CHECK_EQ(data_pool_.size(), pool_info.size());
Expand Down

0 comments on commit fbc6910

Please sign in to comment.