Skip to content

Commit

Permalink
move scripts under scripts directory
Browse files Browse the repository at this point in the history
  • Loading branch information
okapies committed Sep 20, 2018
1 parent a7a597b commit 83f1b74
Show file tree
Hide file tree
Showing 20 changed files with 108 additions and 104 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ matrix:
install:
- if [ "$TRAVIS_OS_NAME" = "linux" -a "$CXX" = "g++" ]; then export CXX="g++-7" CC="gcc-7"; fi
- |
bash -ex ${TRAVIS_BUILD_DIR}/.travis/build-mkldnn.sh \
bash -ex ${TRAVIS_BUILD_DIR}/scripts/build-mkldnn.sh \
--version ${MKLDNN_VERSION} \
--download-dir ${HOME}/downloads \
--extract-dir ${HOME}/build \
--install-dir ${HOME}/mkl-dnn-${MKLDNN_VERSION} \
--parallel ${MAKE_JOBS}
- |
bash -ex ${TRAVIS_BUILD_DIR}/.travis/install-mkldnn.sh \
bash -ex ${TRAVIS_BUILD_DIR}/scripts/install-mkldnn.sh \
--build-dir ${HOME}/build/mkl-dnn-${MKLDNN_VERSION}/build
script: true # skip build and test

Expand Down
2 changes: 1 addition & 1 deletion .travis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Linux-based platforms requires a container image with the following softwares:
Currently it uses [okapies/buildenv](https://hub.docker.com/r/okapies/buildenv/) image for linux-x86_64 platform.

## Architecture
`.travis.yml` -> `run-build.sh` -> `build.sh` -> `install-*.sh` & `build-menoh.sh`
`.travis.yml` -> `run-build.sh` -> `build.sh` -> `scripts/*.sh`

1. `run-build.sh` just calls a platform's `build.sh` for running the actual build workflow
2. `build.sh`
Expand Down
44 changes: 22 additions & 22 deletions .travis/init-build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export MKLDNN_INSTALL_DIR=/usr/local
# $HOME:$HOME = /home/travis : /home/travis
# /home/travis/build : /home/travis/build
# /home/travis/build/<user>/<repo> : /home/travis/build/<user>/<repo> (= ${TRAVIS_BUILD_DIR})
SHARED_SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
source ${SHARED_SCRIPT_DIR}/run-container.sh --image ${BUILDENV_IMAGE} --work-dir ${WORK_DIR}
SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}/..")"; pwd)
source ${SOURCE_DIR}/scripts/run-container.sh --image ${BUILDENV_IMAGE} --work-dir ${WORK_DIR}
test -n "${BUILDENV_CONTAINER_ID}" || { echo "BUILDENV_CONTAINER_ID can't be empty" 1>&2; exit 1; }

## define shared functions for Linux-based platforms
Expand All @@ -36,64 +36,64 @@ function docker_exec_script() {

function build_protobuf() {
docker_exec_script \
${PROJ_DIR}/.travis/build-protobuf.sh \
"${PROJ_DIR}/scripts/build-protobuf.sh" \
--version ${PROTOBUF_VERSION} \
--download-dir ${WORK_DIR}/downloads \
--extract-dir ${WORK_DIR}/build \
--install-dir ${PROTOBUF_INSTALL_DIR} \
--download-dir "${WORK_DIR}/downloads" \
--extract-dir "${WORK_DIR}/build" \
--install-dir "${PROTOBUF_INSTALL_DIR}" \
--parallel ${MAKE_JOBS}
}

function install_protobuf() {
docker_exec_script \
${PROJ_DIR}/.travis/install-protobuf.sh \
--build-dir ${WORK_DIR}/build/protobuf-${PROTOBUF_VERSION}
"${PROJ_DIR}/scripts/install-protobuf.sh" \
--build-dir "${WORK_DIR}/build/protobuf-${PROTOBUF_VERSION}"
}

function build_mkldnn() {
docker_exec_script \
${PROJ_DIR}/.travis/build-mkldnn.sh \
"${PROJ_DIR}/scripts/build-mkldnn.sh" \
--version ${MKLDNN_VERSION} \
--download-dir ${WORK_DIR}/downloads \
--extract-dir ${WORK_DIR}/build \
--install-dir ${MKLDNN_INSTALL_DIR} \
--download-dir "${WORK_DIR}/downloads" \
--extract-dir "${WORK_DIR}/build" \
--install-dir "${MKLDNN_INSTALL_DIR}" \
--parallel ${MAKE_JOBS}
}

function install_mkldnn() {
docker_exec_script \
${PROJ_DIR}/.travis/install-mkldnn.sh \
--build-dir ${WORK_DIR}/build/mkl-dnn-${MKLDNN_VERSION}/build
"${PROJ_DIR}/scripts/install-mkldnn.sh" \
--build-dir "${WORK_DIR}/build/mkl-dnn-${MKLDNN_VERSION}/build"
}

function prepare_menoh_data() {
docker_exec_script \
${PROJ_DIR}/.travis/prepare-menoh-data.sh \
--source-dir ${PROJ_DIR} \
"${PROJ_DIR}/scripts/prepare-menoh-data.sh" \
--source-dir "${PROJ_DIR}" \
--python-executable python3
}

function build_menoh() {
if [ "${LINK_STATIC}" != "true" ]; then
docker_exec_script \
${PROJ_DIR}/.travis/build-menoh.sh \
"${PROJ_DIR}/scripts/build-menoh.sh" \
--build-type Release \
--source-dir ${PROJ_DIR}
--source-dir "${PROJ_DIR}"
else
docker_exec_script \
${PROJ_DIR}/.travis/build-menoh.sh \
"${PROJ_DIR}/scripts/build-menoh.sh" \
--build-type Release \
--source-dir ${PROJ_DIR} \
--source-dir "${PROJ_DIR}" \
--link-static-libgcc ON \
--link-static-libstdcxx ON \
--link-static-libprotobuf ON
fi
}

function test_menoh() {
docker_exec "cd ${PROJ_DIR}/build && ./test/menoh_test"
docker_exec "cd \"${PROJ_DIR}/build\" && ./test/menoh_test"
}

function check_menoh_artifact() {
docker_exec "ldd ${PROJ_DIR}/build/menoh/libmenoh.so"
docker_exec "ldd \"${PROJ_DIR}/build/menoh/libmenoh.so\""
}
16 changes: 8 additions & 8 deletions .travis/init-build-osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ export PROJ_DIR=${TRAVIS_BUILD_DIR} # = ${HOME}/build/${TRAVIS_REPO_SLUG}
## define shared functions for macOS (OSX) platforms

function prepare_menoh_data() {
bash -ex ${PROJ_DIR}/.travis/prepare-menoh-data.sh \
--source-dir ${PROJ_DIR} \
bash -ex "${PROJ_DIR}/scripts/prepare-menoh-data.sh" \
--source-dir "${PROJ_DIR}" \
--python-executable python
}

function build_menoh() {
if [ "${LINK_STATIC}" != "true" ]; then
bash -ex ${PROJ_DIR}/.travis/build-menoh.sh \
bash -ex "${PROJ_DIR}/scripts/build-menoh.sh" \
--build-type Release \
--source-dir ${PROJ_DIR}
--source-dir "${PROJ_DIR}"
else
# Does not set --link-static-libgcc and --link-static-libstdcxx in macOS
bash -ex ${PROJ_DIR}/.travis/build-menoh.sh \
bash -ex "${PROJ_DIR}/scripts/build-menoh.sh" \
--build-type Release \
--source-dir ${PROJ_DIR} \
--source-dir "${PROJ_DIR}" \
--link-static-libprotobuf ON
fi
}

function test_menoh() {
cd ${PROJ_DIR}/build
cd "${PROJ_DIR}/build"
./test/menoh_test
}

function check_menoh_artifact() {
otool -L ${PROJ_DIR}/build/menoh/libmenoh.dylib
otool -L "${PROJ_DIR}/build/menoh/libmenoh.dylib"
}
2 changes: 1 addition & 1 deletion .travis/linux-x86_64/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -ex

BASE_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
BASE_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)

# initialize this script
source ${BASE_DIR}/../init-build-linux.sh
Expand Down
2 changes: 1 addition & 1 deletion .travis/macosx-x86_64/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

BASE_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
BASE_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)

# initialize this script
source ${BASE_DIR}/../init-build-osx.sh
Expand Down
2 changes: 1 addition & 1 deletion BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ make install # as root
To run the example, you also need to download model data:

```
python retrieve_data.py
python scripts/retrieve_data.py
```

#### Static linking
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ This codebase contains C API and C++ API.
Execute following commands in root directory.
```
python retrieve_data.py
python scripts/retrieve_data.py
mkdir build && cd build
cmake ..
make
Expand Down Expand Up @@ -111,7 +111,7 @@ Setup chainer
Then, execute following commands in root directory.
```
python gen_test_data.py
python scripts/gen_test_data.py
cd build
cmake -DENABLE_TEST=ON ..
make
Expand Down Expand Up @@ -155,7 +155,7 @@ make
Menoh is released under MIT License. Please see the LICENSE file for details.
Note: `retrieve_data.py` downloads `data/VGG16.onnx`. `data/VGG16.onnx` is generated by onnx-chainer from pre-trained model which is uploaded
Note: `scripts/retrieve_data.py` downloads `data/VGG16.onnx`. `data/VGG16.onnx` is generated by onnx-chainer from pre-trained model which is uploaded
at http://www.robots.ox.ac.uk/%7Evgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel
That pre-trained model is released under Creative Commons Attribution License.
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ install:
- if [%TARGET%]==[mingw] (
pip3 install --user chainer &&
mkdir -p data &&
python3 retrieve_data.py &&
python3 gen_test_data.py
python3 scripts/retrieve_data.py &&
python3 scripts/gen_test_data.py
) else (
pip install --user chainer &&
md data &&
python retrieve_data.py &&
python gen_test_data.py
python scripts/retrieve_data.py &&
python scripts/gen_test_data.py
)

before_build:
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ make install
Execute below command in root directory:

```
python retrieve_data.py
python scripts/retrieve_data.py
cd build
./example/vgg16_example
```
Expand Down Expand Up @@ -68,7 +68,7 @@ Please give `--help` option for details
Execute below commands in root directory:

```
python gen_test_data.py
python scripts/gen_test_data.py
cd build
cmake -DENABLE_TEST=ON ..
make
Expand Down
2 changes: 1 addition & 1 deletion docs/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Menoh is released under MIT License.

Menoh is released under MIT License. Please see the LICENSE file for details.

Note: `retrieve_data.sh` downloads `data/VGG16.onnx`.
Note: `scripts/retrieve_data.sh` downloads `data/VGG16.onnx`.

`data/VGG16.onnx` is generated by onnx-chainer from pre-trained model which is uploaded
at http://www.robots.ox.ac.uk/%7Evgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel
Expand Down
36 changes: 18 additions & 18 deletions .travis/build-menoh.sh → scripts/build-menoh.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
#!/bin/bash -e

BASE_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)

# retrieve arguments
while [[ $# != 0 ]]; do
Expand Down Expand Up @@ -50,37 +52,35 @@ while [[ $# != 0 ]]; do
esac
done

# validate the arguments
test -n "${ARG_SOURCE_DIR}" || { echo "--source-dir is not specified" 1>&2; exit 1; }

# options that have default value
test -n "${ARG_BUILD_DIR}" || readonly ARG_BUILD_DIR=${ARG_SOURCE_DIR}/build
test -n "${ARG_BUILD_TYPE}" || readonly ARG_BUILD_TYPE=Debug
test -n "${ARG_SOURCE_DIR}" || readonly ARG_SOURCE_DIR="${BASE_DIR}/.."
test -n "${ARG_BUILD_DIR}" || readonly ARG_BUILD_DIR="${ARG_SOURCE_DIR}/build"
test -n "${ARG_INSTALL_DIR}" || readonly ARG_INSTALL_DIR=/usr/local

if [ -n "${ARG_MKLDNN_DIR}" ]; then
OPT_MKLDNN_INCLUDE_DIR=-DMKLDNN_INCLUDE_DIR=${ARG_MKLDNN_DIR}/include
OPT_MKLDNN_LIBRARY=-DMKLDNN_LIBRARY=${ARG_MKLDNN_DIR}/lib/libmkldnn.so
fi

test -n "${ARG_LINK_STATIC_LIBGCC}" || readonly ARG_LINK_STATIC_LIBGCC='OFF'
test -n "${ARG_LINK_STATIC_LIBSTDCXX}" || readonly ARG_LINK_STATIC_LIBSTDCXX='OFF'
test -n "${ARG_LINK_STATIC_LIBPROTOBUF}" || readonly ARG_LINK_STATIC_LIBPROTOBUF='OFF'

echo -e "\e[33;1mBuilding Menoh\e[0m"

[ -d "${ARG_BUILD_DIR}" ] || mkdir -p ${ARG_BUILD_DIR}
[ -d "${ARG_BUILD_DIR}" ] || mkdir -p "${ARG_BUILD_DIR}"

cd ${ARG_BUILD_DIR}
if [ -n "${ARG_INSTALL_DIR}" ]; then
OPT_CMAKE_INSTALL_PREFIX=-DCMAKE_INSTALL_PREFIX=${ARG_INSTALL_DIR}
fi
if [ -n "${ARG_MKLDNN_DIR}" ]; then
OPT_MKLDNN_INCLUDE_DIR=-DMKLDNN_INCLUDE_DIR=${ARG_MKLDNN_DIR}/include
OPT_MKLDNN_LIBRARY=-DMKLDNN_LIBRARY=${ARG_MKLDNN_DIR}/lib/libmkldnn.so
fi
cd "${ARG_BUILD_DIR}"
cmake \
-DCMAKE_BUILD_TYPE=${ARG_BUILD_TYPE} \
${OPT_CMAKE_INSTALL_PREFIX} \
${OPT_MKLDNN_INCLUDE_DIR} \
${OPT_MKLDNN_LIBRARY} \
"-DCMAKE_INSTALL_PREFIX=${ARG_INSTALL_DIR}" \
"${OPT_MKLDNN_INCLUDE_DIR}" \
"${OPT_MKLDNN_LIBRARY}" \
-DLINK_STATIC_LIBGCC=${ARG_LINK_STATIC_LIBGCC} \
-DLINK_STATIC_LIBSTDCXX=${ARG_LINK_STATIC_LIBSTDCXX} \
-DLINK_STATIC_LIBPROTOBUF=${ARG_LINK_STATIC_LIBPROTOBUF} \
-DENABLE_TEST=ON \
${ARG_SOURCE_DIR}
"${ARG_SOURCE_DIR}"

make
29 changes: 15 additions & 14 deletions .travis/build-mkldnn.sh → scripts/build-mkldnn.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -e

# retrieve arguments
while [[ $# != 0 ]]; do
Expand Down Expand Up @@ -42,30 +42,31 @@ while [[ $# != 0 ]]; do
done

# validate the arguments
test -n "${ARG_VERSION}" || { echo "--version is not specified" 1>&2; exit 1; }
test -n "${ARG_DOWNLOAD_DIR}" || { echo "--download-dir is not specified" 1>&2; exit 1; }
test -n "${ARG_EXTRACT_DIR}" || { echo "--extract-dir is not specified" 1>&2; exit 1; }
test -n "${ARG_INSTALL_DIR}" || { echo "--install-dir is not specified" 1>&2; exit 1; }

# options that have default value
test -n "${ARG_VERSION}" || readonly ARG_VERSION=0.16

readonly LIBRARY_NAME=mkl-dnn-${ARG_VERSION}
readonly SOURCE_DIR=${ARG_EXTRACT_DIR}/${LIBRARY_NAME}
readonly SOURCE_DIR="${ARG_EXTRACT_DIR}/${LIBRARY_NAME}"

# options that have default value
test -n "${ARG_BUILD_DIR}" || readonly ARG_BUILD_DIR=${SOURCE_DIR}/build
test -n "${ARG_BUILD_DIR}" || readonly ARG_BUILD_DIR="${SOURCE_DIR}/build"
test -n "${ARG_INSTALL_DIR}" || readonly ARG_INSTALL_DIR=/usr/local
test -n "${ARG_PARALLEL}" || readonly ARG_PARALLEL=1

# download (if it isn't cached)
if [ ! -e "${SOURCE_DIR}/LICENSE" ]; then
echo -e "\e[33;1mDownloading libmkldnn\e[0m"

[ -d "${ARG_DOWNLOAD_DIR}" ] || mkdir -p ${ARG_DOWNLOAD_DIR}
[ -d "${ARG_DOWNLOAD_DIR}" ] || mkdir -p "${ARG_DOWNLOAD_DIR}"

cd ${ARG_DOWNLOAD_DIR}
cd "${ARG_DOWNLOAD_DIR}"
if [ ! -e "${LIBRARY_NAME}.tar.gz" ]; then
download_url="https://github.com/intel/mkl-dnn/archive/v${ARG_VERSION}.tar.gz"
wget -O ${LIBRARY_NAME}.tar.gz ${download_url}
fi
tar -zxf ${LIBRARY_NAME}.tar.gz -C ${ARG_EXTRACT_DIR}
tar -zxf ${LIBRARY_NAME}.tar.gz -C "${ARG_EXTRACT_DIR}"

echo -e "\e[32;1mlibmkldnn was successfully downloaded.\e[0m"
else
Expand All @@ -76,20 +77,20 @@ fi
if [ ! -e "${ARG_BUILD_DIR}/src/libmkldnn.so" ]; then
echo -e "\e[33;1mBuilding libmkldnn\e[0m"

cd ${SOURCE_DIR}/scripts
cd "${SOURCE_DIR}/scripts"
./prepare_mkl.sh

[ -d "${ARG_BUILD_DIR}" ] || mkdir -p ${ARG_BUILD_DIR}
[ -d "${ARG_BUILD_DIR}" ] || mkdir -p "${ARG_BUILD_DIR}"

cd ${ARG_BUILD_DIR}
cd "${ARG_BUILD_DIR}"
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${ARG_INSTALL_DIR} \
"-DCMAKE_INSTALL_PREFIX=${ARG_INSTALL_DIR}" \
-DWITH_TEST=OFF \
-DWITH_EXAMPLE=OFF \
-DARCH_OPT_FLAGS='' \
-Wno-error=unused-result \
${SOURCE_DIR}
"${SOURCE_DIR}"
make -j${ARG_PARALLEL}

echo -e "\e[32;1mlibmkldnn was successfully built.\e[0m"
Expand Down
Loading

0 comments on commit 83f1b74

Please sign in to comment.