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

Function TEST

tensorflow/core/common_runtime/mkl_cpu_allocator_test.cc:26–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24namespace tensorflow {
25
26TEST(MKLBFCAllocatorTest, TestMaxLimit) {
27 setenv(MklCPUAllocator::kMaxLimitStr, "1000", 1);
28 MklCPUAllocator a;
29 TF_EXPECT_OK(a.Initialize());
30 auto stats = a.GetStats();
31 EXPECT_EQ(stats->bytes_limit, 1000);
32
33 unsetenv(MklCPUAllocator::kMaxLimitStr);
34 TF_EXPECT_OK(a.Initialize());
35 stats = a.GetStats();
36 uint64 max_mem_bytes = MklCPUAllocator::kDefaultMaxLimit;
37#if defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
38 max_mem_bytes =
39 (uint64)sysconf(_SC_PHYS_PAGES) * (uint64)sysconf(_SC_PAGESIZE);
40#endif
41 EXPECT_EQ(stats->bytes_limit, max_mem_bytes);
42
43 setenv(MklCPUAllocator::kMaxLimitStr, "wrong-input", 1);
44 EXPECT_TRUE(errors::IsInvalidArgument(a.Initialize()));
45
46 setenv(MklCPUAllocator::kMaxLimitStr, "-20", 1);
47 EXPECT_TRUE(errors::IsInvalidArgument(a.Initialize()));
48}
49
50} // namespace tensorflow
51

Callers

nothing calls this directly

Calls 4

setenvFunction · 0.50
unsetenvFunction · 0.50
InitializeMethod · 0.45
GetStatsMethod · 0.45

Tested by

no test coverage detected