From d93002b5b8e0d12c726566958140e632eb6c9b3a Mon Sep 17 00:00:00 2001
From: 雾聪 <wucong.lyb@alibaba-inc.com>
Date: 星期一, 01 四月 2024 11:05:39 +0800
Subject: [PATCH] fix padding
---
runtime/websocket/bin/funasr-wss-server.cpp | 2 +-
runtime/onnxruntime/bin/funasr-onnx-offline.cpp | 2 +-
runtime/onnxruntime/include/com-define.h | 1 +
runtime/onnxruntime/src/paraformer-torch.cpp | 6 +++---
runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp | 2 +-
5 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp b/runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp
index 4ff216a..bb032e6 100644
--- a/runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp
+++ b/runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp
@@ -144,7 +144,7 @@
TCLAP::ValueArg<std::int32_t> thread_num("", THREAD_NUM, "multi-thread num for rtf", false, 1, "int32_t");
TCLAP::ValueArg<std::string> hotword("", HOTWORD, "the hotword file, one hotword perline, Format: Hotword Weight (could be: 闃块噷宸村反 20)", false, "", "string");
TCLAP::SwitchArg use_gpu("", INFER_GPU, "Whether to use GPU for inference, default is false", false);
- TCLAP::ValueArg<std::int32_t> batch_size("", "batch-size", "batch_size for ASR model when using GPU", false, 1, "int32_t");
+ TCLAP::ValueArg<std::int32_t> batch_size("", BATCHSIZE, "batch_size for ASR model when using GPU", false, 1, "int32_t");
cmd.add(model_dir);
cmd.add(quantize);
diff --git a/runtime/onnxruntime/bin/funasr-onnx-offline.cpp b/runtime/onnxruntime/bin/funasr-onnx-offline.cpp
index c8b0d4b..f0234c8 100644
--- a/runtime/onnxruntime/bin/funasr-onnx-offline.cpp
+++ b/runtime/onnxruntime/bin/funasr-onnx-offline.cpp
@@ -60,7 +60,7 @@
TCLAP::ValueArg<std::int32_t> audio_fs("", AUDIO_FS, "the sample rate of audio", false, 16000, "int32_t");
TCLAP::ValueArg<std::string> hotword("", HOTWORD, "the hotword file, one hotword perline, Format: Hotword Weight (could be: 闃块噷宸村反 20)", false, "", "string");
TCLAP::SwitchArg use_gpu("", INFER_GPU, "Whether to use GPU for inference, default is false", false);
- TCLAP::ValueArg<std::int32_t> batch_size("", "batch-size", "batch_size for ASR model when using GPU", false, 5, "int32_t");
+ TCLAP::ValueArg<std::int32_t> batch_size("", BATCHSIZE, "batch_size for ASR model when using GPU", false, 5, "int32_t");
cmd.add(model_dir);
cmd.add(quantize);
diff --git a/runtime/onnxruntime/include/com-define.h b/runtime/onnxruntime/include/com-define.h
index 7160a0e..9480b0b 100644
--- a/runtime/onnxruntime/include/com-define.h
+++ b/runtime/onnxruntime/include/com-define.h
@@ -51,6 +51,7 @@
#define QUANT_MODEL_NAME "model_quant.onnx"
// gpu models
#define INFER_GPU "gpu"
+#define BATCHSIZE "batch-size"
#define TORCH_MODEL_NAME "model.torchscripts"
#define TORCH_QUANT_MODEL_NAME "model_quant.torchscripts"
#define BLADE_MODEL_NAME "model.blade.fp16.pt"
diff --git a/runtime/onnxruntime/src/paraformer-torch.cpp b/runtime/onnxruntime/src/paraformer-torch.cpp
index e603e89..9ac0cf7 100644
--- a/runtime/onnxruntime/src/paraformer-torch.cpp
+++ b/runtime/onnxruntime/src/paraformer-torch.cpp
@@ -281,10 +281,10 @@
if(asr_feats.size() != 0){
LfrCmvn(asr_feats);
}
- int32_t num_frames = asr_feats.size() / feature_dim;
+ int32_t num_frames = asr_feats.size();
paraformer_length.emplace_back(num_frames);
- if(max_size < asr_feats.size()){
- max_size = asr_feats.size();
+ if(max_size < asr_feats.size()*feature_dim){
+ max_size = asr_feats.size()*feature_dim;
max_frames = num_frames;
}
diff --git a/runtime/websocket/bin/funasr-wss-server.cpp b/runtime/websocket/bin/funasr-wss-server.cpp
index cc4c156..f395e59 100644
--- a/runtime/websocket/bin/funasr-wss-server.cpp
+++ b/runtime/websocket/bin/funasr-wss-server.cpp
@@ -126,7 +126,7 @@
TCLAP::ValueArg<std::int32_t> fst_inc_wts("", FST_INC_WTS,
"the fst hotwords incremental bias", false, 20, "int32_t");
TCLAP::SwitchArg use_gpu("", INFER_GPU, "Whether to use GPU, default is false", false);
- TCLAP::ValueArg<std::int32_t> batch_size("", "batch-size", "batch_size for ASR model when using GPU", false, 5, "int32_t");
+ TCLAP::ValueArg<std::int32_t> batch_size("", BATCHSIZE, "batch_size for ASR model when using GPU", false, 5, "int32_t");
// add file
cmd.add(hotword);
--
Gitblit v1.9.1