|
10 | 10 |
|
11 | 11 |
|
12 | 12 | def patch_fix_RoundToNearest(tf_version: str, tf_src_root: str): |
13 | | - if tf_version not in ['2.11.0', '2.11.1']: |
| 13 | + if tf_version not in ['2.11.0', '2.11.1', '2.12.0']: |
14 | 14 | print(f"warning: skip applying `patch_fix_RoundToNearest` to tf version `{tf_version}`") |
15 | 15 | return |
16 | 16 |
|
@@ -38,8 +38,31 @@ def patch_fix_RoundToNearest(tf_version: str, tf_src_root: str): |
38 | 38 | dst.truncate(0) |
39 | 39 | dst.write(fixed.getvalue()) |
40 | 40 |
|
41 | | -patches = [patch_fix_RoundToNearest] |
| 41 | +def patch_compiling_telemetry_cc(tf_version: str, tf_src_root: str): |
| 42 | + if tf_version not in ['2.12.0']: |
| 43 | + print(f"warning: skip applying `patch_compiling_telemetry_cc` to tf version `{tf_version}`") |
| 44 | + return |
| 45 | + |
| 46 | + cmakelists_txt = Path(tf_src_root) / 'CMakeLists.txt' |
| 47 | + fixed = StringIO() |
| 48 | + patched_1 = False |
| 49 | + with open(cmakelists_txt, 'r') as source: |
| 50 | + for line in source: |
| 51 | + line_strip = line.strip() |
| 52 | + if not patched_1 and line_strip == '${TFLITE_SOURCE_DIR}/profiling/telemetry/profiler.cc': |
| 53 | + fixed.write(f" {line_strip} # fixed\n") |
| 54 | + fixed.write(" ${TFLITE_SOURCE_DIR}/profiling/telemetry/telemetry.cc\n") |
| 55 | + patched_1 = True |
| 56 | + else: |
| 57 | + fixed.write(line) |
| 58 | + |
| 59 | + if patched_1: |
| 60 | + with open(cmakelists_txt, 'w') as dst: |
| 61 | + dst.truncate(0) |
| 62 | + dst.write(fixed.getvalue()) |
| 63 | + |
42 | 64 |
|
| 65 | +patches = [patch_fix_RoundToNearest, patch_compiling_telemetry_cc] |
43 | 66 |
|
44 | 67 | if __name__ == '__main__': |
45 | 68 | tf_version = None |
|
0 commit comments