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

Method BigAllocate

tensorflow/core/common_runtime/tensorpool_allocator.cc:328–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326}
327
328void* TensorPoolAllocator::BigAllocate(size_t alignment,
329 size_t num_bytes) {
330 auto header_size = std::max(sizeof(Header), alignment);
331 auto total = num_bytes + header_size;
332 if (!inited_.load()) {
333 mem_planner_->TrackAllocate(alignment, total);
334 auto ptr = sub_allocator_->Alloc(alignment, total);
335 return SetDefaultHeader(!inited_.load(), ptr, total, header_size);
336 }
337
338 auto id = Index(total, alignment_, alignment_offset_);
339 if (unlikely(id < 0)) {
340 auto ptr = sub_allocator_->Alloc(alignment, total);
341 return SetDefaultHeader(!inited_.load(), ptr, total, header_size);
342 }
343
344 auto b = GetBin(id);
345 if (unlikely(b == nullptr)) {
346 auto ptr = sub_allocator_->Alloc(alignment, total);
347 return SetDefaultHeader(!inited_.load(), ptr, total, header_size);
348 }
349
350 auto ptr = b->Allocate(total, header_size);
351 if (likely(ptr != nullptr)) {
352 return ptr;
353 }
354 ptr = sub_allocator_->Alloc(alignment, total);
355 return SetDefaultHeader(!inited_.load(), ptr, total, header_size);
356}
357
358// unlikely execute this path which do some atomic operations
359void* TensorPoolAllocator::BigAllocateStatistic(size_t alignment,

Callers

nothing calls this directly

Calls 7

SetDefaultHeaderFunction · 0.85
IndexFunction · 0.70
maxFunction · 0.50
loadMethod · 0.45
TrackAllocateMethod · 0.45
AllocMethod · 0.45
AllocateMethod · 0.45

Tested by

no test coverage detected