Исходный код СУБД 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
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#pragma once
 
#include "LearningModelSession.g.h"
 
#include "LearningModelBinding.h"
#include "MLOperatorAuthor.h"
#include "WinML_Lock.h"
#include "core/providers/winml/winml_provider_factory.h"
#include "iengine.h"
 
namespace WINMLP {
 
struct LearningModelSession
  : LearningModelSessionT<LearningModelSession, ILearningModelSessionNative, ILearningModelSessionNative1> {
  /* LearningModelSession constructors (MachineLearningContract 1). */
  LearningModelSession(_winml::IEngine* engine);
 
  LearningModelSession(winml::LearningModel const& model);
 
  LearningModelSession(winml::LearningModel const& model, winml::LearningModelDevice const& deviceToRunOn);
 
  /* LearningModelSession constructors (MachineLearningContract 2). */
  LearningModelSession(
    winml::LearningModel const& model,
    winml::LearningModelDevice const& deviceToRunOn,
    winml::LearningModelSessionOptions const& sessionOptions
  );
 
  /* IClosable methods. */
  void Close();
 
  /* LearningModelSession properties (MachineLearningContract 1). */
  wfc::IPropertySet EvaluationProperties();
 
  winml::LearningModel Model();
 
  winml::LearningModelDevice Device();
 
  /* LearningModelSession methods (MachineLearningContract 1). */
  winml::LearningModelEvaluationResult Evaluate(winml::LearningModelBinding binding, hstring const& correlationId);
 
  wf::IAsyncOperation<winml::LearningModelEvaluationResult> EvaluateAsync(
    winml::LearningModelBinding binding, hstring const correlationId
  );
 
  winml::LearningModelEvaluationResult EvaluateFeatures(
    wfc::IMap<hstring, wf::IInspectable> const features, hstring const correlationId
  );
 
  wf::IAsyncOperation<winml::LearningModelEvaluationResult> EvaluateFeaturesAsync(
    wfc::IMap<hstring, wf::IInspectable> const features, hstring const correlationId
  );
 
  STDMETHOD(GetIntraOpNumThreads)
  (uint32_t* numThreads);
 
  STDMETHOD(GetIntraOpThreadSpinning)
  (boolean* allowSpinning);
 
 public:
  /* Non-ABI methods */
 
  _winml::IEngine* GetEngine();
 
  void CheckClosed();
 
  // LearningModelBinding needs to leverage the lock
  CWinMLLock* GetDMLEPLock() { return &dml_ep_lock_; }
 
  static winml::LearningModelSession CreateInertSession(_winml::IEngine* engine);
 
  winml::LearningModelSessionOptions Options();
 
 private:
  void Initialize();
 
  _winml::IModel* GetOptimizedModel();
 
  _winml::IModel* GetOptimizedModel(bool should_close_model);
 
  uint64_t Run(winrt::com_ptr<winmlp::LearningModelBinding> bindingImpl);
 
  winml::LearningModelEvaluationResult GetResults(
    winrt::com_ptr<winmlp::LearningModelBinding> bindingImpl, hstring const& correlationId, uint64_t fenceValueForDML
  );
 
  void ApplyEvaluationProperties();
 
  void ToggleProfiler();
 
 private:
  com_ptr<_winml::IEngineFactory> engine_factory_;
  com_ptr<_winml::IEngine> engine_;
 
  using MLOperatorRegistry = std::unique_ptr<IMLOperatorRegistry, void (*)(IMLOperatorRegistry*)>;
  MLOperatorRegistry operator_registry_;
 
  winml::LearningModel model_;
  winml::LearningModelDevice device_;
  winml::LearningModelSessionOptions session_options_;
  wfc::IPropertySet evaluation_properties_;
 
  // Synchronization
  CWinMLLock session_creation_lock_;
  CWinMLLock dml_ep_lock_;
};
 
}  // namespace WINMLP
 
namespace WINML::factory_implementation {
 
struct LearningModelSession : LearningModelSessionT<LearningModelSession, implementation::LearningModelSession> {};
 
}  // namespace WINML::factory_implementation