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
Browse files Browse the repository at this point in the history
  • Loading branch information
yajiedesign committed Sep 9, 2016
1 parent 85c2f9b commit 4b0816c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
29 changes: 28 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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 @@ -31,6 +32,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 @@ -66,7 +69,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 @@ -76,7 +79,9 @@ if(USE_CUDNN)
endif()
endif()


add_subdirectory("dmlc-core")

if(USE_DIST_KVSTORE)
add_subdirectory("ps-lite")
endif()
Expand All @@ -92,6 +97,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 @@ -117,10 +123,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 @@ -185,8 +210,10 @@ endif()
target_link_libraries(mxnet ${mxnet_LINKER_LIBS})
target_link_libraries(mxnet dmlccore)


if(MSVC)
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 @@ -49,7 +49,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 @@ -61,7 +61,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 @@ -31,9 +31,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 4b0816c

Please sign in to comment.