forked from Hankpipi/diffusers-hetu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile_read.py
31 lines (25 loc) · 968 Bytes
/
profile_read.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
import pickle
import argparse
def profile(args):
f_read = open(f'profile_{args.filename}.pkl', 'rb')
profile_conv = pickle.load(f_read)
f_read.close()
if args.details:
print(len(profile_conv))
for i in profile_conv:
print(i, profile_conv[i])
else:
profile_conv_group = {}
for i in profile_conv:
if i[1] not in profile_conv_group:
profile_conv_group[i[1]] = profile_conv[i]
else:
profile_conv_group[i[1]] += profile_conv[i]
for i in profile_conv_group:
print(profile_conv_group[i])
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--filename', type=str, default='conv', help='you can choose conv, linear or attention')
parser.add_argument('--details', type=int, default=0, help='see the profile details by setting it to 1')
args = parser.parse_args()
profile(args)