MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / get_profile_func

Function get_profile_func

python/oneflow/test/gen_ops_process.py:83–106  ·  view source on GitHub ↗

Iterate through files under `path` to find out all operator names, and update code links to file_func_map_list by file_func_map.

(path)

Source from the content-addressed store, hash-verified

81
82
83def get_profile_func(path):
84 """
85 Iterate through files under `path` to find out all operator names,
86 and update code links to file_func_map_list by file_func_map.
87 """
88 files = os.listdir(path)
89 commit_bytes = subprocess.check_output(["git", "rev-parse", "HEAD"])
90 commit_str = commit_bytes.decode("utf-8").replace("\n", "")
91 result_profile_func_list = []
92 for file in files:
93 if file != "log" and not os.path.isdir(file) and file.find("__pycache__") == -1:
94 f = open(os.path.join(path, file))
95 last_line = ""
96 iter_f = iter(f)
97 line_num = 1
98 for line in iter_f:
99 line = line.strip()
100 match = re.fullmatch(r"^@profile\((.+)\)$", line)
101 if match:
102 tem_profile = match.group(1)
103 tem_profile_name = tem_profile.split(".")[-1]
104 result_profile_func_list.append(tem_profile_name)
105
106 return result_profile_func_list
107
108
109def get_test_func(path):

Callers 1

gen_ops_process.pyFile · 0.85

Calls 6

decodeMethod · 0.80
findMethod · 0.80
joinMethod · 0.80
splitMethod · 0.80
check_outputMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected