forked from ucb-bar/gemmini
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_errors.py
37 lines (33 loc) · 1.29 KB
/
extract_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
import numpy as np
import argparse
def extract_error_lines(file_path):
try:
# Open the file in read mode
with open(file_path, 'r') as file:
# Iterate over each line in the file
for line in file:
# Check if the line starts with one of the specified error strings
if (line.startswith("Mean Absolute Error") or
line.startswith("Mean Squared Error") or
line.startswith("Maximum Absolute Error") or
line.startswith("Gemmini conv took") or
line.startswith("Gemmini matmul took") or
line.startswith("Flattening weights took") or
line.startswith("Error compuation took")):
# Print the matching line
print(line.strip())
except FileNotFoundError:
print(f"Error: The file '{file_path}' was not found.")
except Exception as e:
print(f"An error occurred: {e}")
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument('--input_file', default="tmp.txt", type=str)
return parser.parse_args()
# Main function
def main():
args = get_args()
extract_error_lines(args.input_file)
# Run the main function
if __name__ == "__main__":
main()