Fangjun Kuang
Committed by GitHub

Fix building (#1508)

@@ -123,7 +123,7 @@ std::unique_ptr<OfflineRecognizerImpl> OfflineRecognizerImpl::Create( @@ -123,7 +123,7 @@ std::unique_ptr<OfflineRecognizerImpl> OfflineRecognizerImpl::Create(
123 123
124 auto model_type = 124 auto model_type =
125 LookupCustomModelMetaData(meta_data, "model_type", allocator); 125 LookupCustomModelMetaData(meta_data, "model_type", allocator);
126 - if (!model_type.empty()) { 126 + if (model_type.empty()) {
127 SHERPA_ONNX_LOGE( 127 SHERPA_ONNX_LOGE(
128 "No model_type in the metadata!\n\n" 128 "No model_type in the metadata!\n\n"
129 "Please refer to the following URLs to add metadata" 129 "Please refer to the following URLs to add metadata"
@@ -25,7 +25,7 @@ static std::string GetInputName(Ort::Session *sess, size_t index, @@ -25,7 +25,7 @@ static std::string GetInputName(Ort::Session *sess, size_t index,
25 OrtAllocator *allocator) { 25 OrtAllocator *allocator) {
26 // Note(fangjun): We only tested 1.17.1 and 1.11.0 26 // Note(fangjun): We only tested 1.17.1 and 1.11.0
27 // For other versions, we may need to change it 27 // For other versions, we may need to change it
28 -#if ORT_API_VERSION >= 17 28 +#if ORT_API_VERSION >= 12
29 auto v = sess->GetInputNameAllocated(index, allocator); 29 auto v = sess->GetInputNameAllocated(index, allocator);
30 return v.get(); 30 return v.get();
31 #else 31 #else
@@ -40,7 +40,7 @@ static std::string GetOutputName(Ort::Session *sess, size_t index, @@ -40,7 +40,7 @@ static std::string GetOutputName(Ort::Session *sess, size_t index,
40 OrtAllocator *allocator) { 40 OrtAllocator *allocator) {
41 // Note(fangjun): We only tested 1.17.1 and 1.11.0 41 // Note(fangjun): We only tested 1.17.1 and 1.11.0
42 // For other versions, we may need to change it 42 // For other versions, we may need to change it
43 -#if ORT_API_VERSION >= 17 43 +#if ORT_API_VERSION >= 12
44 auto v = sess->GetOutputNameAllocated(index, allocator); 44 auto v = sess->GetOutputNameAllocated(index, allocator);
45 return v.get(); 45 return v.get();
46 #else 46 #else
@@ -106,7 +106,7 @@ Ort::Value GetEncoderOutFrame(OrtAllocator *allocator, Ort::Value *encoder_out, @@ -106,7 +106,7 @@ Ort::Value GetEncoderOutFrame(OrtAllocator *allocator, Ort::Value *encoder_out,
106 106
107 void PrintModelMetadata(std::ostream &os, const Ort::ModelMetadata &meta_data) { 107 void PrintModelMetadata(std::ostream &os, const Ort::ModelMetadata &meta_data) {
108 Ort::AllocatorWithDefaultOptions allocator; 108 Ort::AllocatorWithDefaultOptions allocator;
109 -#if ORT_API_VERSION >= 17 109 +#if ORT_API_VERSION >= 12
110 std::vector<Ort::AllocatedStringPtr> v = 110 std::vector<Ort::AllocatedStringPtr> v =
111 meta_data.GetCustomMetadataMapKeysAllocated(allocator); 111 meta_data.GetCustomMetadataMapKeysAllocated(allocator);
112 for (const auto &key : v) { 112 for (const auto &key : v) {
@@ -406,7 +406,7 @@ std::string LookupCustomModelMetaData(const Ort::ModelMetadata &meta_data, @@ -406,7 +406,7 @@ std::string LookupCustomModelMetaData(const Ort::ModelMetadata &meta_data,
406 OrtAllocator *allocator) { 406 OrtAllocator *allocator) {
407 // Note(fangjun): We only tested 1.17.1 and 1.11.0 407 // Note(fangjun): We only tested 1.17.1 and 1.11.0
408 // For other versions, we may need to change it 408 // For other versions, we may need to change it
409 -#if ORT_API_VERSION >= 17 409 +#if ORT_API_VERSION >= 12
410 auto v = meta_data.LookupCustomMetadataMapAllocated(key, allocator); 410 auto v = meta_data.LookupCustomMetadataMapAllocated(key, allocator);
411 return v.get(); 411 return v.get();
412 #else 412 #else
@@ -60,7 +60,7 @@ Ort::SessionOptions GetSessionOptionsImpl( @@ -60,7 +60,7 @@ Ort::SessionOptions GetSessionOptionsImpl(
60 case Provider::kCPU: 60 case Provider::kCPU:
61 break; // nothing to do for the CPU provider 61 break; // nothing to do for the CPU provider
62 case Provider::kXnnpack: { 62 case Provider::kXnnpack: {
63 -#if ORT_API_VERSION >= 17 63 +#if ORT_API_VERSION >= 12
64 if (std::find(available_providers.begin(), available_providers.end(), 64 if (std::find(available_providers.begin(), available_providers.end(),
65 "XnnpackExecutionProvider") != available_providers.end()) { 65 "XnnpackExecutionProvider") != available_providers.end()) {
66 sess_opts.AppendExecutionProvider("XNNPACK"); 66 sess_opts.AppendExecutionProvider("XNNPACK");