-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[SOT][Faster Guard] add FasterStringifiedExpression #69353
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
for (size_t i = 0; i < shape.size(); ++i) { | ||
if (py::isinstance<py::int_>(shape[i])) { | ||
_expected[i] = std::make_optional(shape[i].cast<int64_t>()); | ||
} |
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.
else 是 None
是么?
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.
这块主要是针对SombolcInt,现在只要不是整数都被当成动态shape了,没有做其他类型的检查
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.
那在构造的时候需要小心传入 -1,会产生奇怪的问题,或者直接不允许 -1(负数)
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.
done
python/paddle/jit/sot/opcode_translator/executor/variables/basic.py
Outdated
Show resolved
Hide resolved
self.faster_guard = faster_guard | ||
if ENV_SOT_ENABLE_FASTER_GUARD: | ||
original_expr_template = expr_template | ||
guard_name = f"guard_check_{id(faster_guard)}" |
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.
名字里是否可以表明 guard 类型?这样生成的 guard 更具可读性些~
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.
[Cache]: Cache miss, Guard is
lambda frame: (___t_1 := (len((___t_0 := (frame.f_locals['input'])).shape) == 4)) and (___t_2 := (___t_0.shape[0] == 32)) and (___t_3 := (___t_0.shape[1] == 16)) and (___t_4 := (___t_0.shape[2] == 176)) and (___t_5 := (___t_0.shape[3] == 176)) and (___t_6 := (___t_0.dtype == paddle.core.DataType(10))) and (___t_7 := (___t_0.stop_gradient == False)) and (___t_15 := (id(type((___t_14 := ((___t_13 := ((___t_12 := ((___t_11 := ((___t_10 := ((___t_9 := ((___t_8 := (frame.f_locals['self']))._sub_layers))['0'])).__call__)).__globals__['in_to_static_mode'])).__globals__['global_var']))._in_to_static_mode_)))) == 94911584974496)) and (___t_16 := (___t_14 == False)) and (___t_18 := (isinstance((___t_17 := (___t_10._forward_pre_hooks)), dict))) and (___t_19 := (len(___t_17) == 0)) and (___t_21 := (isinstance((___t_20 := (___t_10._forward_post_hooks)), dict))) and (___t_22 := (len(___t_20) == 0)) and (___t_24 := (id(type((___t_23 := (___t_10._built)))) == 94911584974496)) and (___t_25 := (___t_23 == False)) and (___t_28 := (id(type((___t_27 := ((___t_26 := (___t_11.__globals__['in_profiler_mode'])).__globals__['_is_profiler_used'])))) == 94911584974496)) and (___t_29 := (___t_27 == False)) and (___t_32 := (isinstance((___t_31 := ((___t_30 := (___t_10.dw_conv))._forward_pre_hooks)), dict))) and (___t_33 := (len(___t_31) == 0)) and (___t_35 := (isinstance((___t_34 := (___t_30._forward_post_hooks)), dict))) and (___t_36 := (len(___t_34) == 0)) and (___t_38 := (id(type((___t_37 := (___t_30._built)))) == 94911584974496)) and (___t_39 := (___t_37 == False)) and (___t_41 := (id((___t_40 := (___t_30.conv))) == 139643550285056)) and (___t_42 := (___t_40.training == True)) and (___t_44 := (id((___t_43 := (___t_30.bn))) == 139643550284096)) and (___t_45 := (___t_43.training == True)) and (___t_47 := (id((___t_46 := (___t_30.act))) == 139643550285392)) and (___t_48 := (___t_46.training == True)) and (___t_50 := (id(type((___t_49 := (___t_10.use_se)))) == 94911584974496)) and (___t_51 := (___t_49 == False)) and (___t_54 := (isinstance((___t_53 := ((___t_52 := (___t_10.pw_conv))._forward_pre_hooks)), dict))) and (___t_55 := (len(___t_53) == 0)) and (___t_57 := (isinstance((___t_56 := (___t_52._forward_post_hooks)), dict))) and (___t_58 := (len(___t_56) == 0)) and (___t_60 := (id(type((___t_59 := (___t_52._built)))) == 94911584974496)) and (___t_61 := (___t_59 == False)) and (___t_63 := (id((___t_62 := (___t_52.conv))) == 139643550385152)) and (___t_64 := (___t_62.training == True)) and (___t_66 := (id((___t_65 := (___t_52.bn))) == 139643550385728)) and (___t_67 := (___t_65.training == True)) and (___t_69 := (id((___t_68 := (___t_52.act))) == 139643550385248)) and (___t_70 := (___t_68.training == True)) and (___t_71 := (isinstance(___t_9, dict))) and (___t_72 := (len(___t_9) == 1)) and (___t_73 := (id(___t_10) == 139643550283328)) and (___t_74 := (___t_10.training == True))
[Cache]: missed at frame.f_locals['input'].shape[1] == 16
最好 faster guard 仍然能有这样的体验,能够知道是在什么地方 cache miss 了(实现方式可能有所不同)
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.
done
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.
现在是先加上了名字,后面再改进一下把参数也标注出来
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.
现在是先加上了名字,后面再改进一下把参数也标注出来
嗯嗯,这个 PR 不用考虑那么完善,后续设计考虑到这点即可(后续 lookup 不一定走这套(Python 端线性查找),在最终态(比如 C++ 端树形查找)实现这一点即可)
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.
PR Category
Execute Infrastructure
PR Types
Performance
Description