From 6ee8c99c5d3563727ba04b4c20c4fe2c8cbd2954 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Sun, 3 Nov 2024 19:47:04 +0800 Subject: [PATCH] Fix building (#1508) --- sherpa-onnx/csrc/offline-recognizer-impl.cc | 2 +- sherpa-onnx/csrc/onnx-utils.cc | 8 ++++---- sherpa-onnx/csrc/session.cc | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sherpa-onnx/csrc/offline-recognizer-impl.cc b/sherpa-onnx/csrc/offline-recognizer-impl.cc index f89bb9bec..99c41d307 100644 --- a/sherpa-onnx/csrc/offline-recognizer-impl.cc +++ b/sherpa-onnx/csrc/offline-recognizer-impl.cc @@ -123,7 +123,7 @@ std::unique_ptr OfflineRecognizerImpl::Create( auto model_type = LookupCustomModelMetaData(meta_data, "model_type", allocator); - if (!model_type.empty()) { + if (model_type.empty()) { SHERPA_ONNX_LOGE( "No model_type in the metadata!\n\n" "Please refer to the following URLs to add metadata" diff --git a/sherpa-onnx/csrc/onnx-utils.cc b/sherpa-onnx/csrc/onnx-utils.cc index 0dc69fc8f..31b6554c6 100644 --- a/sherpa-onnx/csrc/onnx-utils.cc +++ b/sherpa-onnx/csrc/onnx-utils.cc @@ -25,7 +25,7 @@ static std::string GetInputName(Ort::Session *sess, size_t index, OrtAllocator *allocator) { // Note(fangjun): We only tested 1.17.1 and 1.11.0 // For other versions, we may need to change it -#if ORT_API_VERSION >= 17 +#if ORT_API_VERSION >= 12 auto v = sess->GetInputNameAllocated(index, allocator); return v.get(); #else @@ -40,7 +40,7 @@ static std::string GetOutputName(Ort::Session *sess, size_t index, OrtAllocator *allocator) { // Note(fangjun): We only tested 1.17.1 and 1.11.0 // For other versions, we may need to change it -#if ORT_API_VERSION >= 17 +#if ORT_API_VERSION >= 12 auto v = sess->GetOutputNameAllocated(index, allocator); return v.get(); #else @@ -106,7 +106,7 @@ Ort::Value GetEncoderOutFrame(OrtAllocator *allocator, Ort::Value *encoder_out, void PrintModelMetadata(std::ostream &os, const Ort::ModelMetadata &meta_data) { Ort::AllocatorWithDefaultOptions allocator; -#if ORT_API_VERSION >= 17 +#if ORT_API_VERSION >= 12 std::vector v = meta_data.GetCustomMetadataMapKeysAllocated(allocator); for (const auto &key : v) { @@ -406,7 +406,7 @@ std::string LookupCustomModelMetaData(const Ort::ModelMetadata &meta_data, OrtAllocator *allocator) { // Note(fangjun): We only tested 1.17.1 and 1.11.0 // For other versions, we may need to change it -#if ORT_API_VERSION >= 17 +#if ORT_API_VERSION >= 12 auto v = meta_data.LookupCustomMetadataMapAllocated(key, allocator); return v.get(); #else diff --git a/sherpa-onnx/csrc/session.cc b/sherpa-onnx/csrc/session.cc index 160797c6e..cd9eb516f 100644 --- a/sherpa-onnx/csrc/session.cc +++ b/sherpa-onnx/csrc/session.cc @@ -60,7 +60,7 @@ Ort::SessionOptions GetSessionOptionsImpl( case Provider::kCPU: break; // nothing to do for the CPU provider case Provider::kXnnpack: { -#if ORT_API_VERSION >= 17 +#if ORT_API_VERSION >= 12 if (std::find(available_providers.begin(), available_providers.end(), "XnnpackExecutionProvider") != available_providers.end()) { sess_opts.AppendExecutionProvider("XNNPACK");