• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3set -e
4CUR_DIR=$(
5  cd "$(dirname $0)"
6  pwd
7)
8BUILD_DIR=${CUR_DIR}/../build
9
10export GLOG_v=2
11
12# prepare run directory for ut
13mkdir -pv ${CUR_DIR}/do_test
14
15# prepare data for ut
16cd ${CUR_DIR}/do_test
17cp ${BUILD_DIR}/test/lite-test ./
18ENABLE_CONVERTER_TEST=false
19if [ -f "${BUILD_DIR}/test/lite-test-converter" ]; then
20  cp ${BUILD_DIR}/test/lite-test-converter ./
21  ENABLE_CONVERTER_TEST=true
22fi
23cp ${BUILD_DIR}/googletest/googlemock/gtest/libgtest.so ./
24cp ${BUILD_DIR}/googletest/googlemock/gtest/libgmock.so ./
25ls -l *.so*
26if [[ "X${CUDA_HOME}" != "X" ]]; then
27  export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
28fi
29if [[ "X${TENSORRT_PATH}" != "X" ]]; then
30  export LD_LIBRARY_PATH=${TENSORRT_PATH}/lib:${LD_LIBRARY_PATH}
31fi
32export LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH}
33
34cp -r ${CUR_DIR}/ut/test_data/* ./
35cp -r ${CUR_DIR}/ut/src/runtime/kernel/arm/test_data/* ./
36cp -r ${CUR_DIR}/ut/tools/converter/parser/tflite/test_data/* ./
37cp -r ${CUR_DIR}/ut/tools/converter/registry/test_data/* ./
38# prepare data for dataset
39TEST_DATA_DIR=${CUR_DIR}/../../../tests/ut/data/dataset/
40cp -fr $TEST_DATA_DIR/testPK ./data
41
42echo 'run common ut tests'
43# test cases of MindData
44./lite-test --gtest_filter="*MindDataTestTensorDE*"
45./lite-test --gtest_filter="*MindDataTestEager*"
46
47# test cases of Converter
48## ./lite-test --gtest_filter="TestTfliteParser*"
49./lite-test --gtest_filter="ConvActFusionInoutTest*"
50./lite-test --gtest_filter="ConvBiasFusionInoutTest*"
51./lite-test --gtest_filter="ConcatActFusionInoutTest*"
52./lite-test --gtest_filter="MatmulMulFusionInoutTest*"
53./lite-test --gtest_filter="MatMulActivationFusionInoutTest*"
54./lite-test --gtest_filter="ActivationFusionInoutTest*"
55./lite-test --gtest_filter="TransMatMulFusionInoutTest*"
56# test cases of framework
57
58# test cases of FP32 OP
59./lite-test --gtest_filter=TestBatchnormFp32*
60./lite-test --gtest_filter=TestBatchToSpaceFp32*
61./lite-test --gtest_filter=TestConv1x1Fp32*
62./lite-test --gtest_filter=TestConvolutionFp32*
63./lite-test --gtest_filter=CropTestFp32*
64./lite-test --gtest_filter=TestDeConvolutionFp32*
65./lite-test --gtest_filter=DepthToSpaceTestFp32*
66./lite-test --gtest_filter=TestFcFp32*
67./lite-test --gtest_filter=TestLogicalOrFp32*
68./lite-test --gtest_filter=TestNLLLossFp32*
69./lite-test --gtest_filter=TestOneHotFp32*
70./lite-test --gtest_filter=TestPowerFp32*
71./lite-test --gtest_filter=TestReduceFp32*
72./lite-test --gtest_filter=TestRaggedRangeFp32*
73./lite-test --gtest_filter=TestScaleFp32*
74./lite-test --gtest_filter=TestTileFp32*
75
76# test cases of INT8 OP
77./lite-test --gtest_filter=TestBatchnormInt8.*
78./lite-test --gtest_filter=TestDeconvInt8.*
79./lite-test --gtest_filter=TestPadInt8.*
80
81# test cases of generic api
82./lite-test --gtest_filter="GenericApiTest*"
83
84if [ "$ENABLE_CONVERTER_TEST" = true ]; then
85  ./lite-test-converter --gtest_filter="ModelParserRegistryTest.TestRegistry"
86  ./lite-test-converter --gtest_filter="NodeParserRegistryTest.TestRegistry"
87  ./lite-test-converter --gtest_filter="PassRegistryTest.TestRegistry"
88  ./lite-test-converter --gtest_filter="TestConverterAPI.*"
89  ./lite-test-converter --gtest_filter="SpecifyGraphOutputFormatTest*"
90  ./lite-test-converter --gtest_filter="TestThirdPartyParamParser.*"
91fi
92./lite-test --gtest_filter="TestRegistry.TestAdd"
93./lite-test --gtest_filter="TestRegistryCustomOp.TestCustomAdd"
94
95if [ -f "$BUILD_DIR/src/libmindspore-lite-train.so" ]; then
96  echo 'run cxx_api ut tests'
97  ./lite-test --gtest_filter="TestCxxApiLiteModel*"
98  ./lite-test --gtest_filter="TestCxxApiLiteSerialization*"
99
100  echo 'run train ut tests'
101  ./lite-test --gtest_filter="TestActGradFp32*"
102  ./lite-test --gtest_filter="TestSoftmaxGradFp32*"
103  ./lite-test --gtest_filter="TestSoftmaxCrossEntropyFp32*"
104  ./lite-test --gtest_filter="TestBiasGradFp32*"
105  #./lite-test --gtest_filter="TestConvolutionGradFp32*"
106  #./lite-test --gtest_filter="TestDeConvolutionGradFp32*"
107fi
108
109echo 'run inference ut tests'
110./lite-test --gtest_filter="ControlFlowTest.TestMergeWhileModel"
111
112echo 'run mindrt parallel ut test'
113if [ "$ENABLE_CONVERTER_TEST" = true ]; then
114  ./lite-test-converter --gtest_filter="MindrtParallelTest.*"
115  echo 'user set output tensors st test'
116  ./lite-test --gtest_filter="GraphTest.UserSetGraphOutput*"
117fi
118./lite-test --gtest_filter="BenchmarkTest.mindrtParallelOffline*"
119
120echo 'run custom delegate st test'
121./lite-test --gtest_filter="DelegateTest.CustomDelegate"
122
123echo 'runtime pass'
124./lite-test --gtest_filter="RuntimePass.*"
125
126echo 'runtime convert'
127./lite-test --gtest_filter="RuntimeConvert.*"
128./lite-test --gtest_filter="BenchmarkTest.runtimeConvert1"
129
130echo 'Optimize Allocator'
131./lite-test --gtest_filter="OptAllocator.*"
132
133echo 'Runtime config file test'
134./lite-test --gtest_filter="MixDataTypeTest.Config1"
135
136echo 'run c api ut test'
137./lite-test --gtest_filter="TensorCTest.*"
138./lite-test --gtest_filter="ContextCTest.*"
139./lite-test --gtest_filter="ModelCApiTest.*"
140
141echo 'run bfc memory ut test'
142./lite-test --gtest_filter="DynamicMemManagerTest.*"
143
144mindspore_lite_whl=$(ls ${CUR_DIR}/../../../output/*.whl) || true
145if [[ -f "${mindspore_lite_whl}" || "$MSLITE_ENABLE_SERVER_INFERENCE" == on ]]; then
146  # prepare model and inputdata for Python-API ut test
147  if [ ! -e mobilenetv2.ms ]; then
148    if [[ -e "${SHARE_LITE_DATASET_PATH}/quick_start/mobilenetv2.ms" ]]; then
149        cp ${SHARE_LITE_DATASET_PATH}/quick_start/mobilenetv2.ms ./mobilenetv2.ms || exit 1
150    else
151        MODEL_DOWNLOAD_URL="https://download.mindspore.cn/model_zoo/official/lite/quick_start/mobilenetv2.ms"
152        wget -c -O mobilenetv2.ms --no-check-certificate ${MODEL_DOWNLOAD_URL}
153    fi
154  fi
155
156  if [ ! -e mobilenetv2.ms.bin ]; then
157    if [[ -e "${SHARE_LITE_DATASET_PATH}/quick_start/micro/mobilenetv2.tar.gz" ]]; then
158        cp ${SHARE_LITE_DATASET_PATH}/quick_start/micro/mobilenetv2.tar.gz ./mobilenetv2.tar.gz || exit 1
159    else
160        BIN_DOWNLOAD_URL="https://download.mindspore.cn/model_zoo/official/lite/quick_start/micro/mobilenetv2.tar.gz"
161        wget -c --no-check-certificate ${BIN_DOWNLOAD_URL}
162    fi
163    tar -zxf mobilenetv2.tar.gz
164    cp mobilenetv2/*.tflite ./mobilenetv2.tflite
165    cp mobilenetv2/*.ms.out ./mobilenetv2.ms.out
166    cp mobilenetv2/*.ms.bin ./mobilenetv2.ms.bin
167    rm -rf mobilenetv2.tar.gz mobilenetv2/
168  fi
169fi
170
171echo "lite Python API ut test"
172if [ ! -f "${mindspore_lite_whl}" ]; then
173  echo -e "\e[31mPython-API Whl not found, so lite Python API ut test will not be run. \e[0m"
174else
175  export PYTHONPATH=${CUR_DIR}/../build/package/:${PYTHONPATH}
176
177  # run converter Python-API ut test
178  if [[ ! "${MSLITE_ENABLE_CONVERTER}" || "${MSLITE_ENABLE_CONVERTER}" == "ON" || "${MSLITE_ENABLE_CONVERTER}" == "on" ]]; then
179    echo "run converter Python API ut test"
180    pytest ${CUR_DIR}/ut/python/test_converter_api.py -s
181    RET=$?
182    if [ ${RET} -ne 0 ]; then
183      exit ${RET}
184    fi
185  fi
186
187  # run inference Python-API ut test
188  echo "run inference Python API ut test"
189  pytest ${CUR_DIR}/ut/python/test_inference_api.py -s
190  RET=$?
191  if [ ${RET} -ne 0 ]; then
192    exit ${RET}
193  fi
194
195  # run LLMEngine Python-API ut test
196  echo "run LLMEngine Python API ut test"
197  pytest ${CUR_DIR}/ut/python/test_lite_llm_engine_api.py -s
198  RET=$?
199  if [ ${RET} -ne 0 ]; then
200    exit ${RET}
201  fi
202
203  # run inference CPU Python-API st test
204  echo "run inference CPU Python API st test"
205  pytest ${CUR_DIR}/st/python/test_inference.py::test_cpu_inference_01 -s
206  RET=$?
207  if [ ${RET} -ne 0 ]; then
208    exit ${RET}
209  fi
210fi
211
212if [ "$MSLITE_ENABLE_SERVER_INFERENCE" = on ]; then
213  echo 'run ModelParallelRunner api ut test'
214  ./lite-test --gtest_filter="ModelParallelRunnerTest.*"
215fi
216
217if [ "$MSLITE_ENABLE_KERNEL_EXECUTOR" = on ]; then
218  echo 'run kernel executor api ut test'
219  ./lite-test --gtest_filter="KernelExecutorTest.*"
220fi
221