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

Method get_allocator

tensorflow/core/framework/op_kernel.cc:317–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315}
316
317Allocator* OpKernelContext::get_allocator(AllocatorAttributes attr) {
318 Allocator* allocator = nullptr;
319 if (TF_PREDICT_FALSE(attr.scope_id > 0)) {
320 allocator = params_->device->GetScopedAllocator(attr, step_id());
321 CHECK(allocator);
322 } else {
323 allocator = params_->device->GetAllocator(attr);
324 }
325 if (TF_PREDICT_FALSE(track_allocations())) {
326 mutex_lock lock(mu_);
327 for (const auto& wrapped : wrapped_allocators_) {
328 if (wrapped.first == allocator) {
329 return wrapped.second;
330 }
331 }
332 TrackingAllocator* wrapped_allocator =
333 new TrackingAllocator(allocator, params_->track_allocations);
334 wrapped_allocators_.push_back(std::make_pair(allocator, wrapped_allocator));
335 return wrapped_allocator;
336 } else {
337 return allocator;
338 }
339}
340
341void OpKernelContext::SetStatus(const Status& status) {
342 status_.Update(status);

Callers 6

ComputeMethod · 0.80
ComputeMethod · 0.80
ComputeMethod · 0.80
ComputeMethod · 0.80
ReshapeGPUFunction · 0.80
TF_AllocateOutputFunction · 0.80

Calls 3

GetScopedAllocatorMethod · 0.45
GetAllocatorMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected