Skip to content

Commit

Permalink
First commit for directly onnx reading, at least it compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
daquexian committed May 13, 2019
1 parent 3191182 commit 3ec2638
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .daq_pm/configs/onnx_infer
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name DNNLibrary
type cpp
target dnn_retrieve_result
build_dir build_onnxinfer
cmake_options -DCMAKE_SYSTEM_NAME=Android -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_CPP_FEATURES=exceptions -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DDNN_READ_ONNX=ON -DONNX_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc
program_arguments ~/adb_push_and_run.sh binaries/dnn_retrieve_result
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ project(DNNLibrary)

option(DNN_BUILD_BIN "Build binaries" ON)
option(DNN_BUILD_JNI "Build Java Wrapper" OFF)
option(DNN_READ_ONNX "Read ONNX model directly instead of converting to .daq" ON)
option(DNN_SYSTEM_PROTOBUF "Use system protobuf when building onnx2daq" OFF)

include(cmake/system.cmake)
Expand All @@ -14,7 +15,13 @@ configure_glog()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Android")
set (CMAKE_CXX_STANDARD 17)

add_compile_options(-Os -fno-rtti)
add_compile_options(-Os)
if (${DNN_READ_ONNX} AND NOT TARGET onnx)
include(cmake/onnx.cmake)
configure_onnx()
else()
add_compile_options(-fno-rtti)
endif()
add_subdirectory(dnnlibrary)
add_subdirectory(binaries)
else()
Expand Down
19 changes: 18 additions & 1 deletion dnnlibrary/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dnn_protobuf_generate_cpp(ONNX_SRCS ONNX_HDRS onnx.proto3)

add_library(dnnlibrary
set(dnnlibrary_src
include/ModelBuilder.h
include/Model.h
include/DaqReader.h
Expand All @@ -14,6 +14,15 @@ add_library(dnnlibrary
${PROJECT_SOURCE_DIR}/common/Shaper.cpp
${PROJECT_SOURCE_DIR}/common/StrKeyMap.h
)
if (DNN_READ_ONNX)
list(APPEND dnnlibrary_src
src/OnnxReader.cpp
src/OnnxReader.h)
endif()

add_library(dnnlibrary
${dnnlibrary_src}
)

target_include_directories(
dnnlibrary
Expand Down Expand Up @@ -48,6 +57,14 @@ target_link_libraries(
${neural-networks-lib}
)

if (DNN_READ_ONNX)
target_link_libraries(
dnnlibrary
onnx
)
endif()


treat_warnings_as_errors(dnnlibrary)

if (DNN_BUILD_JNI)
Expand Down
3 changes: 3 additions & 0 deletions dnnlibrary/src/OnnxReader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "OnnxReader.h"


1 change: 1 addition & 0 deletions dnnlibrary/src/OnnxReader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <onnx/onnx_pb.h>

0 comments on commit 3ec2638

Please sign in to comment.