-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_taffo_errors.py
69 lines (54 loc) · 2 KB
/
get_taffo_errors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import os
import re
def extract_name_num(text):
# Regular expression pattern to match the number
pattern = r"Computed\serror\sfor\starget\s(\w+):\s(\d+.\d+e[\+\-]\d+)"
# Search for the pattern in the input text
match = re.search(pattern, text)
if match:
return (match.group(1), match.group(2))
else:
return None
def process_files(filename):
result = []
# Get the current working directory
current_path = os.getcwd()
# Function to process each file and update the result array
def process_file(file_path):
with open(file_path, 'r') as file:
lines = file.readlines()
current_dict = {}
current_dict["Test"] = file_path[-80:]
for line in lines:
res = extract_name_num(line.strip())
if res != None:
current_dict[res[0]] = res[1]
if current_dict and len(current_dict.keys()) > 1:
result.append(current_dict)
# Walk through all directories and subdirectories
for root, _, files in os.walk(current_path):
for file in files:
if file == filename:
file_path = os.path.join(root, file)
if "_outside_conv" not in file_path:
process_file(file_path)
return result
filename_to_find_opt = "taffo_err_log.txt"
results = process_files(filename_to_find_opt)
print("\n\n----> Errors:")
def fix_name(res):
name_tokens = res['Test'].split('\\')
name = name_tokens[-2]
if name_tokens[-3] != 'Tests':
name = name_tokens[-3] + '(' + name + ')'
name = name.replace('Compute', '')
name = name.replace('FromPanda_mm_float_inside_opt', 'MatrixProduct')
res['Test'] = name
for res in results:
fix_name(res)
def print_dictionary(dictionary):
formatted_items = [f"{key}: {value}" for key, value in dictionary.items()]
formatted_string = ", ".join(formatted_items)
print(formatted_string)
for res in results:
print_dictionary(res)