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

Method DeallocateRaw

tensorflow/core/framework/tracking_allocator.cc:122–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122void TrackingAllocator::DeallocateRaw(void* ptr) {
123 // freeing a null ptr is a no-op
124 if (nullptr == ptr) {
125 return;
126 }
127 bool should_delete;
128 // fetch the following outside the lock in case the call to
129 // AllocatedSize is slow
130 bool tracks_allocation_sizes = allocator_->TracksAllocationSizes();
131 size_t allocated_bytes = 0;
132 if (tracks_allocation_sizes) {
133 allocated_bytes = allocator_->AllocatedSize(ptr);
134 } else if (track_sizes_locally_) {
135 mutex_lock lock(mu_);
136 auto itr = in_use_.find(ptr);
137 if (itr != in_use_.end()) {
138 tracks_allocation_sizes = true;
139 allocated_bytes = (*itr).second.allocated_size;
140 in_use_.erase(itr);
141 }
142 }
143 Allocator* allocator = allocator_;
144 {
145 mutex_lock lock(mu_);
146 if (tracks_allocation_sizes) {
147 CHECK_GE(allocated_, allocated_bytes);
148 allocated_ -= allocated_bytes;
149 allocations_.emplace_back(-allocated_bytes, Env::Default()->NowMicros());
150 }
151 should_delete = UnRef();
152 }
153 allocator->DeallocateRaw(ptr);
154 if (should_delete) {
155 delete this;
156 }
157}
158
159void TrackingAllocator::DeallocateRawAsync(void* ptr) {
160 // freeing a null ptr is a no-op

Callers 15

TESTFunction · 0.45
FreeMethod · 0.45
FreeMethod · 0.45
FreeMethod · 0.45
TESTFunction · 0.45
BM_AllocationFunction · 0.45
DeallocateMethod · 0.45
DeallocateMethod · 0.45
SaveMethod · 0.45
DeallocateMethod · 0.45
DeallocateMethod · 0.45
deallocateMethod · 0.45

Calls 8

DefaultFunction · 0.85
TracksAllocationSizesMethod · 0.45
AllocatedSizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
emplace_backMethod · 0.45
NowMicrosMethod · 0.45

Tested by 3

TESTFunction · 0.36
TESTFunction · 0.36
BM_AllocationFunction · 0.36