Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#pragma once
 
#include <unordered_map>
#include <core/common/inlined_containers.h>
#include "tensor_allocator.h"
#include "mem_pattern.h"
#include "ort_value_pattern_planner.h"
#include "utils.h"
 
namespace onnxruntime {
class ExecutionProviders;
 
class SimpleTensorAllocator : public ITensorAllocator {
 private:
  MemoryPatternGroup mem_patterns_;
  const ExecutionPlanBase& seq_plan_;
 
 public:
  SimpleTensorAllocator(const ExecutionPlanBase& execution_plan, const SessionState& session_state,
                        InlinedVector<BufferUniquePtr>& /*weights_buffers*/)
      : ITensorAllocator(session_state),
        seq_plan_(execution_plan) {}
 
  common::Status FinalizePlan(InlinedHashMap<OrtDevice, size_t>& planned_memory_sizes_in_byte) override {
    // There is no memory plan to allocate a big block of memory, so
    // planned memory sizes in different locations are all empty.
    planned_memory_sizes_in_byte.clear();
    return Status::OK();
  }
  common::Status GetPreallocatedBuffer(int ort_value_index, const std::string& name, std::optional<MemBuffer>& buf_out,
                                       AllocatorPtr& alloc_out) override;
  common::Status Trace(int id, const ONNX_NAMESPACE::TensorProto* value) override;
  const MemoryPatternGroup& GetMemPatterns() override {
    return mem_patterns_;
  }
};
}  // namespace onnxruntime