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

Function UpdateStats

tensorflow/core/common_runtime/eager/kernel_and_device.cc:198–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196
197namespace {
198void UpdateStats(OpKernelContext* context,
199 StepStatsCollector* step_stats_collector,
200 NodeExecStats* stats) {
201 for (const auto& allocator_pair : context->ConsumeWrappedAllocators()) {
202 AllocatorMemoryUsed* memory = stats->add_memory();
203 memory->set_allocator_name(allocator_pair.first->Name());
204 auto sizes = allocator_pair.second->GetSizes();
205 memory->set_total_bytes(std::get<0>(sizes));
206 memory->set_peak_bytes(std::get<1>(sizes));
207 memory->set_live_bytes(std::get<2>(sizes));
208
209 absl::optional<AllocatorStats> allocator_stats =
210 allocator_pair.first->GetStats();
211 if (allocator_stats) {
212 memory->set_allocator_bytes_in_use(allocator_stats->bytes_in_use);
213 }
214 allocator_pair.second->GetRecordsAndUnRef();
215 }
216 auto* ms = stats->mutable_memory_stats();
217 ms->set_temp_memory_size(context->temp_memory_allocated());
218 for (const auto& alloc_id : context->persistent_alloc_ids()) {
219 ms->mutable_persistent_tensor_alloc_ids()->Add(alloc_id);
220 }
221
222 ms->set_persistent_memory_size(context->persistent_memory_allocated());
223 step_stats_collector->Finalize();
224}
225
226// In certain contexts (e.g. TPU async executions), the CancellationManager is
227// used to shut down the device in error scenarios (as opposed to using the

Callers 1

RunMethod · 0.70

Calls 10

GetRecordsAndUnRefMethod · 0.80
temp_memory_allocatedMethod · 0.80
persistent_alloc_idsMethod · 0.80
NameMethod · 0.45
GetSizesMethod · 0.45
GetStatsMethod · 0.45
AddMethod · 0.45
FinalizeMethod · 0.45

Tested by

no test coverage detected