|
|
|
@ -24,6 +24,20 @@ from . import utils
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def split_with_json(json_str, flags_str):
|
|
|
|
|
"""
|
|
|
|
|
根据JSON字符串分割GraphKernel
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
json_str (str): 包含GraphKernel描述的JSON字符串。
|
|
|
|
|
flags_str (str): 包含分割标志的JSON字符串。
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
str: 包含分割结果的JSON字符串。
|
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
jd.JSONDecodeError: 如果json_str或flags_str无法被解析为JSON格式,将引发此异常。
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
"""Call cost model to split GraphKernel"""
|
|
|
|
|
try:
|
|
|
|
|
graph_desc = json.loads(json_str)
|
|
|
|
@ -45,6 +59,21 @@ def split_with_json(json_str, flags_str):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _reset_graphmode_for_inplaceassign(graph_list, graph_mode):
|
|
|
|
|
"""
|
|
|
|
|
重置具有 InplaceAssign 操作符的图模式。
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
graph_list (list): 包含图的列表,每个图都是一个包含操作描述的字典。
|
|
|
|
|
graph_mode (list): 图模式列表,每个元素表示对应图的模式。
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
None
|
|
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
|
具有 InplaceAssign 操作符的操作应始终为复合操作。
|
|
|
|
|
对于包含 InplaceAssign 操作符的图,将其模式设置为 'composite'。
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
"""Operator with InplaceAssign should always be composite op"""
|
|
|
|
|
for i, g in enumerate(graph_list):
|
|
|
|
|
if any((op['name'] == 'InplaceAssign' for op in g['op_desc'])):
|
|
|
|
@ -52,6 +81,20 @@ def _reset_graphmode_for_inplaceassign(graph_list, graph_mode):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _dump_split_info(flags, graph_json, graph_desc, subgraphs, graph_mode):
|
|
|
|
|
"""
|
|
|
|
|
将分割信息以文本形式输出
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
flags (dict): 包含配置信息的字典
|
|
|
|
|
graph_json (str): 图结构的JSON字符串
|
|
|
|
|
graph_desc (object): 图描述对象
|
|
|
|
|
subgraphs (list): 子图列表
|
|
|
|
|
graph_mode (list): 图模式列表
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
None
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
"""Dump split info as text"""
|
|
|
|
|
if not flags.get("dump_as_text", False):
|
|
|
|
|
return
|
|
|
|
|