-
Notifications
You must be signed in to change notification settings - Fork 25
Add Typical sequence #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Add Typical sequence #188
Conversation
Thanks for your contribution! |
|
||
python -m graph_net.torch.typical_sequence /path/to/model_path | ||
|
||
输入:已经采集到的 模型的整图,在目录下体现为 6 个文件,核心是 model.py 和 weight_meta.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注释部分一律用英文。
把 rp expr parser 的工作分出来,单独提 pr,并附上测试代码。 |
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--model_path", type=str, default="resnet18") |
There was a problem hiding this comment.
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。不要做原地修改
# 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里肯定不需要用到 ast。那种东西不可靠
There was a problem hiding this comment.
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
传到后面去
PR Category
Feature Enhancement
Description