|
| 1 | +diff --git a/tensorflow/core/platform/profile_utils/android_armv7a_cpu_utils_helper.cc b/tensorflow/core/platform/profile_utils/android_armv7a_cpu_utils_helper.cc |
| 2 | +index d61a036181d..cd982a85e42 100644 |
| 3 | +--- tensorflow/core/platform/profile_utils/android_armv7a_cpu_utils_helper.cc |
| 4 | ++++ tensorflow/core/platform/profile_utils/android_armv7a_cpu_utils_helper.cc.new |
| 5 | +@@ -15,7 +15,7 @@ limitations under the License. |
| 6 | + |
| 7 | + #include "tensorflow/core/platform/profile_utils/android_armv7a_cpu_utils_helper.h" |
| 8 | + |
| 9 | +-#if defined(__ANDROID__) && (__ANDROID_API__ >= 21) && \ |
| 10 | ++#if (defined(__ANDROID__) && (__ANDROID_API__ >= 21)) || defined(__linux__) && \ |
| 11 | + (defined(__ARM_ARCH_7A__) || defined(__aarch64__)) |
| 12 | + |
| 13 | + #include <asm/unistd.h> |
| 14 | +diff --git a/tensorflow/core/platform/profile_utils/android_armv7a_cpu_utils_helper.h b/tensorflow/core/platform/profile_utils/android_armv7a_cpu_utils_helper.h |
| 15 | +index 66bc0fd5928..ac2be9af930 100644 |
| 16 | +--- tensorflow/core/platform/profile_utils/android_armv7a_cpu_utils_helper.h |
| 17 | ++++ tensorflow/core/platform/profile_utils/android_armv7a_cpu_utils_helper.h.new |
| 18 | +@@ -22,7 +22,7 @@ limitations under the License. |
| 19 | + #include "tensorflow/core/platform/profile_utils/i_cpu_utils_helper.h" |
| 20 | + #include "tensorflow/core/platform/types.h" |
| 21 | + |
| 22 | +-#if defined(__ANDROID__) && (__ANDROID_API__ >= 21) && \ |
| 23 | ++#if (defined(__ANDROID__) && (__ANDROID_API__ >= 21)) || defined(__linux__) && \ |
| 24 | + (defined(__ARM_ARCH_7A__) || defined(__aarch64__)) |
| 25 | + |
| 26 | + struct perf_event_attr; |
| 27 | +diff --git a/tensorflow/core/platform/profile_utils/cpu_utils.cc b/tensorflow/core/platform/profile_utils/cpu_utils.cc |
| 28 | +index b76b3377397..691154eeaa1 100644 |
| 29 | +--- tensorflow/core/platform/profile_utils/cpu_utils.cc |
| 30 | ++++ tensorflow/core/platform/profile_utils/cpu_utils.cc.new |
| 31 | +@@ -80,6 +80,15 @@ static ICpuUtilsHelper* cpu_utils_helper_instance_ = nullptr; |
| 32 | + // TODO(satok): do not switch by macro here |
| 33 | + #if defined(__ANDROID__) |
| 34 | + return GetCpuUtilsHelperSingletonInstance().CalculateCpuFrequency(); |
| 35 | ++#elif defined(__linux__) && (defined(__ARM_ARCH_7A__) || defined(__aarch64__)) |
| 36 | ++ const int64 freq_n = GetCpuUtilsHelperSingletonInstance().CalculateCpuFrequency(); |
| 37 | ++ // maintain mostly consistent logging with the other linux platforms |
| 38 | ++ if (freq_n < 1) { |
| 39 | ++ LOG(WARNING) << "Failed to get CPU frequency: " << freq_n; |
| 40 | ++ return INVALID_FREQUENCY; |
| 41 | ++ } |
| 42 | ++ LOG(INFO) << "CPU Frequency: " << freq_n << " Hz"; |
| 43 | ++ return freq_n; |
| 44 | + #elif defined(__linux__) |
| 45 | + // Read the contents of /proc/cpuinfo. |
| 46 | + std::ifstream cpuinfo("/proc/cpuinfo"); |
| 47 | +@@ -144,7 +153,7 @@ static ICpuUtilsHelper* cpu_utils_helper_instance_ = nullptr; |
| 48 | + if (cpu_utils_helper_instance_ != nullptr) { |
| 49 | + LOG(FATAL) << "cpu_utils_helper_instance_ is already instantiated."; |
| 50 | + } |
| 51 | +-#if defined(__ANDROID__) && (__ANDROID_API__ >= 21) && \ |
| 52 | ++#if (defined(__ANDROID__) && (__ANDROID_API__ >= 21)) || defined(__linux__) && \ |
| 53 | + (defined(__ARM_ARCH_7A__) || defined(__aarch64__)) |
| 54 | + cpu_utils_helper_instance_ = new AndroidArmV7ACpuUtilsHelper(); |
| 55 | + #else |
0 commit comments