Skip to content

Commit 83e7a97

Browse files
committed
pipeline done
1 parent 13980b4 commit 83e7a97

File tree

158 files changed

+233
-185
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+233
-185
lines changed

.clang-format

100644100755
File mode changed.

.flake8

100644100755
File mode changed.

.github/scripts/.gitignore

100644100755
File mode changed.

.gitignore

100644100755
File mode changed.

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ if(UNIX AND NOT APPLE AND NOT SHERPA_ONNX_ENABLE_WASM AND NOT CMAKE_SYSTEM_NAME
9494
Could not find alsa/asoundlib.h !
9595
We won't build sherpa-onnx-alsa
9696
To fix that, please do:
97-
(1) sudo apt-get install alsa-utils libasound2-dev
97+
(1) sudo apt-get update -y && sudo apt-get install -y alsa-utils libasound2-dev
9898
(2) rm -rf build
9999
(3) re-try
100100
")

CPPLINT.cfg

100644100755
File mode changed.

LICENSE

100644100755
File mode changed.

MANIFEST.in

100644100755
File mode changed.

README.md

100644100755
File mode changed.

cmake/.gitignore

100644100755
File mode changed.

cmake/__init__.py

100644100755
File mode changed.

cmake/asio.cmake

100644100755
File mode changed.

cmake/cargs.cmake

100644100755
File mode changed.

cmake/cmake_extension.py

100644100755
File mode changed.

cmake/eigen.cmake

100644100755
File mode changed.

cmake/espeak-ng-for-piper.cmake

100644100755
File mode changed.

cmake/googletest.cmake

100644100755
File mode changed.

cmake/kaldi-decoder.cmake

100644100755
File mode changed.

cmake/kaldi-native-fbank.cmake

100644100755
File mode changed.

cmake/kaldifst.cmake

100644100755
File mode changed.

cmake/onnxruntime-linux-aarch64-static.cmake

100644100755
File mode changed.

cmake/onnxruntime-linux-aarch64.cmake

100644100755
File mode changed.

cmake/onnxruntime-linux-arm-static.cmake

100644100755
File mode changed.

cmake/onnxruntime-linux-arm.cmake

100644100755
File mode changed.

cmake/onnxruntime-linux-riscv64-static.cmake

100644100755
File mode changed.

cmake/onnxruntime-linux-riscv64.cmake

100644100755
File mode changed.

cmake/onnxruntime-linux-x86_64-gpu.cmake

100644100755
File mode changed.

cmake/onnxruntime-linux-x86_64-static.cmake

100644100755
File mode changed.

cmake/onnxruntime-linux-x86_64.cmake

100644100755
File mode changed.

cmake/onnxruntime-osx-arm64-static.cmake

100644100755
File mode changed.

cmake/onnxruntime-osx-arm64.cmake

100644100755
File mode changed.

cmake/onnxruntime-osx-universal-static.cmake

100644100755
File mode changed.

cmake/onnxruntime-osx-universal.cmake

100644100755
File mode changed.

cmake/onnxruntime-osx-x86_64-static.cmake

100644100755
File mode changed.

cmake/onnxruntime-osx-x86_64.cmake

100644100755
File mode changed.

cmake/onnxruntime-wasm-simd.cmake

100644100755
File mode changed.

cmake/onnxruntime-win-x64-gpu.cmake

100644100755
File mode changed.

cmake/onnxruntime-win-x64-static-debug.cmake

100644100755
File mode changed.

cmake/onnxruntime-win-x64-static.cmake

100644100755
File mode changed.

cmake/onnxruntime-win-x64.cmake

100644100755
File mode changed.

cmake/onnxruntime-win-x86-static-debug.cmake

100644100755
File mode changed.

cmake/onnxruntime-win-x86-static.cmake

100644100755
File mode changed.

cmake/onnxruntime-win-x86.cmake

100644100755
File mode changed.

cmake/onnxruntime.cmake

100644100755
File mode changed.

cmake/openfst.cmake

100644100755
File mode changed.

cmake/piper-phonemize.cmake

100644100755
File mode changed.

cmake/portaudio.cmake

100644100755
File mode changed.

cmake/pybind11.cmake

100644100755
File mode changed.

cmake/sherpa-onnx-no-tts.pc.in

100644100755
File mode changed.

cmake/sherpa-onnx.pc.in

100644100755
File mode changed.

cmake/websocketpp.cmake

100644100755
File mode changed.

setup.py

100644100755
File mode changed.

sherpa-onnx/CMakeLists.txt

100644100755
File mode changed.

sherpa-onnx/c-api/CMakeLists.txt

100644100755
File mode changed.

sherpa-onnx/c-api/c-api.cc

100644100755
File mode changed.

sherpa-onnx/c-api/c-api.h

100644100755
File mode changed.

sherpa-onnx/csrc/.gitignore

100644100755
File mode changed.

sherpa-onnx/csrc/CMakeLists.txt

+8-6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ set(sources
2929
online-transducer-model.cc
3030
online-zipformer-transducer-model.cc
3131
onnx-utils.cc
32+
cvi-utils.cc
33+
onnx-to-cvi.cc
3234
packed-sequence.cc
3335
pad-sequence.cc
3436
parse-options.cc
@@ -70,6 +72,12 @@ endif()
7072

7173
target_link_libraries(sherpa-onnx-core -lm)
7274

75+
set(CVI_LIBS ${CVI_LIBS} cviruntime cvikernel)
76+
if(NOT CMAKE_CROSSCOMPILING)
77+
set(CVI_LIBS ${CVI_LIBS} cvicmodel)
78+
endif()
79+
80+
target_link_libraries(sherpa-onnx-core ${CVI_LIBS})
7381

7482
if(SHERPA_ONNX_ENABLE_TTS)
7583
target_link_libraries(sherpa-onnx-core piper_phonemize)
@@ -137,11 +145,6 @@ if(SHERPA_ONNX_ENABLE_BINARY)
137145
)
138146
endif()
139147

140-
set(CVI_LIBS ${CVI_LIBS} cviruntime cvikernel)
141-
if(NOT CMAKE_CROSSCOMPILING)
142-
set(CVI_LIBS ${CVI_LIBS} cvicmodel)
143-
endif()
144-
145148
if(SHERPA_ONNX_HAS_ALSA AND SHERPA_ONNX_ENABLE_BINARY)
146149
add_executable(sherpa-onnx-alsa sherpa-onnx-alsa.cc alsa.cc)
147150

@@ -151,7 +154,6 @@ if(SHERPA_ONNX_HAS_ALSA AND SHERPA_ONNX_ENABLE_BINARY)
151154

152155
foreach(exe IN LISTS exes)
153156
target_link_libraries(${exe} sherpa-onnx-core)
154-
target_link_libraries(${exe} ${CVI_LIBS})
155157
endforeach()
156158

157159
foreach(exe IN LISTS exes)

sherpa-onnx/csrc/CPPLINT.cfg

100644100755
File mode changed.

sherpa-onnx/csrc/README.md

100644100755
File mode changed.

sherpa-onnx/csrc/alsa-play.cc

100644100755
File mode changed.

sherpa-onnx/csrc/alsa-play.h

100644100755
File mode changed.

sherpa-onnx/csrc/alsa.cc

100644100755
File mode changed.

sherpa-onnx/csrc/alsa.h

100644100755
File mode changed.

sherpa-onnx/csrc/base64-decode.cc

100644100755
File mode changed.

sherpa-onnx/csrc/base64-decode.h

100644100755
File mode changed.

sherpa-onnx/csrc/cat-test.cc

100644100755
File mode changed.

sherpa-onnx/csrc/cat.cc

100644100755
File mode changed.

sherpa-onnx/csrc/cat.h

100644100755
File mode changed.

sherpa-onnx/csrc/circular-buffer-test.cc

100644100755
File mode changed.

sherpa-onnx/csrc/circular-buffer.cc

100644100755
File mode changed.

sherpa-onnx/csrc/circular-buffer.h

100644100755
File mode changed.

sherpa-onnx/csrc/context-graph-test.cc

100644100755
File mode changed.

sherpa-onnx/csrc/context-graph.cc

100644100755
File mode changed.

sherpa-onnx/csrc/context-graph.h

100644100755
File mode changed.

sherpa-onnx/csrc/cvi-utils.cc

100644100755
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include "sherpa-onnx/csrc/cvi-utils.h"
2+
3+
#include <algorithm>
4+
#include <fstream>
5+
#include <sstream>
6+
#include <string>
7+
8+
#include "cviruntime.h" // NOLINT
9+
#include "cvitpu_debug.h"
10+
11+
12+
#define EXIT_IF_ERROR(cond, statement) \
13+
if ((cond)) { \
14+
TPU_LOG_ERROR("%s\n", statement); \
15+
exit(1); \
16+
}
17+
18+
void GetInputOutPutInfo(CVI_MODEL_HANDLE model) {
19+
CVI_TENSOR *input_tensors, *output_tensors;
20+
int32_t input_num, output_num;
21+
CVI_RC ret = CVI_NN_GetInputOutputTensors(model, &input_tensors, &input_num, &output_tensors, &output_num);
22+
23+
EXIT_IF_ERROR(ret != CVI_RC_SUCCESS, "failed to get inputs & outputs from model");
24+
25+
// print the inputs & outputs's information
26+
if (1) {
27+
TPU_LOG_INFO("Inputs:\n");
28+
for (int i = 0; i < input_num; ++i) {
29+
auto &tensor = input_tensors[i];
30+
TPU_LOG_INFO(" [%d] %s <%d,%d,%d,%d>,%s\n",
31+
i, tensor.name, tensor.shape.dim[0], tensor.shape.dim[1], tensor.shape.dim[2],
32+
tensor.shape.dim[3], formatToStr(tensor.fmt));
33+
}
34+
TPU_LOG_INFO("Outputs:\n");
35+
for (int i = 0; i < output_num; ++i) {
36+
auto &tensor = output_tensors[i];
37+
TPU_LOG_INFO(" [%d] %s <%d,%d,%d,%d>,%s\n",
38+
i, tensor.name, tensor.shape.dim[0], tensor.shape.dim[1], tensor.shape.dim[2],
39+
tensor.shape.dim[3], formatToStr(tensor.fmt));
40+
}
41+
}
42+
}

sherpa-onnx/csrc/cvi-utils.h

100644100755
+46-64
Original file line numberDiff line numberDiff line change
@@ -3,86 +3,68 @@
33

44
#include <cassert>
55
#include <ostream>
6-
#include <string>
6+
#include <cstring>
77
#include <utility>
88
#include <vector>
9-
9+
#include <algorithm>
1010
#include "cviruntime.h" // NOLINT
1111

12-
namespace sherpa_onnx {
13-
14-
/**
15-
* Get the input names of a model.
16-
*
17-
* @param model A cviruntime model handle.
18-
* @param input_names. On return, it contains the input names of the model.
19-
* @param input_names_ptr. On return, input_names_ptr[i] contains
20-
* input_names[i].c_str()
21-
*/
22-
void GetInputNames(CVI_MODEL_HANDLE model, std::vector<std::string> *input_names,
23-
std::vector<const char *> *input_names_ptr);
24-
25-
/**
26-
* Get the output names of a model.
27-
*
28-
* @param model A cviruntime model handle.
29-
* @param output_names. On return, it contains the output names of the model.
30-
* @param output_names_ptr. On return, output_names_ptr[i] contains
31-
* output_names[i].c_str()
32-
*/
33-
void GetOutputNames(CVI_MODEL_HANDLE model, std::vector<std::string> *output_names,
34-
std::vector<const char *> *output_names_ptr);
3512

36-
/**
37-
* Get the output frame of Encoder
38-
*
39-
* @param allocator allocator of cviruntime
40-
* @param encoder_out encoder out tensor
41-
* @param t frame_index
42-
*/
43-
CVI_TENSOR GetEncoderOutFrame(CVI_MODEL_HANDLE model, CVI_TENSOR *encoder_out,
44-
int32_t t);
13+
static const char* formatToStr(CVI_FMT fmt) {
14+
switch(fmt) {
15+
case CVI_FMT_FP32: return "fp32";
16+
case CVI_FMT_INT32: return "i32";
17+
case CVI_FMT_UINT32: return "u32";
18+
case CVI_FMT_BF16: return "bf16";
19+
case CVI_FMT_INT16: return "i16";
20+
case CVI_FMT_UINT16: return "u16";
21+
case CVI_FMT_INT8: return "i8";
22+
case CVI_FMT_UINT8: return "u8";
23+
default:
24+
TPU_LOG_FATAL("unknown fmt:%d\n", fmt);
25+
}
26+
return nullptr;
27+
}
4528

46-
/**
47-
* Print model metadata.
48-
*
49-
* @param os The output stream.
50-
* @param model The cviruntime model handle.
51-
*/
52-
void PrintModelMetadata(std::ostream &os, CVI_MODEL_HANDLE model);
29+
static void copyFp32ToFp32(float *src, float *dst, int count) {
30+
memcpy(dst, src, count * sizeof(float));
31+
}
5332

54-
// Return a deep copy of v
55-
CVI_TENSOR Clone(CVI_MODEL_HANDLE model, const CVI_TENSOR *v);
33+
static void copyFp64ToFp32(double *src, float *dst, int count) {
34+
std::transform(src, src + count, dst, [](double x) { return static_cast<float>(x); });
35+
}
5636

57-
// Return a shallow copy
58-
CVI_TENSOR View(const CVI_TENSOR *v);
37+
static void copyI64ToFp32(int64_t *src, float *dst, int count) {
38+
// use bitcasting to convert int64 to float, this is much faster than shifting
39+
memcpy(dst, reinterpret_cast<float*>(src), count * sizeof(float));
40+
}
5941

60-
// Print a 1-D tensor to stderr
61-
void Print1D(const CVI_TENSOR *v);
42+
static void copyI64ToU16(int64_t *src, uint16_t *dst, int count) {
43+
std::transform(src, src + count, dst, [](int64_t x) { return static_cast<uint16_t>(x); });
44+
}
6245

63-
// Print a 2-D tensor to stderr
64-
template <typename T = float>
65-
void Print2D(const CVI_TENSOR *v);
46+
static void copyI32ToFp32(int *src, float *dst, int count) {
47+
std::transform(src, src + count, dst, [](int x) { return static_cast<float>(x); });
48+
}
6649

67-
// Print a 3-D tensor to stderr
68-
void Print3D(const CVI_TENSOR *v);
50+
static void copyI32ToU16(int *src, uint16_t *dst, int count) {
51+
memcpy(dst, reinterpret_cast<uint16_t*>(src), count * sizeof(uint16_t));
52+
}
6953

70-
// Print a 4-D tensor to stderr
71-
void Print4D(const CVI_TENSOR *v);
54+
static void copyI32ToU8(int *src, uint8_t *dst, int count) {
55+
memcpy(dst, reinterpret_cast<uint8_t*>(src), count * sizeof(uint8_t));
56+
}
7257

73-
template <typename T = float>
74-
void Fill(CVI_TENSOR *tensor, T value) {
75-
auto n = CVI_NN_TensorCount(tensor);
76-
auto p = CVI_NN_TensorPtr(tensor);
77-
std::fill(p, p + n * sizeof(T), value);
58+
static void copyI32ToI8(int *src, int8_t *dst, int count) {
59+
memcpy(dst, reinterpret_cast<int8_t*>(src), count * sizeof(int8_t));
7860
}
7961

80-
std::vector<CVI_TENSOR> ReadFile(const std::string &filename);
8162

82-
// TODO(fangjun): Document it
83-
CVI_TENSOR Repeat(CVI_MODEL_HANDLE model, const CVI_TENSOR *cur_encoder_out,
84-
const std::vector<int32_t> &hyps_num_split);
8563

86-
} // namespace sherpa_onnx
64+
/**
65+
* Get the input and output names and shapes of a model.
66+
* @param model A cviruntime model handle.
67+
*/
68+
void GetInputOutPutInfo(CVI_MODEL_HANDLE model);
8769

8870
#endif // SHERPA_CVIRTL_UTILS_H_

sherpa-onnx/csrc/display.h

100644100755
File mode changed.

sherpa-onnx/csrc/endpoint.cc

100644100755
File mode changed.

sherpa-onnx/csrc/endpoint.h

100644100755
File mode changed.

sherpa-onnx/csrc/features.cc

100644100755
File mode changed.

sherpa-onnx/csrc/features.h

100644100755
File mode changed.

sherpa-onnx/csrc/file-utils.cc

100644100755
File mode changed.

sherpa-onnx/csrc/file-utils.h

100644100755
File mode changed.

sherpa-onnx/csrc/hypothesis.cc

100644100755
File mode changed.

sherpa-onnx/csrc/hypothesis.h

100644100755
File mode changed.

sherpa-onnx/csrc/log.cc

100644100755
File mode changed.

sherpa-onnx/csrc/log.h

100644100755
File mode changed.

sherpa-onnx/csrc/macros.h

100644100755
File mode changed.

sherpa-onnx/csrc/math.h

100644100755
File mode changed.

sherpa-onnx/csrc/microphone.cc

100644100755
File mode changed.

sherpa-onnx/csrc/microphone.h

100644100755
File mode changed.

sherpa-onnx/csrc/online-model-config.cc

100644100755
File mode changed.

sherpa-onnx/csrc/online-model-config.h

100644100755
File mode changed.

sherpa-onnx/csrc/online-recognizer-impl.cc

100644100755
File mode changed.

sherpa-onnx/csrc/online-recognizer-impl.h

100644100755
File mode changed.

sherpa-onnx/csrc/online-recognizer-transducer-impl.h

100644100755
File mode changed.

sherpa-onnx/csrc/online-recognizer.cc

100644100755
File mode changed.

sherpa-onnx/csrc/online-recognizer.h

100644100755
File mode changed.

sherpa-onnx/csrc/online-stream.cc

100644100755
File mode changed.

sherpa-onnx/csrc/online-stream.h

100644100755
File mode changed.

sherpa-onnx/csrc/online-transducer-decoder.cc

100644100755
File mode changed.

sherpa-onnx/csrc/online-transducer-decoder.h

100644100755
File mode changed.

sherpa-onnx/csrc/online-transducer-greedy-search-decoder.cc

100644100755
File mode changed.

sherpa-onnx/csrc/online-transducer-greedy-search-decoder.h

100644100755
File mode changed.

sherpa-onnx/csrc/online-transducer-model-config.cc

100644100755
File mode changed.

sherpa-onnx/csrc/online-transducer-model-config.h

100644100755
File mode changed.

sherpa-onnx/csrc/online-transducer-model.cc

100644100755
+1-28
Original file line numberDiff line numberDiff line change
@@ -62,34 +62,7 @@ static ModelType GetModelType(char *model_data, size_t model_data_length,
6262

6363
std::unique_ptr<OnlineTransducerModel> OnlineTransducerModel::Create(
6464
const OnlineModelConfig &config) {
65-
if (!config.model_type.empty()) {
66-
const auto &model_type = config.model_type;
67-
if (model_type == "zipformer") {
68-
return std::make_unique<OnlineZipformerTransducerModel>(config);
69-
} else {
70-
SHERPA_ONNX_LOGE(
71-
"Invalid model_type: %s. Trying to load the model to get its type",
72-
model_type.c_str());
73-
}
74-
}
75-
ModelType model_type = ModelType::kUnknown;
76-
77-
{
78-
auto buffer = ReadFile(config.transducer.encoder);
79-
80-
model_type = GetModelType(buffer.data(), buffer.size(), config.debug);
81-
}
82-
83-
switch (model_type) {
84-
case ModelType::kZipformer:
85-
return std::make_unique<OnlineZipformerTransducerModel>(config);
86-
case ModelType::kUnknown:
87-
SHERPA_ONNX_LOGE("Unknown model type in online transducer!");
88-
return nullptr;
89-
}
90-
91-
// unreachable code
92-
return nullptr;
65+
return std::make_unique<OnlineZipformerTransducerModel>(config);
9366
}
9467

9568
Ort::Value OnlineTransducerModel::BuildDecoderInput(

sherpa-onnx/csrc/online-transducer-model.h

100644100755
File mode changed.

sherpa-onnx/csrc/online-zipformer-transducer-model.cc

+19-13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#include "sherpa-onnx/csrc/session.h"
2121
#include "sherpa-onnx/csrc/text-utils.h"
2222
#include "sherpa-onnx/csrc/unbind.h"
23+
#include "cviruntime.h"
24+
#include "cvi-utils.h"
25+
#include "onnx-to-cvi.h"
2326

2427
namespace sherpa_onnx {
2528

@@ -345,41 +348,44 @@ OnlineZipformerTransducerModel::RunEncoder(Ort::Value features,
345348
// get input / output tensors
346349
CVI_TENSOR *input_tensors, *output_tensors;
347350
int32_t input_num, output_num;
348-
CVI_NN_GetInputOutputTensors(encoder_sess_, &input_tensors, input_num, &output_tensors, output_num);
351+
CVI_NN_GetInputOutputTensors(encoder_sess_, &input_tensors, &input_num, &output_tensors, &output_num);
349352
printf("[encoder] input num: %d, output num: %d\n", input_num, output_num);
350353

351354
LoadOrtValuesToCviTensors(encoder_inputs, input_tensors, input_num);
352355

353-
CVI_NN_Forward(encoder_sess_, &input_tensors, &input_num, &output_tensors, &output_num);
356+
CVI_NN_Forward(encoder_sess_, input_tensors, input_num, output_tensors, output_num);
354357

355-
std::vector<Ort::Value> next_states = GetOrtValuesFromCviTensors(output_tensors+1, output_num, allocator_);
358+
std::vector<Ort::Value> next_states = GetOrtValuesFromCviTensors(output_tensors+1, output_num-1);
356359

357-
return {std::move(ConvertCviTensorToOrtValue(output_tensors[0], allocator_), std::move(next_states)};
360+
return {std::move(GetOrtValueFromCviTensor(output_tensors[0])), std::move(next_states)};
358361
}
359362

360363
Ort::Value OnlineZipformerTransducerModel::RunDecoder(Ort::Value decoder_input) {
361364
// get input / output tensors
362365
CVI_TENSOR *input_tensors, *output_tensors;
363366
int32_t input_num, output_num;
364-
CVI_NN_GetInputOutputTensors(encoder_sess_, &input_tensors, input_num, &output_tensors, output_num);
367+
CVI_NN_GetInputOutputTensors(decoder_sess_, &input_tensors, &input_num, &output_tensors, &output_num);
365368
printf("[Decoder] input num: %d, output num: %d\n", input_num, output_num);
366-
367-
LoadOrtValuesToCviTensors(encoder_inputs, input_tensors, input_num);
368-
CVI_NN_Forward(decoder_sess_, &input_tensors, &input_num, &output_tensors, &output_num);
369-
return std::move(ConvertCviTensorToOrtValue(output_tensors[0], allocator_);
369+
std::vector<Ort::Value> temp = {};
370+
temp.push_back(std::move(decoder_input));
371+
LoadOrtValuesToCviTensors(temp, input_tensors, input_num);
372+
CVI_NN_Forward(decoder_sess_, input_tensors, input_num, output_tensors, output_num);
373+
return std::move(GetOrtValueFromCviTensor(output_tensors[0]));
370374
}
371375

372376
Ort::Value OnlineZipformerTransducerModel::RunJoiner(Ort::Value encoder_out,
373377
Ort::Value decoder_out) {
374378
// get input / output tensors
375379
CVI_TENSOR *input_tensors, *output_tensors;
376380
int32_t input_num, output_num;
377-
CVI_NN_GetInputOutputTensors(joiner_sess_, &input_tensors, input_num, &output_tensors, output_num);
381+
CVI_NN_GetInputOutputTensors(joiner_sess_, &input_tensors, &input_num, &output_tensors, &output_num);
378382
printf("[Decoder] input num: %d, output num: %d\n", input_num, output_num);
379-
std::vector<Ort::Value> temp = {std::move(encoder_out), std::move(decoder_out)};
383+
std::vector<Ort::Value> temp = {};
384+
temp.push_back(std::move(encoder_out));
385+
temp.push_back(std::move(decoder_out));
380386
LoadOrtValuesToCviTensors(temp, input_tensors, input_num);
381-
CVI_NN_Forward(joiner_sess_, &input_tensors, &input_num, &output_tensors, &output_num);
382-
return std::move(ConvertCviTensorToOrtValue(output_tensors[0], allocator_)
387+
CVI_NN_Forward(joiner_sess_, input_tensors, input_num, output_tensors, output_num);
388+
return std::move(GetOrtValueFromCviTensor(output_tensors[0]));
383389
}
384390

385391
} // namespace sherpa_onnx

sherpa-onnx/csrc/online-zipformer-transducer-model.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <utility>
1010
#include <vector>
1111

12-
#include "onnx-to-cvi.h"
12+
#include "cviruntime.h"
1313
#include "sherpa-onnx/csrc/online-model-config.h"
1414
#include "sherpa-onnx/csrc/online-transducer-model.h"
1515

@@ -54,9 +54,9 @@ class OnlineZipformerTransducerModel : public OnlineTransducerModel {
5454
Ort::SessionOptions sess_opts_;
5555
Ort::AllocatorWithDefaultOptions allocator_;
5656

57-
std::unique_ptr<Ort::Session> encoder_sess_;
58-
std::unique_ptr<Ort::Session> decoder_sess_;
59-
std::unique_ptr<Ort::Session> joiner_sess_;
57+
CVI_MODEL_HANDLE encoder_sess_ = nullptr;
58+
CVI_MODEL_HANDLE decoder_sess_ = nullptr;
59+
CVI_MODEL_HANDLE joiner_sess_ = nullptr;
6060

6161
std::vector<std::string> encoder_input_names_;
6262
std::vector<const char *> encoder_input_names_ptr_;

0 commit comments

Comments
 (0)