Исходный код СУБД 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#pragma once
 
#include "core/common/status.h"
#include "core/framework/allocator.h"
#include "core/session/onnxruntime_c_api.h"
 
namespace onnxruntime {
namespace ep_allocator_utils {
 
// Creates a plugin EP allocator using OrtEp::CreateAllocator when available, otherwise OrtEpFactory::CreateAllocator
// when available, and wraps the result as an IAllocator. Returns a null allocator if neither callback is implemented.
// Outputs are modified only on success.
Status CreateAndWrapEpAllocator(OrtEp* ep,
                                OrtEpFactory& ep_factory,
                                const OrtMemoryInfo& memory_info,
                                const OrtKeyValuePairs* ep_factory_allocator_options,
                                AllocatorPtr& allocator_out,
                                OrtAllocator** raw_allocator_out = nullptr);
 
// Creates a plugin EP allocator using OrtEpFactory::CreateAllocator when available and wraps the result as an
// IAllocator. Returns a null allocator if the callback is not implemented.
// Outputs are modified only on success.
inline Status CreateAndWrapEpAllocator(OrtEpFactory& ep_factory,
                                       const OrtMemoryInfo& memory_info,
                                       const OrtKeyValuePairs* ep_factory_allocator_options,
                                       AllocatorPtr& allocator_out,
                                       OrtAllocator** raw_allocator_out = nullptr) {
  return CreateAndWrapEpAllocator(/*ep*/ nullptr, ep_factory, memory_info, ep_factory_allocator_options,
                                  allocator_out, raw_allocator_out);
}
 
}  // namespace ep_allocator_utils
}  // namespace onnxruntime