Skip displaying memory usage info when it's not supported on a platform to avoid confusion.
PiperOrigin-RevId: 305427570 Change-Id: I6bc08b475674294dfb74f4c5891de210a6cafb9c
This commit is contained in:
parent
c6667ea3f2
commit
487fba8ca6
tensorflow/lite
@ -26,7 +26,13 @@ namespace memory {
|
||||
|
||||
const int MemoryUsage::kValueNotSet = 0;
|
||||
|
||||
// TODO(b/139812778): Support to retrieve memory usage on other platforms.
|
||||
bool MemoryUsage::IsSupported() {
|
||||
#ifdef __linux__
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
MemoryUsage GetMemoryUsage() {
|
||||
MemoryUsage result;
|
||||
#ifdef __linux__
|
||||
|
@ -25,6 +25,10 @@ namespace memory {
|
||||
struct MemoryUsage {
|
||||
static const int kValueNotSet;
|
||||
|
||||
// Indicates whether obtaining memory usage is supported on the platform, thus
|
||||
// indicating whether the values defined in this struct make sense or not.
|
||||
static bool IsSupported();
|
||||
|
||||
MemoryUsage()
|
||||
: max_rss_kb(kValueNotSet),
|
||||
total_allocated_bytes(kValueNotSet),
|
||||
|
@ -60,6 +60,14 @@ TEST(MemoryUsage, GetMemoryUsage) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(MemoryUsage, IsSupported) {
|
||||
#ifdef __linux__
|
||||
EXPECT_TRUE(MemoryUsage::IsSupported());
|
||||
#else
|
||||
EXPECT_FALSE(MemoryUsage::IsSupported());
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace memory
|
||||
} // namespace profiling
|
||||
} // namespace tflite
|
||||
|
@ -55,6 +55,7 @@ void BenchmarkLoggingListener::OnBenchmarkEnd(const BenchmarkResults& results) {
|
||||
<< "Warmup (avg): " << warmup_us.avg() << ", "
|
||||
<< "Inference (avg): " << inference_us.avg();
|
||||
|
||||
if (!init_mem_usage.IsSupported()) return;
|
||||
TFLITE_LOG(INFO)
|
||||
<< "Note: as the benchmark tool itself affects memory footprint, the "
|
||||
"following is only APPROXIMATE to the actual memory footprint of the "
|
||||
|
Loading…
Reference in New Issue
Block a user