Skip to content

Conversation

HeyDavid633
Copy link
Contributor

PR Category

Feature Enhancement

Description

Copy link

paddle-bot bot commented Aug 14, 2025

Thanks for your contribution!


python -m graph_net.torch.typical_sequence /path/to/model_path

输入:已经采集到的 模型的整图,在目录下体现为 6 个文件,核心是 model.py 和 weight_meta.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释部分一律用英文。

@lixinqi
Copy link
Collaborator

lixinqi commented Aug 14, 2025

把 rp expr parser 的工作分出来,单独提 pr,并附上测试代码。


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--model_path", type=str, default="resnet18")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该需要两个参数,src_model_path 和 dst_model_path。不要做原地修改

Comment on lines +111 to +118
# Parse model.py into AST and extract forward function of GraphModule
with open(model_py_path, "r", encoding="utf-8") as f:
source_code = f.read()
module_ast = ast.parse(source_code)
forward_func = find_forward_function(module_ast)

# Extract assignment sequence (simulating FX Graph node flow) from AST
assignments = extract_assignments_from_forward(forward_func)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里肯定不需要用到 ast。那种东西不可靠

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参数列表也不对。
src_model_path 可能是一颗树,这里应该是一个这样的 逻辑:

fx_graphs = [
    fx_graph
    for leaf_model_path in _get_leaf_model_pathes(args.src_model_path)
    for fx_graph in [_get_fx_graph(leaf_model_path)]
]

stmt_token_ids = [
    [
        stmt_token_id
        for node in _get_fx_node(fx_graph)
        for stmt_token_id in [encode_node_to_stmt_token_id(node)]
    ]
    for fx_graph in fx_graphs
]

stmt_token_ids 代替 assignments 传到后面去

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants