-
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
[phi] Move sequence_pool to phi - Step 3 :sequence_pool_grad_op #52680
Merged
+116
−68
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
2356517
[phi] move sequence_pool kernel to phi
gouzil cc3d41f
mv kernels impl
gouzil 38af314
fix parameter error
gouzil 00ddd3f
Merge branch 'develop' of github.com:gouzil/Paddle into move_sequence…
gouzil 3fd8944
clean include
gouzil 279c02a
fix compat filename
gouzil 314af78
[phi] move fluid sequence_pool_grad to phi
gouzil e1b4fe3
[phi][compat] sig rm GradVarName
gouzil 5245e08
Merge branch 'develop' of github.com:gouzil/Paddle into move_sequence…
gouzil 720e105
[phi] fix sequence_pool out type
gouzil 4f5ca20
[phi] rm impl, add const string
gouzil 55b6592
[phi] fix const str
gouzil b22dc4b
fix sequence_pooling cmake
gouzil dd0af52
[phi] mv sequence_pooling_test
gouzil 1a4e47f
Merge branch 'develop' of github.com:gouzil/Paddle into move_sequence…
gouzil d2e10ac
[phi] fix grad sig
gouzil c51b9d3
[phi] fix sequence_pool is_test error
gouzil eb38862
[phi] fix sequence_pooling gpu include
gouzil 295dbbf
[phi] mv to impl
gouzil 554361a
[phi] fix SequencePoolFunctor cu include
gouzil 23b560a
Merge branch 'develop' of github.com:gouzil/Paddle into move_sequence…
gouzil 6161252
Merge branch 'develop' of github.com:gouzil/Paddle into move_sequence…
gouzil cee77c3
[phi] modify out max_index int32_t
gouzil 8b1cb69
Merge branches 'move_sequence_pool' and 'develop' of github.com:gouzi…
gouzil f5815bb
[phi] add pooltype mapping determine
gouzil 56fb9e8
[phi] fix sequence_pool_sig
gouzil 8f059d7
[phi] fix sequence_pool_sig sum
gouzil edfafaf
[phi] try ci
gouzil fee21b2
[phi] fix max_index optional
gouzil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
|
||
#include "paddle/phi/kernels/sequence_pool_grad_kernel.h" | ||
|
||
#include "paddle/phi/backends/cpu/cpu_context.h" | ||
#include "paddle/phi/core/kernel_registry.h" | ||
#include "paddle/phi/kernels/impl/sequence_pool_grad_kernel_impl.h" | ||
|
||
PD_REGISTER_KERNEL(sequence_pool_grad, | ||
CPU, | ||
ALL_LAYOUT, | ||
phi::SequencePoolGradKernel, | ||
float, | ||
double) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
|
||
#pragma once | ||
|
||
#include "paddle/phi/kernels/funcs/sequence_pooling.h" | ||
|
||
namespace phi { | ||
|
||
template <typename T, typename Context> | ||
void SequencePoolGradKernel(const Context& dev_ctx, | ||
const DenseTensor& x, | ||
const paddle::optional<DenseTensor>& max_index, | ||
const DenseTensor& out_grad, | ||
bool is_test, | ||
const std::string& pooltype, | ||
float pad_value, | ||
DenseTensor* x_grad) { | ||
const phi::DenseTensor* index = nullptr; | ||
if (pooltype == "MAX") { | ||
index = max_index.get_ptr(); | ||
} | ||
dev_ctx.template Alloc<T>(x_grad); | ||
phi::funcs::SequencePoolGradFunctor<Context, T> pool; | ||
pool(dev_ctx, pooltype, out_grad, x_grad, index); | ||
} | ||
|
||
} // namespace phi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
|
||
#pragma once | ||
|
||
#include "paddle/phi/core/dense_tensor.h" | ||
|
||
namespace phi { | ||
template <typename T, typename Context> | ||
void SequencePoolGradKernel(const Context& dev_ctx, | ||
const DenseTensor& x, | ||
const paddle::optional<DenseTensor>& max_index, | ||
const DenseTensor& out_grad, | ||
bool is_test, | ||
const std::string& pooltype, | ||
float pad_value, | ||
DenseTensor* x_grad); | ||
|
||
} // namespace phi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
需要根据
pooltype
属性判断是否映射MaxIndex
输入,可以参考下batch_norm_sig.cc
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.
还是不行, 而且他是挂在
pooltype = SUM
的时候,而不是MAX
的时候有个问题是我在PR-CI-Mac-Python3上看到这个
test_sequence_pool
这个是挂的,但是我本地是不会挂的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.
sig参数映射需要与OPMaker对齐,仅在
pooltype
为MAX
时映射MaxIndex
输入,包括SUM
在内的其它情况均没有MaxIndex
输入。你现在的sig判断逻辑与OpMaker并不一致,且SUM
被拼错成SUN
。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.
为什么
SUM
也需要3个inputThere 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.
这个case下
max_index
参数是根据不同情况可选的,等价于标记了AsDispensable
,所以在kernel声明时应被声明成optional
类型,在SUM
的情况下这个input就会被跳过。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