|
|
|
@@ -16,57 +16,34 @@ |
|
|
|
@title win_run_test |
|
|
|
setlocal enabledelayedexpansion |
|
|
|
|
|
|
|
SET BASEPATH=%CD% |
|
|
|
SET OUTPUT_PATH=%BASEPATH%\output |
|
|
|
SET TOOL_PATH=%1 |
|
|
|
SET TOOL_PATH=%TOOL_PATH:"=%\windows_x64 |
|
|
|
SET PACKAGE_PATH=%1 |
|
|
|
SET MODEL_PATH_BASE=%2 |
|
|
|
SET MODEL_PATH=%MODEL_PATH_BASE:"=%\models\hiai |
|
|
|
SET BENCHMARK_BASE=%BASEPATH:"=%\output\benchmark |
|
|
|
SET MODEL_CONFIG=%BASEPATH%\win_models.cfg |
|
|
|
|
|
|
|
for /f "tokens=3 delims=-" %%i in ('dir /b %TOOL_PATH%\mindspore-lite-*-inference-win-x64.zip') do set VERSION=%%i |
|
|
|
|
|
|
|
cd /d %BASEPATH% |
|
|
|
IF EXIST "%BASEPATH%/output" ( |
|
|
|
rd /s /q output |
|
|
|
) |
|
|
|
md output |
|
|
|
cd /d %OUTPUT_PATH% |
|
|
|
IF EXIST benchmark ( |
|
|
|
rd /s /q benchmark |
|
|
|
) |
|
|
|
md benchmark |
|
|
|
SET INSTRUCTION=%3 |
|
|
|
|
|
|
|
SET BASEPATH=%CD% |
|
|
|
SET RET_CODE=0 |
|
|
|
|
|
|
|
SET SO_PATH=mindspore-lite-%VERSION%-inference-win-x64 |
|
|
|
IF "%3%" == "sse" ( |
|
|
|
SET SO_PATH=mindspore-lite-%VERSION%-inference-win-x64-sse |
|
|
|
) |
|
|
|
IF "%3%" == "avx" ( |
|
|
|
SET SO_PATH=mindspore-lite-%VERSION%-inference-win-x64-avx |
|
|
|
) |
|
|
|
IF "%3%" == "avx512" ( |
|
|
|
SET SO_PATH=mindspore-lite-%VERSION%-inference-win-x64-avx512 |
|
|
|
) |
|
|
|
7z x -r "%TOOL_PATH%/%SO_PATH%.zip" -o"%BENCHMARK_BASE%" |
|
|
|
SET PACKAGE_PATH=%PACKAGE_PATH:"=%\windows_x64\%INSTRUCTION% |
|
|
|
7z x -r "%PACKAGE_PATH%\mindspore-lite-*.zip" |
|
|
|
IF NOT %errorlevel% == 0 ( |
|
|
|
echo "Decompression of runtime tool fail!" |
|
|
|
SET RET_CODE=1 |
|
|
|
goto run_eof |
|
|
|
) |
|
|
|
|
|
|
|
cd benchmark |
|
|
|
md ms |
|
|
|
for /f %%i in ('dir /b %PACKAGE_PATH%\mindspore-lite-*.zip') do set PACKAGE_NAME=%%i |
|
|
|
set PACKAGE_NAME=%PACKAGE_NAME:.zip=% |
|
|
|
SET DST_PACKAGE_PATH=%BASEPATH%\%PACKAGE_NAME% |
|
|
|
|
|
|
|
echo "Convert models" |
|
|
|
copy %DST_PACKAGE_PATH%\tools\converter\lib\* %DST_PACKAGE_PATH%\tools\converter\converter\ |
|
|
|
cd /d %DST_PACKAGE_PATH%\tools\converter\converter\ |
|
|
|
|
|
|
|
SET TYPE_ID='' |
|
|
|
SET MODEL_NAME='' |
|
|
|
SET SUFFIX='' |
|
|
|
|
|
|
|
echo "Convert models" |
|
|
|
copy %BENCHMARK_BASE%\%SO_PATH%\tools\converter\lib\* %BENCHMARK_BASE%\%SO_PATH%\tools\converter\converter\ |
|
|
|
cd /d %BENCHMARK_BASE%\%SO_PATH%\tools\converter\converter\ |
|
|
|
SET MODEL_CONFIG=%BASEPATH%\win_models.cfg |
|
|
|
SET MODEL_PATH=%MODEL_PATH_BASE:"=%\models\hiai |
|
|
|
|
|
|
|
for /f "tokens=1-2 delims= " %%i in (%MODEL_CONFIG%) do ( |
|
|
|
for /f "tokens=1-2 delims=." %%k in ("%%j") do ( |
|
|
|
@@ -74,15 +51,14 @@ for /f "tokens=1-2 delims= " %%i in (%MODEL_CONFIG%) do ( |
|
|
|
SET MODEL_NAME=%%k |
|
|
|
SET SUFFIX=%%l |
|
|
|
) |
|
|
|
|
|
|
|
if !TYPE_ID!==1 (converter_lite --fmk=MINDIR --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!") |
|
|
|
if !TYPE_ID!==2 (converter_lite --fmk=MINDIR --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!_train" --trainModel=true) |
|
|
|
if !TYPE_ID!==3 (converter_lite --fmk=CAFFE --modelFile="%MODEL_PATH%/!MODEL_NAME!.prototxt" --weightFile="%MODEL_PATH%/!MODEL_NAME!.caffemodel" --outputFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!") |
|
|
|
if !TYPE_ID!==4 (converter_lite --fmk=ONNX --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!") |
|
|
|
if !TYPE_ID!==5 (converter_lite --fmk=TFLITE --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!") |
|
|
|
if !TYPE_ID!==6 (converter_lite --fmk=TFLITE --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!" --quantType=AwareTraining) |
|
|
|
if !TYPE_ID!==7 (converter_lite --fmk=TFLITE --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!_posttraining" --quantType=PostTraining --configFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!_posttraining.config") |
|
|
|
if !TYPE_ID!==8 (converter_lite --fmk=TFLITE --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!_weightquant" --quantType=WeightQuant --bitNum=8 --quantWeightSize=500 --quantWeightChannel=16) |
|
|
|
if !TYPE_ID!==1 (converter_lite --fmk=MINDIR --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!") |
|
|
|
if !TYPE_ID!==2 (converter_lite --fmk=MINDIR --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!_train" --trainModel=true) |
|
|
|
if !TYPE_ID!==3 (converter_lite --fmk=CAFFE --modelFile="%MODEL_PATH%/!MODEL_NAME!.prototxt" --weightFile="%MODEL_PATH%/!MODEL_NAME!.caffemodel" --outputFile="%DST_PACKAGE_PATH%\!MODEL_NAME!") |
|
|
|
if !TYPE_ID!==4 (converter_lite --fmk=ONNX --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!") |
|
|
|
if !TYPE_ID!==5 (converter_lite --fmk=TFLITE --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!") |
|
|
|
if !TYPE_ID!==6 (converter_lite --fmk=TFLITE --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!" --quantType=AwareTraining) |
|
|
|
if !TYPE_ID!==7 (converter_lite --fmk=TFLITE --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!_posttraining" --quantType=PostTraining --configFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!_posttraining.config") |
|
|
|
if !TYPE_ID!==8 (converter_lite --fmk=TFLITE --modelFile="%MODEL_PATH%/!MODEL_NAME!.!SUFFIX!" --outputFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!_weightquant" --quantType=WeightQuant --bitNum=8 --quantWeightSize=500 --quantWeightChannel=16) |
|
|
|
|
|
|
|
IF !errorlevel! == 0 ( |
|
|
|
echo "Run converter for model (TYPE_ID=!TYPE_ID!) !MODEL_NAME!.!SUFFIX! : pass!" |
|
|
|
@@ -94,8 +70,9 @@ for /f "tokens=1-2 delims= " %%i in (%MODEL_CONFIG%) do ( |
|
|
|
) |
|
|
|
|
|
|
|
echo "Run converted models" |
|
|
|
copy %BENCHMARK_BASE%\%SO_PATH%\inference\lib\* %BENCHMARK_BASE%\%SO_PATH%\tools\benchmark\ |
|
|
|
cd /d %BENCHMARK_BASE%\%SO_PATH%\tools\benchmark\ |
|
|
|
copy %DST_PACKAGE_PATH%\inference\lib\* %DST_PACKAGE_PATH%\tools\benchmark\ |
|
|
|
cd /d %DST_PACKAGE_PATH%\tools\benchmark\ |
|
|
|
|
|
|
|
SET INPUT_BASE=%MODEL_PATH%/input_output/input |
|
|
|
SET OUTPUT_BASE=%MODEL_PATH%/input_output/output |
|
|
|
|
|
|
|
@@ -105,15 +82,14 @@ for /f "tokens=1-2 delims= " %%i in (%MODEL_CONFIG%) do ( |
|
|
|
SET MODEL_NAME=%%k |
|
|
|
SET SUFFIX=%%l |
|
|
|
) |
|
|
|
|
|
|
|
if !TYPE_ID!==1 (benchmark --modelFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.out" --accuracyThreshold=1.5) |
|
|
|
if !TYPE_ID!==2 (benchmark --modelFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!_train.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.out" --accuracyThreshold=1.5) |
|
|
|
if !TYPE_ID!==3 (benchmark --modelFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.ms.out") |
|
|
|
if !TYPE_ID!==4 (benchmark --modelFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.out") |
|
|
|
if !TYPE_ID!==5 (benchmark --modelFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.out") |
|
|
|
if !TYPE_ID!==6 (benchmark --modelFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.out") |
|
|
|
if !TYPE_ID!==7 (benchmark --modelFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!_posttraining.ms" --inDataFile="%MODEL_PATH_BASE%/quantTraining/mnist_calibration_data/00099.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!_posttraining.ms.out") |
|
|
|
if !TYPE_ID!==8 (benchmark --modelFile="%BENCHMARK_BASE%/ms/!MODEL_NAME!.!SUFFIX!_weightquant.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.out") |
|
|
|
if !TYPE_ID!==1 (benchmark --modelFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.out" --accuracyThreshold=1.5) |
|
|
|
if !TYPE_ID!==2 (benchmark --modelFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!_train.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.out" --accuracyThreshold=1.5) |
|
|
|
if !TYPE_ID!==3 (benchmark --modelFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.ms.out") |
|
|
|
if !TYPE_ID!==4 (benchmark --modelFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.out") |
|
|
|
if !TYPE_ID!==5 (benchmark --modelFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.out") |
|
|
|
if !TYPE_ID!==6 (benchmark --modelFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.out") |
|
|
|
if !TYPE_ID!==7 (benchmark --modelFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!_posttraining.ms" --inDataFile="%MODEL_PATH_BASE%/quantTraining/mnist_calibration_data/00099.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!_posttraining.ms.out") |
|
|
|
if !TYPE_ID!==8 (benchmark --modelFile="%DST_PACKAGE_PATH%\!MODEL_NAME!.!SUFFIX!_weightquant.ms" --inDataFile="%INPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.bin" --benchmarkDataFile="%OUTPUT_BASE%/!MODEL_NAME!.!SUFFIX!.ms.out") |
|
|
|
|
|
|
|
IF !errorlevel! == 0 ( |
|
|
|
echo "Run benchmark for model (TYPE_ID=!TYPE_ID!) !MODEL_NAME!.!SUFFIX! : pass!" |
|
|
|
@@ -126,6 +102,7 @@ for /f "tokens=1-2 delims= " %%i in (%MODEL_CONFIG%) do ( |
|
|
|
|
|
|
|
:run_eof |
|
|
|
cd /d %BASEPATH% |
|
|
|
rd /s /q %PACKAGE_NAME% |
|
|
|
IF %RET_CODE% == 0 ( |
|
|
|
SET errorlevel=0 |
|
|
|
echo "Run models in Windows success!" |
|
|
|
|