| 315 | } |
| 316 | |
| 317 | Allocator* 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 | |
| 341 | void OpKernelContext::SetStatus(const Status& status) { |
| 342 | status_.Update(status); |
no test coverage detected