Add lm rescore to online-modified-beam-search (#133)

This commit is contained in:
PF Luo
2023-05-05 21:23:54 +08:00
committed by GitHub
parent 3b9c3db31d
commit 8c6a6768d5
26 changed files with 495 additions and 39 deletions

View File

@@ -1,6 +1,7 @@
// sherpa-onnx/csrc/onnx-utils.h
//
// Copyright (c) 2023 Xiaomi Corporation
// Copyright (c) 2023 Pingfeng Luo
#ifndef SHERPA_ONNX_CSRC_ONNX_UTILS_H_
#define SHERPA_ONNX_CSRC_ONNX_UTILS_H_
@@ -13,6 +14,7 @@
#include <cassert>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
#if __ANDROID_API__ >= 9
@@ -89,6 +91,24 @@ std::vector<char> ReadFile(AAssetManager *mgr, const std::string &filename);
// TODO(fangjun): Document it
Ort::Value Repeat(OrtAllocator *allocator, Ort::Value *cur_encoder_out,
const std::vector<int32_t> &hyps_num_split);
struct CopyableOrtValue {
Ort::Value value{nullptr};
CopyableOrtValue() = default;
/*explicit*/ CopyableOrtValue(Ort::Value v) // NOLINT
: value(std::move(v)) {}
CopyableOrtValue(const CopyableOrtValue &other);
CopyableOrtValue &operator=(const CopyableOrtValue &other);
CopyableOrtValue(CopyableOrtValue &&other);
CopyableOrtValue &operator=(CopyableOrtValue &&other);
};
} // namespace sherpa_onnx
#endif // SHERPA_ONNX_CSRC_ONNX_UTILS_H_