-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
136 lines (116 loc) · 4.28 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
cmake_minimum_required(VERSION 3.18.1)
# Declares and names the project.
project("onnxinfer")
set(ONNX_LIB_DIR . )
message("current dir: " + ${CMAKE_CURRENT_SOURCE_DIR})
# set protobufers
set(SPM_PROTO_HDRS sp/pb/sentencepiece.pb.h)
set(SPM_PROTO_SRCS sp/pb/sentencepiece.pb.cc)
set(SPM_MODEL_PROTO_HDRS sp/pb/sentencepiece_model.pb.h)
set(SPM_MODEL_PROTO_SRCS sp/pb/sentencepiece_model.pb.cc)
set(PROTOBUF_LITE_LIBRARY "")
set(PROTOBUF_LITE_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/arena.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/arenastring.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/bytestream.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/coded_stream.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/common.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/extension_set.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/generated_enum_util.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/generated_message_table_driven_lite.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/generated_message_util.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/implicit_weak_message.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/int128.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/io_win32.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/message_lite.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/parse_context.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/repeated_field.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/status.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/statusor.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/stringpiece.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/stringprintf.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/structurally_valid.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/strutil.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/time.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/wire_format_lite.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/zero_copy_stream.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/zero_copy_stream_impl.cc
${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite/zero_copy_stream_impl_lite.cc)
set(ABSL_FLAGS_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/absl/flags/flag.cc)
# set sentencepiece
set(SPM_SRCS
${PROTOBUF_LITE_SRCS}
${SPM_PROTO_HDRS}
${SPM_PROTO_SRCS}
${SPM_MODEL_PROTO_HDRS}
${SPM_MODEL_PROTO_SRCS}
${ABSL_FLAGS_SRCS}
sp/bpe_model.h
sp/common.h
sp/normalizer.h
sp/freelist.h
sp/filesystem.h
sp/init.h
sp/util.h
sp/sentencepiece_processor.h
sp/model_factory.h
sp/model_interface.h
sp/error.cc
sp/bpe_model.cc
sp/model_factory.cc
sp/model_interface.cc
sp/normalizer.cc
sp/filesystem.cc
sp/sentencepiece_processor.cc
sp/util.cc
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party/protobuf-lite)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/sp/third_party) #absl
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/sp/pb)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/sp)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/gen)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ort)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wav)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)
find_package(OpenMP REQUIRED)
add_compile_options(
# -DDEBUG_STFT
# -DDEBUG_FEAT
# -DDEBUG_WAV
# -DDEBUG_INF
-pthread #protobuf
-DHAVE_PTHREAD=1 #protobuf
-mfma #neon
-mavx2 #neon
-fno-permissive
-Wno-deprecated-declarations
-std=c++17
-O3
-Wall
-fPIC
-Ofast
# -march=znver3
-march=native
)
add_executable( # Sets the name of the library.
onnxinfer
${SPM_SRCS}
# Provides a relative path to your source file(s).
wav/wavread.cpp
stfft.cpp
feat.cpp
beam_search.cpp
input_processing.cpp
rnnt_attrs.cpp
onnx_inference.cpp)
set(ONNXRUNTIME_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libonnxruntime.so)
target_compile_options(onnxinfer PRIVATE "${OpenMP_CXX_FLAGS}")
target_compile_definitions(onnxinfer
PRIVATE
${ORR_DEFINITIONS})
target_link_libraries(
onnxinfer
PRIVATE
${ONNXRUNTIME_PATH}
${OpenMP_CXX_FLAGS}
)