-
Notifications
You must be signed in to change notification settings - Fork 5.7k
[SOT][CINN] Only create SymbolicVariable
when value >= 2
& add corresponding guards and C++ constraints
#71748
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
17bdf13
to
4274259
Compare
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 是不是没把 >=2 加到 guard 里?从正确性上来讲这是不够的,需要测一下: shape = [2, 2, 3] # cache miss,静态 shape
shape = [3, 2, 3] # cache miss,动态 shape
shape = [1, 2, 3] # cache miss,静态 shape,按我理解现在的实现这里是会 hit 到上面的动态 shape 的,这是不对的 |
|
This reverts commit 3a6f3c6.
python/paddle/jit/sot/opcode_translator/executor/variables/basic.py
Outdated
Show resolved
Hide resolved
python/paddle/jit/sot/opcode_translator/executor/variables/basic.py
Outdated
Show resolved
Hide resolved
… value_limit_2
向
把constrained_inputs放在了parameters的前面,导致按位置传递参数时,拿不到正确的 |
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.
其余目测没啥大问题
8d4785c
to
c83432d
Compare
另外 approval 也需要看一下,看起来可能是信息太短之类的问题 |
if (!to_append) { | ||
shape_analysis.SetInputDynamicDimSpec(input_dynamic_dim_spec); | ||
} else { | ||
shape_analysis.AppendInputDynamicDimSpec(input_dynamic_dim_spec); | ||
} |
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.
可以写成两个函数接口,语义上更清晰
paddle/cinn/hlir/dialect/operator/transforms/specify_input_dynamic_dim_util.cc
Outdated
Show resolved
Hide resolved
paddle/cinn/hlir/dialect/operator/transforms/specify_input_dynamic_dim_util.cc
Outdated
Show resolved
Hide resolved
if (std::get<1>(range_info).has_value()) { | ||
range.min = std::get<1>(range_info).value(); | ||
} | ||
if (std::get<2>(range_info).has_value()) { | ||
range.max = std::get<2>(range_info).value(); | ||
} |
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.
可以显式设置个min max的默认值
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.
Range结构体内部有min max的默认值
paddle/cinn/hlir/dialect/operator/transforms/specify_input_dynamic_dim_util.h
Outdated
Show resolved
Hide resolved
symbolicVariable
when value is greater than or equal to 2 & add corresponding guards and C++ constraints
symbolicVariable
when value is greater than or equal to 2 & add corresponding guards and C++ constraintsSymbolicVariable
when value is greater than or equal to 2 & add corresponding guards and C++ constraints
SymbolicVariable
when value is greater than or equal to 2 & add corresponding guards and C++ constraintsSymbolicVariable
when value >= 2
& add corresponding guards and C++ constraints
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.
…rresponding guards and C++ constraints (PaddlePaddle#71748)
PR Category
Execute Infrastructure
PR Types
Performance
Description
1. Conditional symbolic variable creation in SOT
Modification: Symbolic variables are now only instantiated when tensor dimensions ≥ 2 in the SOT compiler phase.
Impact: Reduce the number of kernels generated by
CINN
in later pass.2. Add corresponding Guards
Current approach: Implemented temporary validation using
StringifiedGuard
Future plan: Replace it with
FasterGuard
.3. Cross-language constraint (Python → C++)
Implementation:
ConstrainedInputSpec
subclass extendingInputSpec
InputDynamicDimSpec
Extract the constraint information from
ConstrainedInputSpec
, then pass it toConcreteProgram
, where it is finally passed on toPartialProgramLayer
, where we bind the constraint information using interface exposed by Pybind.4. Add new "Append" mode for
SpecifyInputDynamicDim
asAppendInputDynamicDim
This new interface can be useful in future expansion.
5. Add new
__init__()
arguments forPartialProgramLayer
andConcreteProgram
Now both the 2 classes have a new key-word argument named
constraints
, whose default value isNone
.6. Add new
__init__()
argument forMetaInfo
Add a new positional argument
spec_name
forMetaInfo
in__init__()
, remember to pass it when creating newMetaInfo
.PCard-66972