Welcome to pay attention to my public account [极智视界], reply 001 to get Google programming specifications
O_o
>_<
o_O
O_o
~_~
o_O
This tutorial details the method of using cmake to quickly build a Tengine vs project in the win10 environment.
I wrote an article " [Experience Sharing] Win10 qmake build ncnn vs project ", introduced the method of using nmake and qmake to build ncnn vs project on win10, here we use cmake to walk through the construction of Tengine vs project. As you all know, ncnn and Tengine are both very popular deep learning inference frameworks in low computing power scenarios, while cmake should be the most used cross-platform compilation tool in open source projects, and qmake is a minority. Combining these articles, you will find that when you have a ncnn in your left hand, a Tengine in your right hand, a cmake in your left hand, and a qmake in your right hand, no matter whether the environment you are facing is windows or linux, no matter if your deployment target platform is embedded It's easy to use for mobile phones or mobile phones.
Come on。
1. Prepare Tengine source code
Just clone the Tengine project code directly:
git clone https://github.com/OAID/Tengine.git
The project structure is clear. Needless to say, like benchmarks, examples, and tests, you can know what it is used for at a glance. Speaking of tools, you can see that tools provide some useful tools. In the past, these tools, such as model conversion tool convert_tool, were separate git projects. Now they are all integrated into the Tengine project, which will be more user-friendly. I just said that convert_tool is a model conversion tool. For example, optimize is a model optimization tool, and quantize is a model quantization tool. Currently, four quantization algorithms are provided: min-max, kl, eq, dfq. The quantization modes include symmetric quantization and asymmetric quantization. , Channel-by-channel quantization, the coverage of the scene is still very comprehensive, like it.
2. Prepare cmake bat
First of all, use vs studio 2019, remember.
Organize three bats:
- env.bat: used for environment configuration;
- vs_create_project.bat: create a vs project;
- run_project.bat: run vs project;
Take a look at the specific content of the three bats.
env.bat:
SET WATCH_VC_DIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build
vs_create_project.bat:
@echo off
call :prepare_env
call :build_vs
goto :EOF
:prepare_env
echo "call env.bat if exist"
if exist env.bat (call env.bat)
goto :EOF
:build_vs
if defined WATCH_VC_DIR (
echo "has WATCH_VC_DIR in env.bat"
) else (
echo "please set the 1 env variables: WATCH_VC_DIR in env.bat, and retry again."
pause
exit
)
call "%WATCH_VC_DIR%\vcvarsall.bat" x64
if exist build (echo "build folder exist.") else (md build)
cd build
cmake -G "Visual Studio 16 2019" -A x64 ..
cd ../
pause
exit
run_project.bat:
set SLN=.\build\tengine-lite.sln
set VC_DIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build
call "%VC_DIR%\vcvars64.bat" x64
set OPENCV_PATH=.\third_party\opencv\x64\vc15\bin
SET "PATH=%OPENCV_PATH%;%PATH%"
start devenv.exe %SLN%
3. Build the Tengine project
Put the three bats mentioned above into the <Tengine_path> directory. Since the above preparations have been made, the process of building the Tengine project will become very easy.
Take a look at the CmakeList.txt that you just got. The building of many modules is turned off by default. If you want to compile some modules, you can turn on the corresponding switch, just like I opened the CONVERT_TOOL and QUANT_TOOL modules here. as follows:
Then start to compile happily, just move the mouse and double-click, the execution sequence is: env.bat -> vs_create_project.bat -> run_project.bat, and the vs2019 project is automatically opened when it is over, like this:
Then execute the compilation:
To prove that I am not talking nonsense, let me run bentchmark:
The above shared the method of using cmake to build the Tengine project in the win10 environment, I hope my sharing can be a little helpful to your study.
【Public Account Transmission】
" [Experience Sharing] Win10 cmake to build Tengine project "
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。