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 slogdeterminant op to phi #44547

Merged
merged 2 commits into from
Jul 26, 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
25 changes: 13 additions & 12 deletions paddle/fluid/operators/determinant_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "paddle/fluid/operators/determinant_op.h"

#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/op_proto_maker.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/phi/core/infermeta_utils.h"
#include "paddle/phi/infermeta/backward.h"
#include "paddle/phi/infermeta/unary.h"
Expand Down Expand Up @@ -170,19 +171,19 @@ REGISTER_OPERATOR(determinant_grad,
ops::DeterminantGradOp,
DeterminantGradInferShapeFunctor);

DECLARE_INFER_SHAPE_FUNCTOR(slogdeterminant,
SlogDeterminantInferShapeFunctor,
PD_INFER_META(phi::UnchangedInferMeta));
REGISTER_OPERATOR(slogdeterminant,
ops::SlogDeterminantOp,
ops::SlogDeterminantOpMaker,
ops::SlogDeterminantGradOpMaker<paddle::framework::OpDesc>,
ops::SlogDeterminantGradOpMaker<paddle::imperative::OpBase>);
ops::SlogDeterminantGradOpMaker<paddle::imperative::OpBase>,
SlogDeterminantInferShapeFunctor);

DECLARE_INFER_SHAPE_FUNCTOR(slogdeterminant_grad,
SlogDeterminantGradInferShapeFunctor,
PD_INFER_META(phi::GeneralUnaryGradInferMeta));
REGISTER_OPERATOR(slogdeterminant_grad,
ops::SlogDeterminantGradOp) // reuse det grad op

REGISTER_OP_CPU_KERNEL(slogdeterminant,
ops::SlogDeterminantKernel<phi::CPUContext, float>,
ops::SlogDeterminantKernel<phi::CPUContext, double>);

REGISTER_OP_CPU_KERNEL(slogdeterminant_grad,
ops::SlogDeterminantGradKernel<phi::CPUContext, float>,
ops::SlogDeterminantGradKernel<phi::CPUContext, double>);
ops::SlogDeterminantGradOp,
SlogDeterminantGradInferShapeFunctor) // reuse det grad op
29 changes: 0 additions & 29 deletions paddle/fluid/operators/determinant_op.cu

This file was deleted.

227 changes: 0 additions & 227 deletions paddle/fluid/operators/determinant_op.h

This file was deleted.

9 changes: 9 additions & 0 deletions paddle/phi/api/yaml/legacy_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1998,6 +1998,15 @@
func : slice
backward : slice_grad

- api : slogdet
args : (Tensor x)
output : Tensor
infer_meta :
func : UnchangedInferMeta
kernel :
func : slogdeterminant
backward : slogdet_grad

# soft_shrink
- api : soft_shrink
args : (Tensor x, float lambda)
Expand Down
10 changes: 10 additions & 0 deletions paddle/phi/api/yaml/legacy_backward.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,16 @@
backward : slice_double_grad
no_need_buffer : input

- backward_api : slogdet_grad
forward : slogdet (Tensor x) -> Tensor(out)
args : (Tensor x, Tensor out, Tensor out_grad)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param : [x]
kernel :
func : slogdeterminant_grad

- backward_api : soft_shrink_grad
forward : soft_shrink (Tensor x, float lambda) -> Tensor(out)
args : (Tensor x, Tensor out_grad, float lambda)
Expand Down
25 changes: 25 additions & 0 deletions paddle/phi/kernels/cpu/slogdeterminant_grad_kernel.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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/phi/kernels/slogdeterminant_grad_kernel.h"

#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/slogdeterminant_grad_kernel_impl.h"

PD_REGISTER_KERNEL(slogdeterminant_grad,
CPU,
ALL_LAYOUT,
phi::SlogDeterminantGradKernel,
float,
double) {}
25 changes: 25 additions & 0 deletions paddle/phi/kernels/cpu/slogdeterminant_kernel.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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/phi/kernels/slogdeterminant_kernel.h"

#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/slogdeterminant_kernel_impl.h"

PD_REGISTER_KERNEL(slogdeterminant,
CPU,
ALL_LAYOUT,
phi::SlogDeterminantKernel,
float,
double) {}
Loading