Исходный код СУБД 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#pragma once
 
#include <filesystem>
#include <gsl/gsl>
#include <memory>
#include <string_view>
#include <vector>
#include "core/common/common.h"
#include "core/session/onnxruntime_c_api.h"
 
onnxruntime::common::Status CopyStringToOutputArg(std::string_view str, const char* err_msg, char* out, size_t* size);
 
struct OrtSessionOptions;
struct OrtStatus;
struct OrtPrepackedWeightsContainer;
namespace onnxruntime {
class InferenceSession;
class ModelCompilationOptions;
}  // namespace onnxruntime
 
#if !defined(ORT_MINIMAL_BUILD)
namespace onnxruntime {
class Environment;
class EpLibrary;
class EpFactoryInternal;
class IExecutionProvider;
class ModelPackageComponentContext;
struct IExecutionProviderFactory;
struct SessionOptions;
struct VariantSelectionEpInfo;
}  // namespace onnxruntime
#endif  // !defined(ORT_MINIMAL_BUILD)
 
OrtStatus* CreateSessionAndLoadModel(_In_ const OrtSessionOptions* options,
                                     _In_ const OrtEnv* env,
                                     _In_opt_z_ const ORTCHAR_T* model_path,
                                     _In_opt_ const void* model_data,
                                     size_t model_data_length,
                                     std::unique_ptr<onnxruntime::InferenceSession>& sess);
 
OrtStatus* InitializeSession(_In_ const OrtSessionOptions* options,
                             _In_ onnxruntime::InferenceSession& sess,
                             _Inout_opt_ OrtPrepackedWeightsContainer* prepacked_weights_container = nullptr);
 
#if !defined(ORT_MINIMAL_BUILD)
namespace onnxruntime {
 
/// <summary>
/// Compiles an ONNX model into a model with EPContext nodes. Each EPContext node represents a subgraph compiled for
/// a specific execution provider.
/// </summary>
/// <param name="env">A reference to the Environment instance.</param>
/// <param name="model_compile_options">An object specifying the compilation options.</param>
/// <returns>A Status indicating an error or success.</returns>
Status CompileModel(const Environment& env, const ModelCompilationOptions& model_compile_options);
 
// load a library that is added using RegisterExecutionProviderLibrary.
// infer whether it's a provider bridge library or plugin library
Status LoadPluginOrProviderBridge(const std::string& registration_name,
                                  const ORTCHAR_T* library_path,
                                  std::unique_ptr<EpLibrary>& ep_library,
                                  std::vector<EpFactoryInternal*>& internal_factories);
 
// Creates an IExecutionProviderFactory instance for a list of OrtEpDevices that all refer to the same EP.
Status CreateIExecutionProviderFactoryForEpDevices(const Environment& env,
                                                   gsl::span<const OrtEpDevice* const> ep_devices,
                                                   /*output*/ std::unique_ptr<IExecutionProviderFactory>& out);
 
// Adds provider options to the OrtSessionOptions configuration.
Status AddEpOptionsToSessionOptions(gsl::span<const OrtEpDevice* const> ep_devices,
                                    gsl::span<const char* const> ep_options_keys,
                                    gsl::span<const char* const> ep_options_vals,
                                    SessionOptions& session_options);
 
// Adss EP specific custom domains to the OrtSessionOptions configuration.
Status AddEpCustomDomainsToSessionOptions(gsl::span<const OrtEpDevice* const> ep_devices,
                                          OrtSessionOptions& ort_session_options);
 
// Builds VariantSelectionEpInfo entries from already-created IExecutionProvider instances.
// Same logic used by the standard CreateSession path for model package workflows; exposed so
// the model package API can pre-resolve EP selection (see ModelPackageOptions::ResolveEpSelection).
//
/// Constraints (matching the standard path):
//   - Only one EP is selected (CPU EP is skipped in favor of the first non-CPU EP if available).
//   - All devices are expected to be supported by the same EP.
Status GetVariantSelectionEpInfo(std::vector<std::unique_ptr<IExecutionProvider>>& provider_list,
                                 std::vector<VariantSelectionEpInfo>& ep_infos);
 
// Logs available environment EP devices and the ones selected for variant selection. Informational only.
Status PrintAvailableAndSelectedEpInfos(const Environment& env,
                                        std::vector<VariantSelectionEpInfo>& ep_infos);
 
// Create session for model package workflow.
OrtStatus* CreateSessionForModelPackage(
    _In_ const OrtSessionOptions* options,
    const onnxruntime::Environment& env,
    const std::filesystem::path& selected_model_path,
    onnxruntime::ModelPackageComponentContext& model_package_context,
    std::unique_ptr<onnxruntime::InferenceSession>& sess);
 
}  // namespace onnxruntime
#endif  // !defined(ORT_MINIMAL_BUILD)