| From e8c07c006869046296f8fc0372547afb7db2a049 Mon Sep 17 00:00:00 2001 | |
| From: TFLite Patcher <tflite@localhost> | |
| Date: Fri, 18 Oct 2024 18:08:07 +0800 | |
| Subject: [PATCH] Fix cpuinfo on some AMD model | |
| PATCH_NAME=ruy-amd-cpu | |
| --- | |
| tensorflow/workspace2.bzl | 1 + | |
| third_party/cpuinfo.patch | 16 ++++++++++++++++ | |
| 2 files changed, 17 insertions(+) | |
| create mode 100644 third_party/cpuinfo.patch | |
| diff --git a/tensorflow/workspace2.bzl b/tensorflow/workspace2.bzl | |
| index 23b438ec..1e099870 100644 | |
| --- a/tensorflow/workspace2.bzl | |
| +++ b/tensorflow/workspace2.bzl | |
| @@ -172,6 +172,7 @@ def _tf_repositories(): | |
| tf_http_archive( | |
| name = "cpuinfo", | |
| strip_prefix = "cpuinfo-ef634603954d88d2643d5809011288b890ac126e", | |
| + patch_file = ["//third_party:cpuinfo.patch"], | |
| sha256 = "e07512a11e1c71687359a133f49d60583d7465b737fe5dbe11f461c9aaa72a2b", | |
| urls = tf_mirror_urls("https://github.com/pytorch/cpuinfo/archive/ef634603954d88d2643d5809011288b890ac126e.zip"), | |
| ) | |
| diff --git a/third_party/cpuinfo.patch b/third_party/cpuinfo.patch | |
| new file mode 100644 | |
| index 00000000..290947ed | |
| --- /dev/null | |
| +++ b/third_party/cpuinfo.patch | |
| @@ -0,0 +1,16 @@ | |
| +diff --git a/src/x86/init.c b/src/x86/init.c | |
| +index 244359c..653f1ee 100644 | |
| +--- a/src/x86/init.c | |
| ++++ b/src/x86/init.c | |
| +@@ -38,8 +38,10 @@ void cpuinfo_x86_init_processor(struct cpuinfo_x86_processor* processor) { | |
| + /* | |
| + * Topology extensions support: | |
| + * - AMD: ecx[bit 22] in extended info (reserved bit on Intel CPUs). | |
| ++ * Relax the condition a bit for Excavator, see b/305999585#comment11 for more details. | |
| + */ | |
| +- const bool amd_topology_extensions = !!(leaf0x80000001.ecx & UINT32_C(0x00400000)); | |
| ++ const bool amd_topology_extensions = | |
| ++ !!(leaf0x80000001.ecx & UINT32_C(0x00400000)) || uarch == cpuinfo_uarch_excavator; | |
| + | |
| + cpuinfo_x86_detect_cache( | |
| + max_base_index, max_extended_index, amd_topology_extensions, vendor, &model_info, | |
| -- | |
| 2.47.0.rc1.288.g06298d1525-goog | |