-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add expand composite rule #50810
Add expand composite rule #50810
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
… composite_rule_expand
shape_in = x.shape | ||
assert len(shape) >= len(shape_in) | ||
dim_out = len(shape) | ||
dim_in = len(shape_in) |
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.
polish 3 lines
dim_out = len(shape) | ||
dim_in = len(shape_in) | ||
if dim_out == 0: | ||
return x |
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.
dim_out can't be 0, remove the code.
|
||
|
||
# Situation 10: comp case, input x is Bool | ||
class TestExpandV2CompOpBoolean(OpTest): |
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.
之前没有组合测试的单测可以去掉,例如Shape Tensor类的
for i in range(dim_out - dim_in): | ||
shape_in_expand.append(1) | ||
shape_in_expand.extend(shape_in) | ||
x_reshape = reshape(x, shape_in_expand) |
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.
Add comment to show why we need reshape first
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.
Under the static graph, the tile op will set the expanded dimension to -1 when expanding the tensor, which will result in failure to pass the shape check. So for tensors that need to expand the dimension, reshape will be used in advance
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 types
Others
PR changes
Others
Describe
add composite rule for expand