Skip to content

Commit

Permalink
Add another c++ simple example (Updated) (#90)
Browse files Browse the repository at this point in the history
* Update test

* use cmake options
  • Loading branch information
chilo-ms authored Mar 14, 2022
1 parent 3b10c75 commit 63d461a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
8 changes: 5 additions & 3 deletions c_cxx/squeezenet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ project(capi_test)

set(CMAKE_BUILD_TYPE Debug)

cmake_minimum_required (VERSION 2.6)
cmake_minimum_required(VERSION 3.13)

option(ONNXRUNTIME_ROOTDIR "onnxruntime root dir")

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include_directories(
${PROJECT_SOURCE_DIR}/../../include/onnxruntime/core/session/
${PROJECT_SOURCE_DIR}/../../include/onnxruntime/core/providers/tensorrt/
${ONNXRUNTIME_ROOTDIR}/include/onnxruntime/core/session/
${ONNXRUNTIME_ROOTDIR}/include/onnxruntime/core/providers/tensorrt/
)

ADD_EXECUTABLE(capi_test main.cpp)
Expand Down
7 changes: 4 additions & 3 deletions c_cxx/squeezenet/run_capi_application.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
set ONNX_MODEL_URL="https://media.githubusercontent.com/media/onnx/models/main/vision/classification/squeezenet/model/squeezenet1.0-7.onnx"
set ONNX_MODEL="squeezenet.onnx"
SET ORT_PACKAGE=%1
SET WORKSPACE=%2
SET ONNXRUNTIME_ROOTDIR=%1
SET ORT_PACKAGE=%2
SET WORKSPACE=%3

echo The current directory is %CD%

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

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

REM Copy ORT libraries to same folder for linker to build.
REM For some reasons, setting "LINK" or "LIBPATH" env variables won't help.
Expand Down
7 changes: 3 additions & 4 deletions c_cxx/squeezenet/run_capi_application.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash
set -x

while getopts w:p: parameter
while getopts o:w:p: parameter
do case "${parameter}"
in
o) ONNXRUNTIME_ROOTDIR=${OPTARG};;
p) ORT_PACKAGE=${OPTARG};;
w) WORKSPACE=${OPTARG};;
esac
done

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

Expand All @@ -27,9 +27,8 @@ cd ${WORKSPACE}
mkdir -p build
cd build

cmake ..
cmake .. -DONNXRUNTIME_ROOTDIR=${ONNXRUNTIME_ROOTDIR}
make -j4
#wget ${ONNX_MODEL_URL} -O ${ONNX_MODEL}
curl ${ONNX_MODEL_URL} --output ${ONNX_MODEL}
./capi_test

Expand Down

0 comments on commit 63d461a

Please sign in to comment.