Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#pragma once
 
#include "core/flatbuffers/schema/ort.fbs.h"
 
#if !defined(ORT_MINIMAL_BUILD)
//
// Includes to parse json session config from onnx model file
//
#include "core/graph/onnx_protobuf.h"
#include "core/session/inference_session.h"
#include "core/framework/session_options.h"
#include "core/framework/tuning_results.h"
#include "core/common/common.h"
#include "nlohmann/json.hpp"
using json = nlohmann::json;
#endif
 
namespace onnxruntime {
namespace logging {
class Logger;
}
namespace inference_session_utils {
 
// need this value to be accessible in all builds in order to report error for attempted usage in a minimal build
static constexpr const char* kOrtLoadConfigFromModelEnvVar = "ORT_LOAD_CONFIG_FROM_MODEL";
 
#if !defined(ORT_MINIMAL_BUILD)
bool AreAnyNodesAssignedToCpuEp(const Graph& graph);
 
//
// Code to parse json session config from onnx model file
//
static constexpr const char* kOrtConfigKey = "ort_config";
static constexpr const char* kSessionOptionsKey = "session_options";
static constexpr const char* kTuningResultsKeys = "tuning_results";
 
class JsonConfigParser {
 public:
  JsonConfigParser(const logging::Logger& logger) : logger_(logger) {
  }
 
  Status ParseOrtConfigJsonInModelProto(const ONNX_NAMESPACE::ModelProto& model_proto);
 
  Status ParseSessionOptionsFromModelProto(/*out*/ SessionOptions& session_options);
 
  Status ParseRunOptionsFromModelProto(/*out*/ RunOptions& run_options);
 
 private:
  // Logger instance that will be used to log events along the parsing steps
  const logging::Logger& logger_;
 
  // Flag indicating if the model has been checked for ort config json existence
  bool is_model_checked_for_ort_config_json_ = false;
 
  // Parsed json available for other utility methods to use (if the model did have a valid json)
  nlohmann::json parsed_json_;
 
  // Flag indicating if an ort config json is available to be used
  bool is_ort_config_json_available_ = false;
};
 
Status ParseTuningResultsFromModelMetadata(const onnxruntime::ModelMetadata& metadata,
                                           /*out*/ std::vector<TuningResults>& results,
                                           /*out*/ bool& key_found,
                                           const logging::Logger& logger);
 
#endif  // !defined(ORT_MINIMAL_BUILD)
 
}  // namespace inference_session_utils
}  // namespace onnxruntime