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

Function CheckStats

tensorflow/core/framework/allocator_test.cc:28–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26namespace tensorflow {
27
28static void CheckStats(Allocator* a, int64 num_allocs, int64 bytes_in_use,
29 int64 peak_bytes_in_use, int64 largest_alloc_size) {
30 absl::optional<AllocatorStats> stats = a->GetStats();
31 //EXPECT_TRUE(stats);
32 if (!stats) {
33 return;
34 }
35 LOG(INFO) << "Alloc stats: \n" << stats->DebugString();
36#if defined(PLATFORM_GOOGLE) && defined(NDEBUG)
37 // NOTE: allocator stats expectation depends on the system malloc,
38 // and can vary as that changes.
39 static const int64 kSlop = 5 * 1024;
40 EXPECT_GT(stats->bytes_in_use, bytes_in_use - kSlop);
41 EXPECT_LT(stats->bytes_in_use, bytes_in_use + kSlop);
42 EXPECT_GT(stats->peak_bytes_in_use, peak_bytes_in_use - kSlop);
43 EXPECT_LT(stats->peak_bytes_in_use, peak_bytes_in_use + kSlop);
44 EXPECT_EQ(stats->num_allocs, num_allocs);
45 EXPECT_EQ(stats->largest_alloc_size, largest_alloc_size);
46#endif
47}
48
49TEST(AllocatorAttributesTest, AllCombos) {
50 for (bool on_host : {false, true}) {

Callers 1

TESTFunction · 0.70

Calls 2

GetStatsMethod · 0.45
DebugStringMethod · 0.45

Tested by

no test coverage detected