Skip to content

Commit 63d461a

Browse files
authored
Add another c++ simple example (Updated) (#90)
* Update test * use cmake options
1 parent 3b10c75 commit 63d461a

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

c_cxx/squeezenet/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ project(capi_test)
22

33
set(CMAKE_BUILD_TYPE Debug)
44

5-
cmake_minimum_required (VERSION 2.6)
5+
cmake_minimum_required(VERSION 3.13)
6+
7+
option(ONNXRUNTIME_ROOTDIR "onnxruntime root dir")
68

79
set(CMAKE_CXX_STANDARD 14)
810
set(CMAKE_CXX_STANDARD_REQUIRED ON)
911

1012
include_directories(
11-
${PROJECT_SOURCE_DIR}/../../include/onnxruntime/core/session/
12-
${PROJECT_SOURCE_DIR}/../../include/onnxruntime/core/providers/tensorrt/
13+
${ONNXRUNTIME_ROOTDIR}/include/onnxruntime/core/session/
14+
${ONNXRUNTIME_ROOTDIR}/include/onnxruntime/core/providers/tensorrt/
1315
)
1416

1517
ADD_EXECUTABLE(capi_test main.cpp)

c_cxx/squeezenet/run_capi_application.bat

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
set ONNX_MODEL_URL="https://media.githubusercontent.com/media/onnx/models/main/vision/classification/squeezenet/model/squeezenet1.0-7.onnx"
22
set ONNX_MODEL="squeezenet.onnx"
3-
SET ORT_PACKAGE=%1
4-
SET WORKSPACE=%2
3+
SET ONNXRUNTIME_ROOTDIR=%1
4+
SET ORT_PACKAGE=%2
5+
SET WORKSPACE=%3
56

67
echo The current directory is %CD%
78

@@ -10,7 +11,7 @@ set ORT_LIB=%ORT_PACKAGE:~0,-4%\lib
1011
echo %ORT_LIB%
1112

1213
cd %WORKSPACE%
13-
cmake.exe -S . -B build\ -G "Visual Studio 16 2019"
14+
cmake.exe -S . -B build\ -G "Visual Studio 16 2019" -DONNXRUNTIME_ROOTDIR=%ONNXRUNTIME_ROOTDIR%
1415

1516
REM Copy ORT libraries to same folder for linker to build.
1617
REM For some reasons, setting "LINK" or "LIBPATH" env variables won't help.

c_cxx/squeezenet/run_capi_application.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/bin/bash
22
set -x
33

4-
while getopts w:p: parameter
4+
while getopts o:w:p: parameter
55
do case "${parameter}"
66
in
7+
o) ONNXRUNTIME_ROOTDIR=${OPTARG};;
78
p) ORT_PACKAGE=${OPTARG};;
89
w) WORKSPACE=${OPTARG};;
910
esac
1011
done
1112

12-
#ONNX_MODEL_URL="https://github.com/onnx/models/raw/main/vision/classification/squeezenet/model/squeezenet1.0-7.onnx"
1313
ONNX_MODEL_URL="https://media.githubusercontent.com/media/onnx/models/main/vision/classification/squeezenet/model/squeezenet1.0-7.onnx"
1414
ONNX_MODEL="squeezenet.onnx"
1515

@@ -27,9 +27,8 @@ cd ${WORKSPACE}
2727
mkdir -p build
2828
cd build
2929

30-
cmake ..
30+
cmake .. -DONNXRUNTIME_ROOTDIR=${ONNXRUNTIME_ROOTDIR}
3131
make -j4
32-
#wget ${ONNX_MODEL_URL} -O ${ONNX_MODEL}
3332
curl ${ONNX_MODEL_URL} --output ${ONNX_MODEL}
3433
./capi_test
3534

0 commit comments

Comments
 (0)