Skip to content

Commit

Permalink
Update script to allow specify the git commit hash
Browse files Browse the repository at this point in the history
  • Loading branch information
icemelon committed Sep 3, 2020
1 parent 7808a84 commit 720d540
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
9 changes: 4 additions & 5 deletions scripts/build_pip_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ set -o pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DOCKER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../docker" && pwd)"
PIP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../pip" && pwd)"

DOCKER_TAG=`cat "${DOCKER_DIR}/version.txt"`
COMMIT_HASH=`cat "${SCRIPT_DIR}/tvm_commit_hash.txt"`

function usage() {
echo "Usage: $0 [--cuda CUDA] "
Expand All @@ -19,28 +21,25 @@ function usage() {
function in_array() {
KEY=$1
ARRAY=$2
#echo $2
for e in ${ARRAY[*]}; do
if [[ "$e" == "$1" ]]; then
#echo "found"
return 0
fi
done
#echo "not found"
return 1
}

function build_wheel() {
CUDA="$1"
ARGS="--hash ${COMMIT_HASH}"
if [[ ${CUDA} == "none" ]]; then
DOCKER_IMAGE="tlcpack/package-cpu:${DOCKER_TAG}"
CUDA_ENV=""
ARGS=""
echo "Building wheel for CPU only"
else
DOCKER_IMAGE="tlcpack/package-cu${CUDA/./}:${DOCKER_TAG}"
CUDA_ENV=" --gpus all "
ARGS="--cuda ${CUDA}"
ARGS="${ARGS} --cuda ${CUDA}"
echo "Building wheel with CUDA ${CUDA}"
fi

Expand Down
20 changes: 15 additions & 5 deletions scripts/build_tvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
source /multibuild/manylinux_utils.sh

function usage() {
echo "Usage: $0 [--cuda CUDA]"
echo "Usage: $0 [--cuda CUDA] [--hash HASH]"
echo
echo -e "--cuda {none 10.0 10.1 10.2}"
echo -e "\tSpecify the CUDA version in the TVM (default: none)."
echo -e "--hash HASH\tSpecify a git commit hash for TVM."
}

function in_array() {
Expand All @@ -22,6 +23,7 @@ function in_array() {

CUDA_OPTIONS=("none" "10.0" "10.1" "10.2")
CUDA="none"
HASH_TAG=""

while [[ $# -gt 0 ]]; do
arg="$1"
Expand All @@ -31,6 +33,11 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
--hash)
HASH_TAG=$2
shift
shift
;;
-h|--help)
usage
exit -1
Expand Down Expand Up @@ -60,6 +67,9 @@ fi
# check out the tvm
cd /workspace
git clone https://github.com/apache/incubator-tvm tvm --recursive
if [[ ${HASH_TAG} ]]; then
cd /workspace/tvm && git checkout ${HASH_TAG} && git submodule update --recursive
fi

# config the cmake
cd /workspace/tvm
Expand All @@ -79,6 +89,10 @@ cd build
cmake ..
make -j$(nproc)

# patch the package name
cd /workspace/tvm
/workspace/scripts/patch_name.sh ${CUDA}

UNICODE_WIDTH=32 # Dummy value, irrelevant for Python 3
CPYTHON36_PATH="$(cpython_path 3.6 ${UNICODE_WIDTH})"
CPYTHON37_PATH="$(cpython_path 3.7 ${UNICODE_WIDTH})"
Expand All @@ -90,10 +104,6 @@ PIP36="${CPYTHON36_PATH}/bin/pip"
PIP37="${CPYTHON37_PATH}/bin/pip"
PIP38="${CPYTHON38_PATH}/bin/pip"

# patch the package name
cd /workspace/tvm
/workspace/scripts/patch_name.sh ${CUDA}

# build the python wheel
cd /workspace/tvm/python
PATH="${CPYTHON36_PATH}/bin:$PATH" ${PYTHON36} setup.py bdist_wheel
Expand Down
1 change: 1 addition & 0 deletions scripts/tvm_commit_hash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9a42cb63d29710a37fc34211d0cdc502d0626771

0 comments on commit 720d540

Please sign in to comment.