Skip to content
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

move Masked select to pten #39193

Merged
merged 23 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
24046ad
move masked select cpu kernel
phlrain Jan 21, 2022
92997ba
Merge branch 'develop' of /~https://github.com/PaddlePaddle/Paddle into…
phlrain Jan 21, 2022
61f3aa9
add masked selected gpu kernel; test=develop
phlrain Jan 25, 2022
102def5
Merge branch 'develop' of /~https://github.com/PaddlePaddle/Paddle into…
phlrain Jan 25, 2022
272aa40
fix bugs; test=develop
phlrain Jan 25, 2022
7ea034d
Merge branch 'develop' of /~https://github.com/PaddlePaddle/Paddle into…
phlrain Jan 25, 2022
eca8f6c
bug fix; test=develop
phlrain Jan 25, 2022
317d4df
bug fix; test=develop
phlrain Jan 28, 2022
f4f2fc0
Merge branch 'develop' of /~https://github.com/PaddlePaddle/Paddle into…
phlrain Jan 28, 2022
0defd84
add namespace to set mask array; test=develop
phlrain Jan 29, 2022
23313b0
Merge branch 'develop' of /~https://github.com/PaddlePaddle/Paddle into…
phlrain Jan 29, 2022
0dd230c
fix bug; test=develop
phlrain Jan 29, 2022
9954080
fix bugs; test=develop
phlrain Jan 29, 2022
39a7ce4
Merge branch 'develop' of /~https://github.com/PaddlePaddle/Paddle into…
phlrain Jan 29, 2022
98e1de5
fix ddim bug; test=develop
phlrain Jan 29, 2022
d0a7d91
Merge branch 'develop' of /~https://github.com/PaddlePaddle/Paddle into…
phlrain Jan 29, 2022
26d9140
fix npu op bug; test=develop
phlrain Feb 5, 2022
1272d81
Merge branch 'develop' of /~https://github.com/PaddlePaddle/Paddle into…
phlrain Feb 5, 2022
9fd7781
fix xpu dependecy bug; test=develop
phlrain Feb 7, 2022
2320f16
Merge branch 'develop' of /~https://github.com/PaddlePaddle/Paddle into…
phlrain Feb 7, 2022
c4f429c
Merge branch 'develop' of /~https://github.com/PaddlePaddle/Paddle into…
phlrain Feb 10, 2022
dcb51f2
move kernel args to sig.cc; test=develop
phlrain Feb 10, 2022
1dd3f2b
Merge branch 'develop' of /~https://github.com/PaddlePaddle/Paddle into…
phlrain Feb 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions paddle/fluid/operators/masked_select_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ 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/fluid/operators/masked_select_op.h"
#include "paddle/fluid/framework/op_registry.h"

namespace paddle {
Expand Down Expand Up @@ -106,16 +105,3 @@ REGISTER_OPERATOR(masked_select, ops::MaskedSelectOp, ops::MaskedSelectOpMaker,
ops::MaskedSelectGradOpMaker<paddle::imperative::OpBase>);
REGISTER_OPERATOR(masked_select_grad, ops::MaskedSelectOpGrad,
ops::MaskedSelectedGradNoNeedBufferVarsInferer);

REGISTER_OP_CPU_KERNEL(
masked_select,
ops::MaskedSelectKernel<paddle::platform::CPUDeviceContext, float>,
ops::MaskedSelectKernel<paddle::platform::CPUDeviceContext, double>,
ops::MaskedSelectKernel<paddle::platform::CPUDeviceContext, int>,
ops::MaskedSelectKernel<paddle::platform::CPUDeviceContext, int64_t>);
REGISTER_OP_CPU_KERNEL(
masked_select_grad,
ops::MaskedSelectGradKernel<paddle::platform::CPUDeviceContext, float>,
ops::MaskedSelectGradKernel<paddle::platform::CPUDeviceContext, double>,
ops::MaskedSelectGradKernel<paddle::platform::CPUDeviceContext, int>,
ops::MaskedSelectGradKernel<paddle::platform::CPUDeviceContext, int64_t>);
179 changes: 0 additions & 179 deletions paddle/fluid/operators/masked_select_op.cu

This file was deleted.

94 changes: 0 additions & 94 deletions paddle/fluid/operators/masked_select_op.h

This file was deleted.

2 changes: 1 addition & 1 deletion paddle/fluid/operators/masked_select_op_npu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ 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/fluid/operators/masked_select_op.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/platform/device/npu/npu_op_runner.h"

namespace paddle {
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/masked_select_op_xpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ limitations under the License. */

#ifdef PADDLE_WITH_XPU

#include "paddle/fluid/operators/masked_select_op.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/platform/device/device_wrapper.h"

namespace paddle {
Expand Down
53 changes: 53 additions & 0 deletions paddle/pten/kernels/cpu/masked_select_grad_kernel.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) 2022 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/pten/kernels/masked_select_grad_kernel.h"

#include "paddle/pten/backends/cpu/cpu_context.h"
#include "paddle/pten/core/kernel_registry.h"

namespace pten {

template <typename T, typename Context>
void MaskedSelectGradKernel(const Context& dev_ctx,
const DenseTensor& out_grad,
const DenseTensor& x,
const DenseTensor& mask,
DenseTensor* x_grad) {
auto* mask_data = mask.data<bool>();
auto* input_data = out_grad.data<T>();
auto* out_data = x_grad->mutable_data<T>(dev_ctx.GetPlace());
int mask_size = mask.numel();

int index = 0;
for (int i = 0; i < mask_size; i++) {
if (mask_data[i]) {
out_data[i] = input_data[index];
index++;
} else {
out_data[i] = 0;
}
}
}

} // namespace pten

PT_REGISTER_KERNEL(masked_select_grad,
CPU,
ALL_LAYOUT,
pten::MaskedSelectGradKernel,
float,
double,
int,
int64_t) {}
Loading