-
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
【Hackathon 5th No.38】为 Paddle 新增 FractionalMaxPool2d / FractionalMaxPool3d API -kernel #59847
Changes from 16 commits
ada4fa5
6411892
ac2151c
6d6dcf8
7b3ef68
80caf0f
f512f96
f092060
a23d0f2
a6f18d4
8fd2c3f
940499d
36aee10
7d65773
f6182d4
0e8df70
6f1f822
331cd95
7706c4a
ba2970f
98d4c9b
34b4d28
c1305fe
6cc617d
e24739a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2343,6 +2343,42 @@ void MaxPoolWithIndexInferMeta(const MetaTensor& x, | |
mask->set_dtype(phi::CppTypeToDataType<int>::Type()); | ||
} | ||
|
||
void FractionalMaxPoolWithIndexInferMeta(const MetaTensor& x, | ||
const std::vector<int>& output_size, | ||
float random_u, | ||
MetaTensor* out, | ||
MetaTensor* mask, | ||
MetaConfig config) { | ||
std::vector<int> output_size_ = output_size; | ||
|
||
auto x_dims = x.dims(); | ||
|
||
PADDLE_ENFORCE_EQ( | ||
(x_dims.size() == 4 || x_dims.size() == 5), | ||
true, | ||
errors::InvalidArgument("Pooling intput should be 4-D or " | ||
"5-D tensor but received %dD-Tensor", | ||
x_dims.size())); | ||
|
||
PADDLE_ENFORCE_EQ( | ||
x_dims.size() - output_size_.size(), | ||
2U, | ||
errors::InvalidArgument( | ||
"The input size %d minus the output size %d should equal to 2.", | ||
x_dims.size(), | ||
output_size_.size())); | ||
|
||
std::vector<int64_t> output_shape({x_dims[0], x_dims[1]}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 上面指定x的dim size是4 或者5 为什么这儿output dim size只能为2了,是不是应该也可以为3 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. output_size 只需要是 2、3 即可,只需要设置最后的几个 size ~ 比如使用 2d 的 api 输入是 [2, 3, 32, 32] ,输出 output_size 是 [18, 18] ;如果使用 3d 的 api 输入是 [2, 3, 32, 32, 32] ,输出 output_size 是 [18, 18, 18] ~ 所以使用 x 的前两个 dim ~ |
||
output_shape.insert( | ||
output_shape.end(), output_size_.begin(), output_size_.end()); | ||
|
||
out->set_dims(common::make_ddim(output_shape)); | ||
out->set_dtype(x.dtype()); | ||
|
||
mask->set_dims(common::make_ddim(output_shape)); | ||
mask->set_dtype(phi::CppTypeToDataType<int>::Type()); | ||
} | ||
|
||
void MeanAllInferMeta(const MetaTensor& x, MetaTensor* out) { | ||
out->set_dims(common::make_ddim({})); | ||
out->set_dtype(x.dtype()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -348,6 +348,13 @@ void MaxPoolWithIndexInferMeta(const MetaTensor& x, | |
MetaTensor* mask, | ||
MetaConfig config = MetaConfig()); | ||
|
||
void FractionalMaxPoolWithIndexInferMeta(const MetaTensor& x, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. InferMeta函数按照字母序排列 |
||
const std::vector<int>& output_size, | ||
float random_u, | ||
MetaTensor* out, | ||
MetaTensor* mask, | ||
MetaConfig config = MetaConfig()); | ||
|
||
void MeanAllInferMeta(const MetaTensor& x, MetaTensor* out); | ||
|
||
void ModeInferMeta(const MetaTensor& 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.
InferMeta函数名为什么多了
WithIndex
?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.
之前为了与其他带有 index 的 pooling 算子命名保持一致所以用的 with index ~ 我改一下吧 ~