-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[phi] Move sequence_pool to phi - Step 3 :sequence_pool_grad_op (#52680)
* [phi] move sequence_pool kernel to phi * mv kernels impl * fix parameter error * clean include * fix compat filename * [phi] move fluid sequence_pool_grad to phi * [phi][compat] sig rm GradVarName * [phi] fix sequence_pool out type * [phi] rm impl, add const string * [phi] fix const str * fix sequence_pooling cmake * [phi] mv sequence_pooling_test * [phi] fix grad sig * [phi] fix sequence_pool is_test error * [phi] fix sequence_pooling gpu include * [phi] mv to impl * [phi] fix SequencePoolFunctor cu include * [phi] modify out max_index int32_t * [phi] add pooltype mapping determine * [phi] fix sequence_pool_sig * [phi] fix sequence_pool_sig sum * [phi] try ci * [phi] fix max_index optional
- Loading branch information
Showing
10 changed files
with
116 additions
and
68 deletions.
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