-
Notifications
You must be signed in to change notification settings - Fork 766
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CONVERTER2TNN][UPD] 1. default do not clean build directory; (#694)
Co-authored-by: tiankai <tiankai@tencent.com>
- Loading branch information
1 parent
be65fd9
commit e6c176c
Showing
3 changed files
with
130 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,84 @@ | ||
if [ ! -d "bin" ]; then | ||
mkdir bin | ||
fi | ||
|
||
if [ ! -d "temp" ]; then | ||
mkdir temp | ||
fi | ||
|
||
function build_model_check() { | ||
cd $2 | ||
|
||
cmake ../../.. \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DTNN_CPU_ENABLE:BOOL="ON" \ | ||
-DTNN_MODEL_CHECK_ENABLE:BOOL="ON" \ | ||
-DTNN_CONVERTER_ENABLE:BOOL="ON" \ | ||
-DTNN_BUILD_SHARED="OFF" | ||
|
||
make -j4 | ||
cp tools/converter/TnnConverter ../bin/ | ||
|
||
if [ -f "model_check" ]; then | ||
mv model_check ../$1 | ||
|
||
cd .. | ||
|
||
rm -rf $2 | ||
|
||
cd ../onnx2tnn/onnx-converter | ||
./build.sh | ||
|
||
echo "Compiled successfully !" | ||
else | ||
cd .. | ||
rm -rf $1 $2 | ||
echo "Compiled failed !!!" | ||
fi | ||
#!/usr/bin/env bash | ||
|
||
CURRENT_DIR=$(pwd) | ||
CLEAN="" | ||
BUILD_DIR=build | ||
BIN_DIR=bin | ||
|
||
function usage() { | ||
echo "usage: ./build.sh [-c]" | ||
echo "options:" | ||
echo " -c Clean up build folders." | ||
} | ||
|
||
function clean_build() { | ||
echo $1 | grep "${BUILD_DIR}\b" >/dev/null | ||
if [[ "$?" != "0" ]]; then | ||
die "Warnning: $1 seems not to be a BUILD folder." | ||
fi | ||
rm -rf $1 | ||
mkdir -p $1 | ||
} | ||
|
||
function build_model_check_and_tnn_converter() { | ||
|
||
if [ "-c" == "${CLEAN}" ]; then | ||
clean_build ${BUILD_DIR} | ||
fi | ||
pwd | ||
mkdir -p ${BUILD_DIR} | ||
cd ${BUILD_DIR} | ||
|
||
cmake ../../.. \ | ||
-DCMAKE_BUILD_TYPE=DEBUG \ | ||
-DTNN_CPU_ENABLE:BOOL="ON" \ | ||
-DTNN_MODEL_CHECK_ENABLE:BOOL="ON" \ | ||
-DTNN_CONVERTER_ENABLE:BOOL="ON" \ | ||
-DTNN_BUILD_SHARED="OFF" \ | ||
-DDEBUG="ON" | ||
|
||
make -j4 | ||
|
||
if [ -f "model_check" ]; then | ||
cp model_check ../${BIN_DIR} | ||
echo "Compiled model_check successfully !" | ||
else | ||
|
||
echo "Compiled model_check failed !!!" | ||
fi | ||
|
||
if [ -f "tools/converter/TnnConverter" ]; then | ||
cp tools/converter/TnnConverter ../${BIN_DIR} | ||
echo "Compiled model_check successfully !" | ||
else | ||
echo "Compiled TNNConverter failed !!!" | ||
fi | ||
} | ||
|
||
build_model_check bin temp | ||
function build_onnx2tnn() { | ||
cd ${CURRENT_DIR} | ||
cd ../onnx2tnn/onnx-converter/ | ||
|
||
if [ "-c" == "${CLEAN}" ]; then | ||
./build.sh -c | ||
else | ||
./build.sh | ||
fi | ||
} | ||
|
||
while [ "$1" != "" ]; do | ||
case $1 in | ||
-c) | ||
shift | ||
CLEAN="-c" | ||
;; | ||
*) | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
build_model_check_and_tnn_converter | ||
|
||
build_onnx2tnn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,59 @@ | ||
export CMAKE=/path/to/cmake | ||
export CPP_COMPILER=/path/to/g++ | ||
export C_COMPILER=/path/to/gcc | ||
export PYTHON=/path/to/python3 | ||
##!/usr/bin/env bash | ||
|
||
# here is an example, make sure libpython3 is in LD_LIBRARY_PATH | ||
export CMAKE=cmake | ||
export CPP_COMPILER=g++ | ||
export C_COMPILER=gcc | ||
export PYTHON=`which python3` | ||
|
||
set -xe | ||
CLEAN="" | ||
BUILD_DIR=build | ||
|
||
if [ -d "build" ]; then | ||
rm -rf build/ | ||
fi | ||
#set -xe | ||
|
||
$PYTHON script/detect_dependency.py | ||
function usage() { | ||
echo "usage: ./build.sh [-c]" | ||
echo "options:" | ||
echo " -c Clean up build folders." | ||
} | ||
|
||
mkdir -p build | ||
cd build && $CMAKE .. \ | ||
-DCMAKE_CXX_COMPILER=$CPP_COMPILER \ | ||
-DCMAKE_C_COMPILER=$C_COMPILER \ | ||
-DPYTHON_EXECUTABLE=$PYTHON \ | ||
&& make -j4 && cd .. | ||
function clean_build() { | ||
echo $1 | grep "${BUILD_DIR}\b" > /dev/null | ||
if [[ "$?" != "0" ]]; then | ||
die "Warnning: $1 seems not to be a BUILD folder." | ||
fi | ||
rm -rf $1 | ||
mkdir -p $1 | ||
} | ||
|
||
cp build/*.so . | ||
function build() { | ||
|
||
rm -rf build/ | ||
$PYTHON script/detect_dependency.py | ||
if [ "-c" == "${CLEAN}" ]; then | ||
clean_build ${BUILD_DIR} | ||
fi | ||
mkdir -p ${BUILD_DIR} | ||
cd ${BUILD_DIR} | ||
|
||
${CMAKE} .. -DCMAKE_CXX_COMPILER=$CPP_COMPILER \ | ||
-DCMAKE_C_COMPILER=$C_COMPILER \ | ||
-DPYTHON_EXECUTABLE=$PYTHON \ | ||
|
||
make -j4 | ||
cp *.so ../ | ||
cd ../ | ||
} | ||
|
||
|
||
while [ "$1" != "" ]; do | ||
case $1 in | ||
-c) | ||
shift | ||
CLEAN="-c" | ||
;; | ||
*) | ||
usage | ||
exit 1 | ||
esac | ||
done | ||
|
||
build |