Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
591b957b
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 2 年 前同步成功
通知
210
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
591b957b
编写于
3月 30, 2023
作者:
Mars懵
提交者:
GitHub
3月 30, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[runtime] fix linux && android cmake bug (#3112)
* support vad ios compile * support onnx model recognize * add build ios sh
上级
9e5a39ca
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
49 addition
and
38 deletion
+49
-38
runtime/CMakeLists.txt
runtime/CMakeLists.txt
+5
-2
runtime/build.sh
runtime/build.sh
+5
-1
runtime/build_android.sh
runtime/build_android.sh
+2
-2
runtime/cmake/glog.cmake
runtime/cmake/glog.cmake
+1
-1
runtime/engine/asr/nnet/u2_nnet.cc
runtime/engine/asr/nnet/u2_nnet.cc
+11
-11
runtime/engine/cls/nnet/CMakeLists.txt
runtime/engine/cls/nnet/CMakeLists.txt
+1
-1
runtime/engine/cls/nnet/panns_nnet.cc
runtime/engine/cls/nnet/panns_nnet.cc
+11
-12
runtime/engine/cls/nnet/panns_nnet_main.cc
runtime/engine/cls/nnet/panns_nnet_main.cc
+2
-2
runtime/engine/common/base/log_impl.h
runtime/engine/common/base/log_impl.h
+3
-3
runtime/engine/common/frontend/CMakeLists.txt
runtime/engine/common/frontend/CMakeLists.txt
+1
-0
runtime/engine/kaldi/base/kaldi-error.h
runtime/engine/kaldi/base/kaldi-error.h
+1
-1
runtime/engine/vad/interface/CMakeLists.txt
runtime/engine/vad/interface/CMakeLists.txt
+1
-1
runtime/engine/vad/nnet/CMakeLists.txt
runtime/engine/vad/nnet/CMakeLists.txt
+5
-1
未找到文件。
runtime/CMakeLists.txt
浏览文件 @
591b957b
...
...
@@ -60,7 +60,10 @@ set(FETCHCONTENT_BASE_DIR ${fc_patch})
###############################################################################
# https://github.com/google/brotli/pull/655
option
(
BUILD_SHARED_LIBS
"Build shared libraries"
ON
)
option
(
NDEBUG
"debug option"
OFF
)
option
(
WITH_PPS_DEBUG
"debug option"
OFF
)
if
(
WITH_PPS_DEBUG
)
add_definitions
(
"-DPPS_DEBUG"
)
endif
()
option
(
WITH_ASR
"build asr"
ON
)
option
(
WITH_CLS
"build cls"
ON
)
...
...
@@ -71,7 +74,7 @@ option(WITH_GPU "NNet using GPU." OFF)
option
(
WITH_PROFILING
"enable c++ profling"
OFF
)
option
(
WITH_TESTING
"unit test"
ON
)
option
(
WITH_ONNX
"u2 support onnx runtime"
O
N
)
option
(
WITH_ONNX
"u2 support onnx runtime"
O
FF
)
###############################################################################
# Include Third Party
...
...
runtime/build.sh
浏览文件 @
591b957b
...
...
@@ -9,9 +9,11 @@ mkdir -p ${BUILD_DIR}
BUILD_TYPE
=
Release
#BUILD_TYPE=Debug
BUILD_SO
=
OFF
BUILD_ONNX
=
ON
BUILD_ASR
=
ON
BUILD_CLS
=
ON
BUILD_VAD
=
ON
PPS_DEBUG
=
OFF
FASTDEPLOY_INSTALL_DIR
=
""
# the build script had verified in the paddlepaddle docker image.
...
...
@@ -21,9 +23,11 @@ FASTDEPLOY_INSTALL_DIR=""
cmake
-B
${
BUILD_DIR
}
\
-DCMAKE_BUILD_TYPE
=
${
BUILD_TYPE
}
\
-DBUILD_SHARED_LIBS
=
${
BUILD_SO
}
\
-DWITH_ONNX
=
${
BUILD_ONNX
}
\
-DWITH_ASR
=
${
BUILD_ASR
}
\
-DWITH_CLS
=
${
BUILD_CLS
}
\
-DWITH_VAD
=
${
BUILD_VAD
}
\
-DFASTDEPLOY_INSTALL_DIR
=
${
FASTDEPLOY_INSTALL_DIR
}
-DFASTDEPLOY_INSTALL_DIR
=
${
FASTDEPLOY_INSTALL_DIR
}
\
-DWITH_PPS_DEBUG
=
${
PPS_DEBUG
}
cmake
--build
${
BUILD_DIR
}
-j
runtime/build_android.sh
浏览文件 @
591b957b
...
...
@@ -2,7 +2,7 @@
set
-ex
ANDROID_NDK
=
/
workspace/zhanghui/android-sdk/android-ndk-r25c
ANDROID_NDK
=
/
mnt/masimeng/workspace/software/android-ndk-r25b/
# Setting up Android toolchanin
ANDROID_ABI
=
arm64-v8a
# 'arm64-v8a', 'armeabi-v7a'
...
...
@@ -14,7 +14,7 @@ TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake
# Create build directory
BUILD_ROOT
=
build/Android
BUILD_DIR
=
${
BUILD_ROOT
}
/
${
ANDROID_ABI
}
-api-21
FASTDEPLOY_INSTALL_DIR
=
"/
workspace/zhanghui/paddl
e/FastDeploy/build/Android/arm64-v8a-api-21/install"
FASTDEPLOY_INSTALL_DIR
=
"/
mnt/masimeng/workspac
e/FastDeploy/build/Android/arm64-v8a-api-21/install"
mkdir
-p
${
BUILD_DIR
}
cd
${
BUILD_DIR
}
...
...
runtime/cmake/glog.cmake
浏览文件 @
591b957b
...
...
@@ -28,7 +28,7 @@ endif()
if
(
ANDROID
)
add_library
(
extern_glog INTERFACE
)
add_dependencies
(
glog gflags
)
add_dependencies
(
extern_
glog gflags
)
else
()
# UNIX
add_library
(
extern_glog ALIAS glog
)
add_dependencies
(
glog gflags
)
...
...
runtime/engine/asr/nnet/u2_nnet.cc
浏览文件 @
591b957b
...
...
@@ -223,7 +223,7 @@ void U2Nnet::ForwardEncoderChunkImpl(
VLOG
(
3
)
<<
"feats shape: "
<<
feats
.
shape
()[
0
]
<<
", "
<<
feats
.
shape
()[
1
]
<<
", "
<<
feats
.
shape
()[
2
];
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
stringstream
path
(
"feat"
,
std
::
ios_base
::
app
|
std
::
ios_base
::
out
);
path
<<
offset_
;
...
...
@@ -269,7 +269,7 @@ void U2Nnet::ForwardEncoderChunkImpl(
cnn_cache_
=
outputs
[
2
];
#endif
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
stringstream
path
(
"encoder_logits"
,
std
::
ios_base
::
app
|
std
::
ios_base
::
out
);
...
...
@@ -299,7 +299,7 @@ void U2Nnet::ForwardEncoderChunkImpl(
encoder_outs_
.
push_back
(
chunk_out
);
VLOG
(
2
)
<<
"encoder_outs_ size: "
<<
encoder_outs_
.
size
();
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
stringstream
path
(
"encoder_logits_list"
,
std
::
ios_base
::
app
|
std
::
ios_base
::
out
);
...
...
@@ -332,7 +332,7 @@ void U2Nnet::ForwardEncoderChunkImpl(
CHECK_EQ
(
outputs
.
size
(),
1
);
paddle
::
Tensor
ctc_log_probs
=
outputs
[
0
];
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
stringstream
path
(
"encoder_logprob"
,
std
::
ios_base
::
app
|
std
::
ios_base
::
out
);
...
...
@@ -371,7 +371,7 @@ void U2Nnet::ForwardEncoderChunkImpl(
std
::
memcpy
(
out_prob
->
data
(),
ctc_log_probs_ptr
,
T
*
D
*
sizeof
(
kaldi
::
BaseFloat
));
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
stringstream
path
(
"encoder_logits_list_ctc"
,
std
::
ios_base
::
app
|
std
::
ios_base
::
out
);
...
...
@@ -462,7 +462,7 @@ void U2Nnet::AttentionRescoring(const std::vector<std::vector<int>>& hyps,
}
}
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
stringstream
path
(
"encoder_logits_concat"
,
std
::
ios_base
::
app
|
std
::
ios_base
::
out
);
...
...
@@ -486,7 +486,7 @@ void U2Nnet::AttentionRescoring(const std::vector<std::vector<int>>& hyps,
paddle
::
Tensor
encoder_out
=
paddle
::
concat
(
encoder_outs_
,
1
);
VLOG
(
2
)
<<
"encoder_outs_ size: "
<<
encoder_outs_
.
size
();
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
stringstream
path
(
"encoder_out0"
,
std
::
ios_base
::
app
|
std
::
ios_base
::
out
);
...
...
@@ -505,7 +505,7 @@ void U2Nnet::AttentionRescoring(const std::vector<std::vector<int>>& hyps,
}
#endif // end TEST_DEBUG
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
stringstream
path
(
"encoder_out"
,
std
::
ios_base
::
app
|
std
::
ios_base
::
out
);
...
...
@@ -536,7 +536,7 @@ void U2Nnet::AttentionRescoring(const std::vector<std::vector<int>>& hyps,
CHECK_EQ
(
probs_shape
[
0
],
num_hyps
);
CHECK_EQ
(
probs_shape
[
1
],
max_hyps_len
);
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
stringstream
path
(
"decoder_logprob"
,
std
::
ios_base
::
app
|
std
::
ios_base
::
out
);
...
...
@@ -554,7 +554,7 @@ void U2Nnet::AttentionRescoring(const std::vector<std::vector<int>>& hyps,
}
#endif // end TEST_DEBUG
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
stringstream
path
(
"hyps_lens"
,
std
::
ios_base
::
app
|
std
::
ios_base
::
out
);
...
...
@@ -570,7 +570,7 @@ void U2Nnet::AttentionRescoring(const std::vector<std::vector<int>>& hyps,
}
#endif // end TEST_DEBUG
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
stringstream
path
(
"hyps_tensor"
,
std
::
ios_base
::
app
|
std
::
ios_base
::
out
);
...
...
runtime/engine/cls/nnet/CMakeLists.txt
浏览文件 @
591b957b
...
...
@@ -3,7 +3,7 @@ set(srcs
panns_interface.cc
)
add_library
(
cls
${
srcs
}
)
add_library
(
cls
SHARED
${
srcs
}
)
target_link_libraries
(
cls PRIVATE
${
FASTDEPLOY_LIBS
}
kaldi-matrix kaldi-base frontend utils
)
set
(
bin_name panns_nnet_main
)
...
...
runtime/engine/cls/nnet/panns_nnet.cc
浏览文件 @
591b957b
...
...
@@ -49,23 +49,22 @@ int ClsNnet::Init(const ClsNnetConf& conf) {
// init model
fastdeploy
::
RuntimeOption
runtime_option
;
#ifdef USE_ORT_BACKEND
#ifdef USE_PADDLE_INFERENCE_BACKEND
runtime_option
.
SetModelPath
(
conf
.
model_file_path_
,
conf
.
param_file_path_
,
fastdeploy
::
ModelFormat
::
PADDLE
);
runtime_option
.
UsePaddleInferBackend
();
#elif defined(USE_ORT_BACKEND)
runtime_option
.
SetModelPath
(
conf
.
model_file_path_
,
""
,
fastdeploy
::
ModelFormat
::
ONNX
);
// onnx
runtime_option
.
UseOrtBackend
();
// onnx
#endif
#ifdef USE_PADDLE_LITE_BACKEND
#elif defined(USE_PADDLE_LITE_BACKEND)
runtime_option
.
SetModelPath
(
conf
.
model_file_path_
,
conf
.
param_file_path_
,
fastdeploy
::
ModelFormat
::
PADDLE
);
runtime_option
.
UseLiteBackend
();
#endif
#ifdef USE_PADDLE_INFERENCE_BACKEND
runtime_option
.
SetModelPath
(
conf
.
model_file_path_
,
conf
.
param_file_path_
,
fastdeploy
::
ModelFormat
::
PADDLE
);
runtime_option
.
UsePaddleInferBackend
();
#endif
runtime_option
.
SetCpuThreadNum
(
conf
.
num_cpu_thread_
);
// runtime_option.DeletePaddleBackendPass("simplify_with_basic_ops_pass");
runtime_
=
std
::
unique_ptr
<
fastdeploy
::
Runtime
>
(
new
fastdeploy
::
Runtime
());
...
...
@@ -105,7 +104,7 @@ int ClsNnet::Forward(const char* wav_path,
conf_
.
wav_normal_
,
conf_
.
wav_normal_type_
,
conf_
.
wav_norm_mul_factor_
);
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
ofstream
fp
(
"cls.wavform"
,
std
::
ios
::
out
);
for
(
int
i
=
0
;
i
<
wavform
.
size
();
++
i
)
{
...
...
@@ -138,7 +137,7 @@ int ClsNnet::Forward(const char* wav_path,
feats
[
i
*
feat_dim
+
j
]
=
PowerTodb
(
feats
[
i
*
feat_dim
+
j
]);
}
}
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
ofstream
fp
(
"cls.feat"
,
std
::
ios
::
out
);
for
(
int
i
=
0
;
i
<
num_frames
;
++
i
)
{
...
...
@@ -162,7 +161,7 @@ int ClsNnet::Forward(const char* wav_path,
#ifdef WITH_PROFILING
printf
(
"fast deploy infer consume: %fs
\n
"
,
timer
.
Elapsed
());
#endif
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
{
std
::
ofstream
fp
(
"cls.logits"
,
std
::
ios
::
out
);
for
(
int
i
=
0
;
i
<
model_out
.
size
();
++
i
)
{
...
...
runtime/engine/cls/nnet/panns_nnet_main.cc
浏览文件 @
591b957b
...
...
@@ -15,8 +15,8 @@
#include <fstream>
#include <string>
#include "
base/
flags.h"
#include "
base/lo
g.h"
#include "
gflags/g
flags.h"
#include "
glog/loggin
g.h"
#include "cls/nnet/panns_interface.h"
DEFINE_string
(
conf_path
,
""
,
"config path"
);
...
...
runtime/engine/common/base/log_impl.h
浏览文件 @
591b957b
...
...
@@ -90,7 +90,7 @@ class LogMessage {
}
// namespace ppspeech
#if
def N
DEBUG
#if
ndef PPS_
DEBUG
#define DLOG_INFO \
ppspeech::log::LogMessage(__FILE__, __LINE__, ppspeech::log::INFO, false)
#define DLOG_WARNING \
...
...
@@ -145,7 +145,7 @@ class LogMessage {
#define CHECK_LT(x, y) CHECK((x) < (y))
#define CHECK_GE(x, y) CHECK((x) >= (y))
#define CHECK_GT(x, y) CHECK((x) > (y))
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
#define DCHECK(x) CHECK(x)
#define DCHECK_EQ(x, y) CHECK_EQ(x, y)
#define DCHECK_NE(x, y) CHECK_NE(x, y)
...
...
@@ -153,7 +153,7 @@ class LogMessage {
#define DCHECK_LT(x, y) CHECK_LT(x, y)
#define DCHECK_GE(x, y) CHECK_GE(x, y)
#define DCHECK_GT(x, y) CHECK_GT(x, y)
#else
// NDEBUG
#else
#define DCHECK(condition) \
while (false) CHECK(condition)
#define DCHECK_EQ(val1, val2) \
...
...
runtime/engine/common/frontend/CMakeLists.txt
浏览文件 @
591b957b
...
...
@@ -7,6 +7,7 @@ add_library(kaldi-native-fbank-core
rfft.cc
)
target_link_libraries
(
kaldi-native-fbank-core PUBLIC utils base
)
target_compile_options
(
kaldi-native-fbank-core PUBLIC
"-fPIC"
)
add_library
(
frontend STATIC
cmvn.cc
...
...
runtime/engine/kaldi/base/kaldi-error.h
浏览文件 @
591b957b
...
...
@@ -181,7 +181,7 @@ private:
// Also see KALDI_COMPILE_TIME_ASSERT, defined in base/kaldi-utils.h, and
// KALDI_ASSERT_IS_INTEGER_TYPE and KALDI_ASSERT_IS_FLOATING_TYPE, also defined
// there.
#if
ndef N
DEBUG
#if
def PPS_
DEBUG
#define KALDI_ASSERT(cond) \
do { \
if (cond) \
...
...
runtime/engine/vad/interface/CMakeLists.txt
浏览文件 @
591b957b
...
...
@@ -2,7 +2,7 @@ set(srcs
vad_interface.cc
)
add_library
(
pps_vad_interface
${
srcs
}
)
add_library
(
pps_vad_interface
SHARED
${
srcs
}
)
target_link_libraries
(
pps_vad_interface PUBLIC pps_vad extern_glog
)
...
...
runtime/engine/vad/nnet/CMakeLists.txt
浏览文件 @
591b957b
...
...
@@ -12,4 +12,8 @@ target_link_libraries(${bin_name} pps_vad)
file
(
RELATIVE_PATH DEST_DIR
${
ENGINE_ROOT
}
${
CMAKE_CURRENT_SOURCE_DIR
}
)
install
(
TARGETS pps_vad DESTINATION lib
)
install
(
TARGETS glog DESTINATION lib
)
\ No newline at end of file
if
(
ANDROID
)
install
(
TARGETS extern_glog DESTINATION lib
)
else
()
# UNIX
install
(
TARGETS glog DESTINATION lib
)
endif
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录