Skip to content

Add another c++ simple example (Updated) #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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