Skip to content

Conversation

@fangfangssj
Copy link
Contributor

@fangfangssj fangfangssj commented Nov 20, 2025

PR Category

Feature Enhancement

Description

添加高频子图序列提取脚本
运行命令 python split_points.py --models ./samples/torchvision/resnet18 ./samples/torchvision/resnet34
下图为windows为10时,测试的结果

7870033a7f099a57518fc22885e62ac6

@paddle-bot
Copy link

paddle-bot bot commented Nov 20, 2025

Thanks for your contribution!

@paddle-bot paddle-bot bot added the contributor External developers label Nov 20, 2025
token_tensor[start:end]
for consecutive_tensor in consecutive_tensors
for start, end in [get_range(int(consecutive_tensor.size(0)))]
for start, end in [get_range(len(consecutive_tensor))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

之前的语义是已知consecutive_tensor 是个 1D的 tensor,其 size(0)其实就是这个张量的长度。
后面的代码看起来意思是一样的,这么改的原因是啥呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TypeError: 'int' object is not callable
这里语义上是tensor,但是实际上是一个np的数组,这样调用是有问题的

@lixinqi
Copy link
Collaborator

lixinqi commented Nov 20, 2025

PR Category

Feature Enhancement

Description

添加高频子图序列提取脚本 下图为windows为10时,测试的结果 7870033a7f099a57518fc22885e62ac6

这个图里的用法不是真实情况。应该是一下子塞入 resnet18 和 resnet34,综合两个计算图的情况来抽取高频子图

Comment on lines +157 to +168
inputs = []
valid_model_names = []

for model_path in args.models:
seq = extract_ops_via_compile(model_path, args.device)
inputs.append(seq)
valid_model_names.append(os.path.basename(model_path))

rp_parser = RpExprParser(
window_size=args.window, fold_policy="default", fold_times=0
)
rp_expr, token_id2primitive_id = rp_parser(inputs)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里就是把计算图一起输入的,并不是单个分开输入

description="Extract graph patterns and split points from multiple models."
)
parser.add_argument(
"--models",
Copy link
Collaborator

Choose a reason for hiding this comment

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

这种调用方式并不方便。改成 model-dirs-file。从文本里读取多个 model_path

help="List of paths to model directories (e.g. --models path/to/m1 path/to/m2)",
)
parser.add_argument("--device", type=str, default="cuda")
parser.add_argument("--window", type=int, default=10)
Copy link
Collaborator

Choose a reason for hiding this comment

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

add argument output_split_points.
put results into output_split_points file with scheme like
<model-path> <space> 3,5,7

@lixinqi
Copy link
Collaborator

lixinqi commented Nov 20, 2025

todo things:

  1. Refactor test/split_points.py according to aforementioned comments.
  2. call naive decomposer for each model_path and split_points. see test/naive_graph_decomposer_test.sh for details
  3. draw ES plot by RangeDecomposerValidator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants