From 5d7382f3300b8eca910efb2a09a3abc2c53e3d9b Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Fri, 1 Nov 2024 11:13:34 +0800 Subject: [PATCH] Fix style issues --- build-aarch64-linux-gnu.sh | 5 +++++ sherpa-onnx/csrc/macros.h | 2 ++ sherpa-onnx/csrc/symbol-table.cc | 17 ++++++++--------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/build-aarch64-linux-gnu.sh b/build-aarch64-linux-gnu.sh index 3e344bb01..62b359c17 100755 --- a/build-aarch64-linux-gnu.sh +++ b/build-aarch64-linux-gnu.sh @@ -47,6 +47,11 @@ fi if [[ x"$SHERPA_ONNX_ENABLE_GPU" == x"" ]]; then # By default, use CPU SHERPA_ONNX_ENABLE_GPU=OFF + + # If you use GPU, then please make sure you have NVIDIA GPUs on your board. + # It uses onnxruntime 1.11.0. + # + # Tested on Jetson Nano B01 fi if [[ x"$SHERPA_ONNX_ENABLE_GPU" == x"ON" ]]; then diff --git a/sherpa-onnx/csrc/macros.h b/sherpa-onnx/csrc/macros.h index a9fae424a..506e63e13 100644 --- a/sherpa-onnx/csrc/macros.h +++ b/sherpa-onnx/csrc/macros.h @@ -7,6 +7,8 @@ #include #include +#include + #if __ANDROID_API__ >= 8 #include "android/log.h" #define SHERPA_ONNX_LOGE(...) \ diff --git a/sherpa-onnx/csrc/symbol-table.cc b/sherpa-onnx/csrc/symbol-table.cc index 173b060b4..77b976431 100644 --- a/sherpa-onnx/csrc/symbol-table.cc +++ b/sherpa-onnx/csrc/symbol-table.cc @@ -29,20 +29,19 @@ namespace { const char *ws = " \t\n\r\f\v"; // trim from end of string (right) -inline std::string &TrimRight(std::string &s, const char *t = ws) { - s.erase(s.find_last_not_of(t) + 1); - return s; +inline void TrimRight(std::string *s, const char *t = ws) { + s->erase(s->find_last_not_of(t) + 1); } // trim from beginning of string (left) -inline std::string &TrimLeft(std::string &s, const char *t = ws) { - s.erase(0, s.find_first_not_of(t)); - return s; +inline void TrimLeft(std::string *s, const char *t = ws) { + s->erase(0, s->find_first_not_of(t)); } // trim from both ends of string (right then left) -inline std::string &Trim(std::string &s, const char *t = ws) { - return TrimLeft(TrimRight(s, t), t); +inline void Trim(std::string *s, const char *t = ws) { + TrimRight(s, t); + TrimLeft(s, t); } } // namespace @@ -56,7 +55,7 @@ std::unordered_map ReadTokens( std::string sym; int32_t id = -1; while (std::getline(is, line)) { - Trim(line); + Trim(&line); std::istringstream iss(line); iss >> sym; if (iss.eof()) {