MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Init

Method Init

tensorflow/core/common_runtime/tensorpool_allocator.cc:112–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void TensorPoolAllocator::Init() {
113 bool tmp = false;
114 if (initing_.compare_exchange_strong(tmp, true)) {
115 signal(SIGUSR1, signal_handler);
116 auto lifetime_policy = mem_planner_->BestLifetimePolicy();
117 lifetime_policy->Dump();
118
119 alignment_ = lifetime_policy->Alignment();
120 alignment_offset_ = lifetime_policy->AlignmentOffset();
121
122 auto policy_large_bins = lifetime_policy->GetLargeBins();
123 for (auto rit = policy_large_bins.rbegin();
124 rit != policy_large_bins.rend(); ++rit) {
125 auto bin_info = rit->second;
126 auto bin = new Bin(bin_info->BlockSize(), bin_info->ChunkSize(),
127 bin_info->Alignment(), bin_info->VBlocks(),
128 sub_allocator_.get(), this);
129 large_lifetime_bins_.emplace(rit->first, bin);
130 }
131 auto policy_bins = lifetime_policy->GetBins();
132 large_bin_index_ = policy_bins.size();
133 lifetime_bins_.resize(large_bin_index_);
134
135 // create bigger bin first
136 for (auto it = policy_bins.rbegin(); it != policy_bins.rend();
137 ++it) {
138 Bin* bin = nullptr;
139 if ((*it)->BlockSize() > 0 || (*it)->VBlocks().size() > 0) {
140 bin = new Bin((*it)->BlockSize(), (*it)->ChunkSize(),
141 (*it)->Alignment(), (*it)->VBlocks(),
142 sub_allocator_.get(), this);
143 }
144 lifetime_bins_[(*it)->BinIndex()] = bin;
145 }
146 LOG(INFO) << "TensorPoolAllocator enabled";
147 inited_ = true;
148 }
149}
150
151void* TensorPoolAllocator::AllocateRaw(size_t alignment,
152 size_t num_bytes) {

Callers

nothing calls this directly

Calls 13

rbeginMethod · 0.80
rendMethod · 0.80
BestLifetimePolicyMethod · 0.45
DumpMethod · 0.45
AlignmentMethod · 0.45
AlignmentOffsetMethod · 0.45
BlockSizeMethod · 0.45
ChunkSizeMethod · 0.45
getMethod · 0.45
emplaceMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected