| 440 | } |
| 441 | |
| 442 | Status SingleMachine::ClearAllocatorStats() const { |
| 443 | // Cpu_allocator->TracksAllocationSizes() returns true doesn't always mean the |
| 444 | // the AllocatorStats would be collected. |
| 445 | if (!cpu_allocator_stats_enabled_) { |
| 446 | return Status(error::INVALID_ARGUMENT, |
| 447 | "Tracking allocation for CPU is not enabled."); |
| 448 | } |
| 449 | |
| 450 | const DeviceMgr* device_mgr; |
| 451 | TF_RETURN_IF_ERROR(session_->LocalDeviceManager(&device_mgr)); |
| 452 | std::vector<Device*> devices = device_mgr->ListDevices(); |
| 453 | |
| 454 | for (Device* device : devices) { |
| 455 | auto* allocator = device->GetAllocator(AllocatorAttributes()); |
| 456 | if (!allocator->TracksAllocationSizes()) { |
| 457 | return Status(error::INVALID_ARGUMENT, |
| 458 | "Tracking allocation is not enabled."); |
| 459 | } |
| 460 | allocator->ClearStats(); |
| 461 | } |
| 462 | return Status::OK(); |
| 463 | } |
| 464 | |
| 465 | } // namespace grappler |
| 466 | } // namespace tensorflow |
nothing calls this directly
no test coverage detected