Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metal] enable unit_test in macos ci build #550

Closed
wants to merge 9 commits into from
30 changes: 25 additions & 5 deletions scripts/build_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@
SHARED_LIB="ON"
METAL="ON"

SD=$(cd `dirname $0`; pwd)
if [ -z $TNN_ROOT_PATH ]
then
TNN_ROOT_PATH=$(cd `dirname $0`; pwd)/..
TNN_ROOT_PATH=${SD}/..
fi
CWD=$(pwd)

function CheckRtnAndPrintMsg()
{
if [ 0 -ne $? ]
then
echo $1' failed.'
exit -1
fi
echo $1' completes.'
}

mkdir build_macos
cd build_macos
Expand All @@ -24,9 +36,17 @@ cmake ${TNN_ROOT_PATH} \
make -j4

# check if compiling error occurs, or ci will ignore building errors
if [ 0 -ne $? ]
then
echo 'building failed.'
CheckRtnAndPrintMsg "building"

echo 'start unit_test'
cd test/unit_test
BUILD_PATH=${CWD}/build_macos
echo "check ${BUILD_PATH}"
if [ ! -f ${BUILD_PATH}/tnn.metallib ]; then
echo "No metallib found!"
exit -1
fi
echo 'building completes.'
./unit_test --lp ${BUILD_PATH}/tnn.metallib --dt METAL

# check if unit_test error occurs, or ci will ignore building errors
CheckRtnAndPrintMsg "unit_test"
2 changes: 1 addition & 1 deletion source/tnn/device/metal/build_tnn_metallib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function BuildMetalLib()
#build air files
for file in ${TNNAllMetalFiles[@]}
do
echo "\033[32m Compile ${file}\033[0m"
echo "\033[32m Compile ${file}\033[0m"
# echo 'TNNMetalFloat32 = '${TNNMetalFloat32}
xcrun -sdk macosx metal -std=osx-metal1.1 -DTNN_METAL_FULL_PRECISION -dM -I ${TNNMetalInclude} -c ${file} -o ${file}.air
TNNAllMetalAIRFiles+=(${file}.air)
Expand Down