-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcosim_excut.py
More file actions
69 lines (62 loc) · 3.17 KB
/
Copy pathcosim_excut.py
File metadata and controls
69 lines (62 loc) · 3.17 KB
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
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import subprocess
import time
if __name__ == "__main__":
print "start TF COSIM test"
eigen_dir = sys.argv[1]
mkldnn_dir = sys.argv[2]
eigen_dir_layer = sys.argv[3]
cmd_flag = 1
#cmd = 'python general_cosim.py -e ../../data/resnet/dummy/data_dump_eigen_step11/ -m ../../data/resnet/dummy/data_dump_mkldnn_step11/ -l ../../data/resnet/dummy/data_dump_eigen_step11/layers.txt'
while (cmd_flag):
cmd = 'python general_cosim.py -e ' + eigen_dir + ' -m ' + mkldnn_dir + ' -l ' + eigen_dir_layer + ' 1>>result.out 2>>result.err'
cmd_flag = subprocess.call(cmd, shell=True)
if (cmd_flag == 1):
with open("result.err") as fp:
line_list = fp.readline()
while line_list:
per_line_list = line_list.split()
for single_per_line_list in per_line_list:
if (single_per_line_list == "node"):
slash_line_list = per_line_list[5].split('/')
for single_slash_line_list in slash_line_list:
if (single_slash_line_list == "Direction_Session"):
ban_layer = per_line_list[5]
break
line_list = fp.readline()
ban_layer_list = ban_layer.split('/')
reorganization_ban_layer_line = ''
ban_flag = 0
for single_ban_layer_list in ban_layer_list:
if (single_ban_layer_list == "v"):
ban_flag = ban_flag + 1
if (ban_flag == 1):
reorganization_ban_layer_line = 'Direction_Session/' + single_ban_layer_list
continue
reorganization_ban_layer_line = reorganization_ban_layer_line + '#' + single_ban_layer_list
reorganization_ban_layer_line = reorganization_ban_layer_line + '.dat\n'
#print "reorganization_ban_layer_line-----", reorganization_ban_layer_line
#with open(eigen_dir_layer) as fs:
with open('test_layers.txt') as fs:
layer_line_list = fs.readlines()
layer_num = 0
for each in layer_line_list:
#print "reorganization_ban_layer_line-----", reorganization_ban_layer_line
if (each == reorganization_ban_layer_line):
layer_line_list[layer_num] = '#' + reorganization_ban_layer_line
#print "ban_layer ----", layer_line_list[layer_num]
with open('new_layers.txt', 'w') as ft:
ft.writelines(layer_line_list)
break
layer_num = layer_num + 1
with open('result.err', 'r') as f1:
with open('result.txt', 'a') as f2:
f2.write('\n')
f2.write(f1.read())
rm_cmd = subprocess.call("rm result.err result.out", shell=True)
cp_cmd = subprocess.call("cp new_layers.txt test_layers.txt", shell=True)
else:
cmd_flag = 0