diff --git a/.travis.yml b/.travis.yml index 88c837798c01..313c4ec2a52f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,32 @@ # disable sudo to use container based build sudo: false -# Enabling test on Linux and OS X + +language: cpp + os: - linux - osx -# Use Build Matrix to do lint and build seperately env: - matrix: - - TASK=lint LINT_LANG=cpp - - TASK=lint LINT_LANG=python - - TASK=doc - - TASK=build CXX=g++ - - TASK=python CXX=g++ - - TASK=python3 CXX=g++ - - TASK=python_naive CXX=g++ - - TASK=python_perdev CXX=g++ - - TASK=cpp_unittest CXX=g++ + # code analysis + - TASK=lint + # test doc build + - TASK=doc + # build mxnet.so with CUDA + - TASK=build + # run tests/cpp + - TASK=cpp_test + # run tests/python + - TASK=python_test + + # TODO, R test, distributed test, clang, more g++ versions + +matrix: + exclude: + - os: osx + env: TASK=lint + - os: osx + env: TASK=doc # dependent apt packages addons: @@ -33,38 +43,30 @@ addons: - libopencv-dev - gcc-4.8 - g++-4.8 - - clang - python-numpy - python-nose - python3-numpy - python3-dev - python3-nose - + - graphviz before_install: - export NVCC_PREFIX=${HOME} - - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi - - scripts/build_dmlc.sh - - export TRAVIS=dmlc-core/scripts/travis + - source dmlc-core/scripts/travis/travis_setup_env.sh - export PYTHONPATH=${PYTHONPATH}:${PWD}/python - - source ${TRAVIS}/travis_setup_env.sh - install: - - pip install cpplint pylint graphviz --user `whoami` - + - source tests/travis/setup.sh script: - - scripts/travis_script.sh - - -before_cache: - - ${TRAVIS}/travis_before_cache.sh + - tests/travis/run_test.sh cache: directories: - ${HOME}/.cache/usr +before_cache: + - dmlc-core/scripts/travis/travis_before_cache.sh notifications: # Emails are sent to the committer's git-configured email address by default, diff --git a/Makefile b/Makefile index 49fbd151ef5f..638568f68ad7 100644 --- a/Makefile +++ b/Makefile @@ -111,9 +111,11 @@ build/%_gpu.o: src/%.cu $(LIB_DEP) $(NVCC) -c -o $@ $(NVCCFLAGS) -Xcompiler "$(CFLAGS)" $< lib/libmxnet.a: $(ALL_DEP) + @mkdir -p $(@D) ar crv $@ $(filter %.o, $?) lib/libmxnet.so: $(ALL_DEP) + @mkdir -p $(@D) $(CXX) $(CFLAGS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS) # ps-lite @@ -127,6 +129,7 @@ $(DMLC_CORE)/libdmlc.a: bin/im2rec: tools/im2rec.cc $(DMLC_CORE)/libdmlc.a $(BIN) : + @mkdir -p $(@D) $(CXX) $(CFLAGS) -o $@ $(filter %.cpp %.o %.c %.a %.cc, $^) $(LDFLAGS) include tests/cpp/unittest.mk @@ -139,11 +142,13 @@ lint: rcpplint rcpplint: python dmlc-core/scripts/lint.py mxnet-rcpp ${LINT_LANG} R-package/src +doc: doxygen + doxygen: doxygen doc/Doxyfile clean: - $(RM) -r build lib/lib* *~ */*~ */*/*~ */*/*/*~ + $(RM) -r build lib bin *~ */*~ */*/*~ */*/*/*~ clean_all: clean cd $(DMLC_CORE); make clean; cd - diff --git a/bin/README b/bin/README deleted file mode 100644 index c44ad0da7d67..000000000000 --- a/bin/README +++ /dev/null @@ -1 +0,0 @@ -This is where the executable files of mxnet tools will be generated into. diff --git a/include/mxnet/c_api.h b/include/mxnet/c_api.h index d3b21c057697..1dc302d0d77b 100644 --- a/include/mxnet/c_api.h +++ b/include/mxnet/c_api.h @@ -393,14 +393,14 @@ MXNET_DLL int MXSymbolCreateFromFile(const char *fname, SymbolHandle *out); MXNET_DLL int MXSymbolCreateFromJSON(const char *json, SymbolHandle *out); /*! * \brief Save a symbol into a json file. - * \param sym the input symbol. + * \param symbol the input symbol. * \param fname the file name. * \return 0 when success, -1 when failure happens */ MXNET_DLL int MXSymbolSaveToFile(SymbolHandle symbol, const char *fname); /*! * \brief Save a symbol into a json string - * \param sym the input symbol. + * \param symbol the input symbol. * \param out_json output json string. * \return 0 when success, -1 when failure happens */ @@ -551,7 +551,7 @@ MXNET_DLL int MXSymbolInferShape(SymbolHandle sym, * \param out_str pointer to hold the output string of the printing. * \return 0 when success, -1 when failure happens */ -MXNET_DLL int MXExecutorPrint(ExecutorHandle symbol, const char **out_str); +MXNET_DLL int MXExecutorPrint(ExecutorHandle handle, const char **out_str); /*! * \brief Executor forward method * @@ -759,7 +759,7 @@ MXNET_DLL int MXKVStorePull(KVStoreHandle handle, mx_uint num, int* keys, NDArrayHandle* vals, - int Priority); + int priority); /*! * \brief user-defined updater for the kvstore * It's this updater's responsibility to delete \a recv and \a local @@ -793,7 +793,7 @@ MXNET_DLL int MXKVStoreSetUpdater(KVStoreHandle handle, * \return 0 when success, -1 when failure happens */ MXNET_DLL int MXKVStoreGetRank(KVStoreHandle handle, - int *rank); + int *ret); /** * \brief return The number of nodes in this group, which is @@ -805,7 +805,7 @@ MXNET_DLL int MXKVStoreGetRank(KVStoreHandle handle, * \return 0 when success, -1 when failure happens */ MXNET_DLL int MXKVStoreGetGroupSize(KVStoreHandle handle, - int *size); + int *ret); /** * \brief return whether or not this process is a worker node. @@ -881,7 +881,7 @@ typedef void (MXKVStoreServerController)(int head, * \return Run as server (or scheduler) * * \param handle handle to the KVStore - * \param controler the user-defined server controller + * \param controller the user-defined server controller * \return 0 when success, -1 when failure happens */ MXNET_DLL int MXKVStoreRunServer(KVStoreHandle handle, diff --git a/include/mxnet/engine.h b/include/mxnet/engine.h index 065ddcb74aa6..03eb45b54de0 100644 --- a/include/mxnet/engine.h +++ b/include/mxnet/engine.h @@ -144,7 +144,7 @@ class Engine { * The delete will not happen immediately, but will wait until all the * operations depending on var are completed. * - * \param delete_fun A function that will be called after the variable is + * \param delete_fn A function that will be called after the variable is * deleted. * \param exec_ctx Execution context. * \param var The variable to be deleted. diff --git a/include/mxnet/kvstore.h b/include/mxnet/kvstore.h index 5126ebe3c5ba..da7d94a75cfd 100644 --- a/include/mxnet/kvstore.h +++ b/include/mxnet/kvstore.h @@ -78,7 +78,7 @@ class KVStore { * always has the same shape as being inited. * * \param keys the list of keys - * \param value the list of values + * \param values the list of values * \param priority Priority of the action. */ virtual void Push(const std::vector& keys, @@ -123,7 +123,7 @@ class KVStore { * value stored on the store node. The store updates \a y by `h(x, &y)`. The * default \a h is ASSIGN, namely `*y = x`. * - * \param updt user-defined updater, default is assign + * \param updater user-defined updater, default is assign */ void set_updater(Updater updater) { updater_ = updater; diff --git a/include/mxnet/ndarray.h b/include/mxnet/ndarray.h index f9ab9386e8c0..fce3d61f6855 100644 --- a/include/mxnet/ndarray.h +++ b/include/mxnet/ndarray.h @@ -246,7 +246,7 @@ class NDArray { * \brief Save list of narray into the file. * \param fname name of the file. * \param data the NDArrays to be saved. - * \param keys the name of the NDArray, optional, can be zero length. + * \param names the name of the NDArray, optional, can be zero length. */ static void Save(const std::string& fname, const std::vector& data, @@ -344,7 +344,7 @@ void CopyFromTo(const NDArray &from, NDArray *to, int priority = 0); /*! * \brief Perform elementwise sum over each data from source, store result into out. * \param source the ndarray we want to sum - * \param to the target ndarray + * \param out the target ndarray * \param priority Priority of the action. */ void ElementwiseSum(const std::vector &source, NDArray *out, int priority = 0); diff --git a/include/mxnet/resource.h b/include/mxnet/resource.h index 53a6dd6698e6..ded89adcb254 100644 --- a/include/mxnet/resource.h +++ b/include/mxnet/resource.h @@ -57,7 +57,7 @@ struct Resource { Resource() : id(0) {} /*! * \brief Get random number generator. - * \param The stream to use in the random number generator. + * \param stream The stream to use in the random number generator. * \return the mshadow random number generator requested. * \tparam xpu the device type of random number generator. */ diff --git a/lib/README.md b/lib/README.md deleted file mode 100644 index 24d68ff1acba..000000000000 --- a/lib/README.md +++ /dev/null @@ -1 +0,0 @@ -MXNet library diff --git a/scripts/build_dmlc.sh b/scripts/build_dmlc.sh deleted file mode 100755 index a5000499d084..000000000000 --- a/scripts/build_dmlc.sh +++ /dev/null @@ -1,27 +0,0 @@ -#! /bin/bash - -if [ ! -d mshadow ]; then - git clone https://github.com/dmlc/mshadow.git -fi - -if [ ! -d rabit ]; then - git clone https://github.com/dmlc/rabit.git -fi - -if [ ! -d dmlc-core ]; then - git clone https://github.com/dmlc/dmlc-core.git -fi - - -if [ ! -f config.mk ]; then - echo "Use the default config.m" - cp make/config.mk config.mk -fi - -cd rabit -make -j4 -cd .. - -cd dmlc-core -make -j4 -cd .. diff --git a/scripts/travis_osx_install.sh b/scripts/travis_osx_install.sh deleted file mode 100755 index 04929633ee5a..000000000000 --- a/scripts/travis_osx_install.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -brew update -brew tap homebrew/science -brew info opencv -brew install graphviz -brew install opencv - -if [ ${TASK} == "python-package3" ]; then - wget -O conda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -else - wget -O conda.sh https://repo.continuum.io/miniconda/Miniconda-latest-MacOSX-x86_64.sh -fi - - -bash conda.sh -b -p $HOME/miniconda -export PATH="$HOME/miniconda/bin:$PATH" -hash -r -conda config --set always_yes yes --set changeps1 no -conda update -q conda -# Useful for debugging any issues with conda -conda info -a - -if [ ${TASK} == "package3" ]; then - conda create -n myenv python=3.4 -else - conda create -n myenv python=2.7 -fi -source activate myenv -conda install numpy scipy matplotlib nose -python -m pip install graphviz \ No newline at end of file diff --git a/scripts/travis_script.sh b/scripts/travis_script.sh deleted file mode 100755 index a56b73c469b9..000000000000 --- a/scripts/travis_script.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash - -# main script of travis -if [ ${TASK} == "lint" ]; then - if [ ${TRAVIS_OS_NAME} != "osx" ]; then - make lint || exit -1 - fi - exit 0 -fi - -if [ ${TASK} == "doc" ]; then - if [ ${TRAVIS_OS_NAME} != "osx" ]; then - make doc 2>log.txt - (cat log.txt|grep warning) && exit -1 - fi - exit 0 -fi - -# prereqs for things that need make -cp make/config.mk config.mk - -export NOSE3=nosetests3 -export PYTHON3=python3 -if [ ${TRAVIS_OS_NAME} == "osx" ]; then - source scripts/travis_osx_install.sh - echo "USE_BLAS=apple" >> config.mk - echo "USE_OPENMP=0" >> config.mk - alias nosetests='python -m nose' - export NOSE3='python -m nose' - export PYTHON3=python -else - echo "USE_BLAS=blas" >> config.mk - echo "USE_CUDNN=0" >> config.mk - echo "CXX=g++-4.8" >> config.mk - export CXX="g++-4.8" -fi - -echo "USE_S3=0" >> config.mk - -if [ ${TASK} == "build" ]; then - if [ ${TRAVIS_OS_NAME} != "osx" ]; then - echo "USE_CUDA=1" >> config.mk - echo "USE_THREADED_ENGINE=1" >> config.mk - ./dmlc-core/scripts/setup_nvcc.sh $NVCC_PREFIX - make all || exit -1 - fi -fi - -if [ ${TASK} == "python" ]; then - echo "USE_CUDA=0" >> config.mk - make all || exit -1 - python --version - export MXNET_ENGINE_TYPE=ThreadedEngine - nosetests tests/python/unittest || exit -1 - nosetests tests/python/train || exit -1 -fi - -if [ ${TASK} == "python3" ]; then - echo "USE_CUDA=0" >> config.mk - make all || exit -1 - export MXNET_ENGINE_TYPE=ThreadedEngine - ${PYTHON3} --version - ${NOSE3} tests/python/unittest || exit -1 - ${NOSE3} tests/python/train || exit -1 -fi - -if [ ${TASK} == "python_naive" ]; then - echo "USE_CUDA=0" >> config.mk - make all || exit -1 - export MXNET_ENGINE_TYPE=NaiveEngine - python --version - nosetests tests/python/unittest || exit -1 - nosetests tests/python/train || exit -1 -fi - -if [ ${TASK} == "python_perdev" ]; then - echo "USE_CUDA=0" >> config.mk - make all || exit -1 - export MXNET_ENGINE_TYPE=ThreadedEnginePerDevice - python --version - nosetests tests/python/unittest || exit -1 - nosetests tests/python/train || exit -1 -fi - -if [ ${TASK} == "cpp_unittest" ]; then - make -f dmlc-core/scripts/packages.mk gtest - echo "USE_CUDA=0" >> config.mk - echo "GTEST_PATH="${CACHE_PREFIX} >> config.mk - make test || exit -1 - export MXNET_ENGINE_TYPE=ThreadedEngine - export MXNET_ENGINE_INFO=true - for test in tests/cpp/*_test; do - ./$test || exit -1 - done -fi - diff --git a/src/common/lazy_alloc_array.h b/src/common/lazy_alloc_array.h index 28c4c259c603..d3722e557b04 100644 --- a/src/common/lazy_alloc_array.h +++ b/src/common/lazy_alloc_array.h @@ -29,7 +29,7 @@ class LazyAllocArray { inline TElem* Get(int index, FCreate creator); /*! * \brief for each not null element of the array, call fvisit - * \param fviist a function of (size_t, TElem*) + * \param fvisit a function of (size_t, TElem*) */ template inline void ForEach(FVisit fvisit); diff --git a/tests/travis/run_test.sh b/tests/travis/run_test.sh new file mode 100755 index 000000000000..a0ebcd9edfcd --- /dev/null +++ b/tests/travis/run_test.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +if [ ${TASK} == "lint" ]; then + make lint + exit $? +fi + +if [ ${TASK} == "doc" ]; then + make doc | tee 2>log.txt + (cat log.txt|grep warning) && exit -1 + exit 0 +fi + +cp make/config.mk config.mk + +if [ ${TRAVIS_OS_NAME} == "osx" ]; then + echo "USE_BLAS=apple" >> config.mk + echo "USE_OPENMP=0" >> config.mk +else + # use g++-4.8 for linux + if [ ${CXX} == "g++" ]; then + export CXX=g++-4.8 + fi + echo "USE_BLAS=blas" >> config.mk +fi +echo "CXX=${CXX}" >>config.mk + +if [ ${TASK} == "build" ]; then + if [ ${TRAVIS_OS_NAME} == "linux" ]; then + echo "USE_CUDA=1" >> config.mk + ./dmlc-core/scripts/setup_nvcc.sh $NVCC_PREFIX + fi + make all + exit $? +fi + +if [ ${TASK} == "cpp_test" ]; then + make -f dmlc-core/scripts/packages.mk gtest + echo "GTEST_PATH="${CACHE_PREFIX} >> config.mk + make test || exit -1 + export MXNET_ENGINE_INFO=true + for test in tests/cpp/*_test; do + ./$test || exit -1 + done + exit 0 +fi + +if [ ${TASK} == "python_test" ]; then + make all || exit -1 + # use cached dir for storing data + rm -rf ${PWD}/data + mkdir -p ${CACHE_PREFIX}/data + ln -s ${CACHE_PREFIX}/data ${PWD}/data + + if [ ${TRAVIS_OS_NAME} == "osx" ]; then + python -m nose tests/python/unittest || exit -1 + # python -m nose tests/python/train || exit -1 + python3 -m nose tests/python/unittest || exit -1 + python3 -m nose tests/python/train || exit -1 + else + nosetests tests/python/unittest || exit -1 + # nosetests tests/python/train || exit -1 + nosetests3 tests/python/unittest || exit -1 + nosetests3 tests/python/train || exit -1 + fi + exit 0 +fi diff --git a/tests/travis/setup.sh b/tests/travis/setup.sh new file mode 100755 index 000000000000..1f465f61e4cc --- /dev/null +++ b/tests/travis/setup.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +if [ ${TRAVIS_OS_NAME} == "osx" ]; then + brew update + brew tap homebrew/science + brew info opencv + brew install opencv + brew install python3 + if [ ${TASK} == "python_test" ]; then + python -m pip install nose numpy --user `whoami` + python3 -m pip install nose numpy --user `whoami` + fi +fi + +if [ ${TASK} == "lint" ]; then + pip install cpplint pylint --user `whoami` +fi