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

[Phi] Move elementwise_floordiv and elementwise_pow to phi #40993

Merged
merged 3 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 0 additions & 8 deletions paddle/fluid/operators/elementwise/elementwise_floordiv_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +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/elementwise/elementwise_floordiv_op.h"

#include <string>

#include "paddle/fluid/operators/elementwise/elementwise_op.h"
Expand Down Expand Up @@ -63,12 +61,6 @@ namespace ops = paddle::operators;
REGISTER_OP_WITHOUT_GRADIENT(elementwise_floordiv, ops::ElementwiseOp,
ops::ElementwiseFloorDivOpMaker);

REGISTER_OP_CPU_KERNEL(
elementwise_floordiv,
ops::ElementwiseFloorDivKernel<paddle::platform::CPUDeviceContext, int>,
ops::ElementwiseFloorDivKernel<paddle::platform::CPUDeviceContext,
int64_t>);

REGISTER_OP_VERSION(elementwise_floordiv)
.AddCheckpoint(
R"ROC(Register elementwise_floordiv for adding the attribute of Scale_y)ROC",
Expand Down
46 changes: 0 additions & 46 deletions paddle/fluid/operators/elementwise/elementwise_floordiv_op.cu

This file was deleted.

54 changes: 0 additions & 54 deletions paddle/fluid/operators/elementwise/elementwise_floordiv_op.h

This file was deleted.

17 changes: 0 additions & 17 deletions paddle/fluid/operators/elementwise/elementwise_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,6 @@ using DivFunctor = phi::funcs::DivideFunctor<T>;
template <typename T>
using InverseDivFunctor = phi::funcs::InverseDivideFunctor<T>;

// Floor Divide
template <typename T>
struct FloorDivFunctor {
inline HOSTDEVICE T operator()(const T a, const T b) const {
PADDLE_ENFORCE(b != 0, DIV_ERROR_INFO);
return static_cast<T>(std::trunc(a / b));
}
};

template <typename T>
struct InverseFloorDivFunctor {
inline HOSTDEVICE T operator()(const T a, const T b) const {
PADDLE_ENFORCE(a != 0, DIV_ERROR_INFO);
return static_cast<T>(std::trunc(b / a));
}
};

#undef DIV_ERROR_INFO

// Maximum
Expand Down
15 changes: 0 additions & 15 deletions paddle/fluid/operators/elementwise/elementwise_pow_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,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/elementwise/elementwise_pow_op.h"

#include <string>

#include "paddle/fluid/operators/elementwise/elementwise_op.h"
Expand Down Expand Up @@ -70,19 +68,6 @@ REGISTER_OPERATOR(elementwise_pow, ops::ElementwiseOp,
ops::ElementwisePowOpGradMaker<paddle::imperative::OpBase>);
REGISTER_OPERATOR(elementwise_pow_grad, ops::ElementwiseOpGrad);

REGISTER_OP_CPU_KERNEL(
elementwise_pow,
ops::ElementwisePowKernel<paddle::platform::CPUDeviceContext, float>,
ops::ElementwisePowKernel<paddle::platform::CPUDeviceContext, double>,
ops::ElementwisePowKernel<paddle::platform::CPUDeviceContext, int>,
ops::ElementwisePowKernel<paddle::platform::CPUDeviceContext, int64_t>);
REGISTER_OP_CPU_KERNEL(
elementwise_pow_grad,
ops::ElementwisePowGradKernel<paddle::platform::CPUDeviceContext, float>,
ops::ElementwisePowGradKernel<paddle::platform::CPUDeviceContext, double>,
ops::ElementwisePowGradKernel<paddle::platform::CPUDeviceContext, int>,
ops::ElementwisePowGradKernel<paddle::platform::CPUDeviceContext, int64_t>);

REGISTER_OP_VERSION(elementwise_pow)
.AddCheckpoint(
R"ROC(Register elementwise_pow for adding the attribute of Scale_y)ROC",
Expand Down
54 changes: 0 additions & 54 deletions paddle/fluid/operators/elementwise/elementwise_pow_op.cu

This file was deleted.

107 changes: 0 additions & 107 deletions paddle/fluid/operators/elementwise/elementwise_pow_op.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License. */
#include <string>

#include "paddle/fluid/operators/elementwise/elementwise_npu.h"
#include "paddle/fluid/operators/elementwise/elementwise_pow_op.h"
#include "paddle/fluid/platform/device/npu/npu_op_runner.h"

namespace paddle {
Expand Down
8 changes: 8 additions & 0 deletions paddle/phi/kernels/cpu/elementwise_grad_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,11 @@ PD_REGISTER_KERNEL(minimum_grad,
int,
int64_t,
phi::dtype::bfloat16) {}
PD_REGISTER_KERNEL(elementwise_pow_grad,
CPU,
ALL_LAYOUT,
phi::ElementwisePowGradKernel,
float,
double,
int,
int64_t) {}
Loading