未验证 提交 17fb92b3 编写于 作者: Z zyfncg 提交者: GitHub

generate static graph code for some ops by yaml (#47416)

上级 e77c062e
// Copyright (c) 2021 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 <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/phi/core/infermeta_utils.h"
#include "paddle/phi/infermeta/backward.h"
#include "paddle/phi/infermeta/unary.h"
namespace paddle {
namespace operators {
class AngleOp : public framework::OperatorWithKernel {
public:
using framework::OperatorWithKernel::OperatorWithKernel;
};
class AngleOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() override {
AddInput("X", "(Tensor), The input tensor of angle op.");
AddOutput("Out", "(Tensor), The output tensor of angle op.");
AddComment(R"DOC(
Angle Operator.
This operator is used to perform elementwise angle for input $X$.
$$out = angle(x)$$
)DOC");
}
};
class AngleGradOp : public framework::OperatorWithKernel {
public:
using framework::OperatorWithKernel::OperatorWithKernel;
protected:
framework::OpKernelType GetExpectedKernelType(
const framework::ExecutionContext& ctx) const override {
auto dtype = OperatorWithKernel::IndicateVarDataType(ctx, "X");
return framework::OpKernelType(dtype, ctx.GetPlace());
}
};
template <typename T>
class AngleGradMaker : public framework::SingleGradOpMaker<T> {
public:
using framework::SingleGradOpMaker<T>::SingleGradOpMaker;
void Apply(GradOpPtr<T> retv) const override {
retv->SetType("angle_grad");
retv->SetInput(framework::GradVarName("Out"), this->OutputGrad("Out"));
retv->SetInput("X", this->Input("X"));
retv->SetAttrMap(this->Attrs());
retv->SetOutput(framework::GradVarName("X"), this->InputGrad("X"));
}
};
} // namespace operators
} // namespace paddle
namespace ops = paddle::operators;
DECLARE_INFER_SHAPE_FUNCTOR(angle,
AngleInferShapeFunctor,
PD_INFER_META(phi::RealAndImagInferMeta));
DECLARE_INFER_SHAPE_FUNCTOR(angle_grad,
AngleGradInferShapeFunctor,
PD_INFER_META(phi::AngleGradInferMeta));
REGISTER_OPERATOR(angle,
ops::AngleOp,
ops::AngleOpMaker,
ops::AngleGradMaker<paddle::framework::OpDesc>,
ops::AngleGradMaker<paddle::imperative::OpBase>,
AngleInferShapeFunctor);
REGISTER_OPERATOR(angle_grad, ops::AngleGradOp, AngleGradInferShapeFunctor);
/* Copyright (c) 2016 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 <memory>
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/phi/core/infermeta_utils.h"
#include "paddle/phi/infermeta/unary.h"
namespace paddle {
namespace operators {
class ArgsortOp : public framework::OperatorWithKernel {
public:
using framework::OperatorWithKernel::OperatorWithKernel;
};
class ArgsortGradOp : public framework::OperatorWithKernel {
public:
using framework::OperatorWithKernel::OperatorWithKernel;
void InferShape(framework::InferShapeContext* ctx) const override {
ctx->SetOutputDim(framework::GradVarName("X"), ctx->GetInputDim("X"));
ctx->ShareLoD("X", /*-->*/ framework::GradVarName("X"));
}
protected:
framework::OpKernelType GetExpectedKernelType(
const framework::ExecutionContext& ctx) const override {
return framework::OpKernelType(OperatorWithKernel::IndicateVarDataType(
ctx, framework::GradVarName("Out")),
ctx.device_context());
}
};
class ArgsortOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() override {
AddInput("X", "(Tensor) The input of Argsort op.");
AddOutput("Out",
"(Tensor) The sorted tensor of Argsort op, with the same "
"shape as Input(X).");
AddOutput("Indices",
"(Tensor) The indices of a tensor giving the sorted order, with "
"the same shape as Input(X).");
AddComment(R"DOC(
Argsort operator
Performs sorting on the input tensor along the given axis and outputs two
tensors, Output(Out) and Output(Indices). They reserve the same shape
with Input(X), and Output(Out) represents the sorted tensor while
Output(Indices) gives the sorted order along the given axis Attr(axis).
)DOC");
AddAttr<int>("axis",
"(int, default -1) The axis along which to sort the tensor. "
"When axis < 0, the actual axis will be the |axis|'th "
"counting backwards. Default -1, the last dimension.")
.SetDefault(-1);
AddAttr<bool>(
"descending",
"(bool, default false) The descending attribute is a flag to tell"
"algorithm how to sort the input data."
"If descending is true, will sort by descending order,"
"else if false, sort by ascending order. Default value is false.")
.SetDefault(false);
}
};
template <typename T>
class ArgsortGradOpMaker : public framework::SingleGradOpMaker<T> {
public:
using framework::SingleGradOpMaker<T>::SingleGradOpMaker;
protected:
void Apply(GradOpPtr<T> op) const override {
op->SetType("argsort_grad");
op->SetInput("Indices", this->Output("Indices"));
op->SetInput("X", this->Input("X"));
op->SetInput(framework::GradVarName("Out"), this->OutputGrad("Out"));
op->SetOutput(framework::GradVarName("X"), this->InputGrad("X"));
op->SetAttrMap(this->Attrs());
}
};
DECLARE_NO_NEED_BUFFER_VARS_INFERER(ArgsortGradNoNeedBufferVarsInferer, "X");
} // namespace operators
} // namespace paddle
namespace ops = paddle::operators;
DECLARE_INFER_SHAPE_FUNCTOR(argsort,
ArgsortInferShapeFunctor,
PD_INFER_META(phi::ArgsortInferMeta));
REGISTER_OPERATOR(argsort,
ops::ArgsortOp,
ops::ArgsortOpMaker,
ops::ArgsortGradOpMaker<paddle::framework::OpDesc>,
ops::ArgsortGradOpMaker<paddle::imperative::OpBase>,
ArgsortInferShapeFunctor);
REGISTER_OPERATOR(argsort_grad,
ops::ArgsortGradOp,
ops::ArgsortGradNoNeedBufferVarsInferer);
/* Copyright (c) 2020 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/fluid/operators/bmm_op.h"
#include <vector>
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/phi/core/infermeta_utils.h"
#include "paddle/phi/infermeta/backward.h"
#include "paddle/phi/infermeta/binary.h"
namespace paddle {
namespace operators {
class BmmOp : public framework::OperatorWithKernel {
public:
using framework::OperatorWithKernel::OperatorWithKernel;
protected:
framework::OpKernelType GetExpectedKernelType(
const framework::ExecutionContext& ctx) const override {
auto data_type = OperatorWithKernel::IndicateVarDataType(ctx, "X");
return framework::OpKernelType(data_type, ctx.device_context());
}
};
class BmmOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() override {
AddInput("X", "(Tensor), The first input tensor of Bmm op.");
AddInput("Y", "(Tensor), The second input tensor of Bmm op.");
AddOutput("Out", "(Tensor), The output tensor of Bmm op.");
AddComment(R"DOC(
The Bmm operator is used to perform batched matrix multiplication
over the last two dimensions of the input tensors `X` and `Y`
which are both 3-dimentionsal.
Examples:
- X: [B, M, K], Y: [B, K, N] => Out: [B, M, N]
)DOC");
}
};
class BmmOpGrad : public framework::OperatorWithKernel {
public:
using framework::OperatorWithKernel::OperatorWithKernel;
protected:
framework::OpKernelType GetExpectedKernelType(
const framework::ExecutionContext& ctx) const override {
return framework::OpKernelType(OperatorWithKernel::IndicateVarDataType(
ctx, framework::GradVarName("Out")),
ctx.device_context());
}
};
template <typename T>
class BmmOpGradMaker : public framework::SingleGradOpMaker<T> {
public:
using framework::SingleGradOpMaker<T>::SingleGradOpMaker;
protected:
void Apply(GradOpPtr<T> retv) const override {
retv->SetType("bmm_grad");
retv->SetInput("X", this->Input("X"));
retv->SetInput("Y", this->Input("Y"));
retv->SetInput(framework::GradVarName("Out"), this->OutputGrad("Out"));
retv->SetOutput(framework::GradVarName("X"), this->InputGrad("X"));
retv->SetOutput(framework::GradVarName("Y"), this->InputGrad("Y"));
}
};
} // namespace operators
} // namespace paddle
namespace ops = paddle::operators;
DECLARE_INFER_SHAPE_FUNCTOR(bmm,
BmmInferShapeFunctor,
PD_INFER_META(phi::BmmInferMeta));
DECLARE_INFER_SHAPE_FUNCTOR(bmm_grad,
BmmGradInferShapeFunctor,
PD_INFER_META(phi::BmmGradInferMeta));
REGISTER_OPERATOR(bmm,
ops::BmmOp,
ops::BmmOpMaker,
ops::BmmOpGradMaker<paddle::framework::OpDesc>,
ops::BmmOpGradMaker<paddle::imperative::OpBase>,
BmmInferShapeFunctor);
REGISTER_OPERATOR(bmm_grad, ops::BmmOpGrad, BmmGradInferShapeFunctor);
/* Copyright (c) 2020 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. */
#ifndef PADDLE_FLUID_OPERATORS_BMM_OP_H_
#define PADDLE_FLUID_OPERATORS_BMM_OP_H_
#include <algorithm>
#include <utility>
#include <vector>
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/phi/kernels/funcs/blas/blas.h"
#include "paddle/phi/kernels/funcs/math_function.h"
namespace paddle {
namespace operators {
using Tensor = phi::DenseTensor;
static void ReshapeTensorIntoMatrixSequence(
phi::DenseTensor *x, const phi::funcs::MatDescriptor &descriptor) {
int64_t h, w;
h = descriptor.height_;
w = descriptor.width_;
if (descriptor.trans_) {
std::swap(w, h);
}
x->Resize({descriptor.batch_size_, h, w});
}
static void ReshapeXYOutIntoMatrixSequence(phi::DenseTensor *x,
phi::DenseTensor *y,
phi::DenseTensor *out,
bool trans_x,
bool trans_y) {
auto x_dim = x->dims();
auto y_dim = y->dims();
auto mat_dim_x = phi::funcs::CreateMatrixDescriptor(x_dim, 0, false);
auto mat_dim_y = phi::funcs::CreateMatrixDescriptor(y_dim, 0, false);
out->Resize({std::max(mat_dim_x.batch_size_, mat_dim_y.batch_size_),
mat_dim_x.height_,
mat_dim_y.width_});
ReshapeTensorIntoMatrixSequence(x, mat_dim_x);
ReshapeTensorIntoMatrixSequence(y, mat_dim_y);
}
} // namespace operators
} // namespace paddle
#endif // PADDLE_FLUID_OPERATORS_BMM_OP_H_
...@@ -23,57 +23,6 @@ ...@@ -23,57 +23,6 @@
namespace paddle { namespace paddle {
namespace operators { namespace operators {
class DeterminantOp : public framework::OperatorWithKernel {
public:
using framework::OperatorWithKernel::OperatorWithKernel;
};
class DeterminantOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() override {
AddInput("Input", "(Tensor) The input tensor of determinant.");
AddOutput("Out",
"(Tensor) The output Tensor containing the determinant"
"value of a square matrix or batches of square matrices ");
AddComment(R"DOC(
Determinant Operator.)DOC");
}
};
class DeterminantGradOp : public framework::OperatorWithKernel {
public:
using framework::OperatorWithKernel::OperatorWithKernel;
protected:
framework::OpKernelType GetExpectedKernelType(
const framework::ExecutionContext &ctx) const override {
return framework::OpKernelType(OperatorWithKernel::IndicateVarDataType(
ctx, framework::GradVarName("Out")),
ctx.GetPlace());
}
};
template <typename T>
class DeterminantGradOpMaker : public framework::SingleGradOpMaker<T> {
public:
using framework::SingleGradOpMaker<T>::SingleGradOpMaker;
protected:
void Apply(GradOpPtr<T> grad_op) const override {
grad_op->SetType("determinant_grad");
grad_op->SetInput("Input", this->Input("Input"));
grad_op->SetInput("Out", this->Output("Out"));
grad_op->SetInput(framework::GradVarName("Out"), this->OutputGrad("Out"));
grad_op->SetOutput(framework::GradVarName("Input"),
this->InputGrad("Input"));
grad_op->SetAttrMap(this->Attrs());
}
};
DECLARE_NO_NEED_BUFFER_VARS_INFERER(DeterminantGradNoNeedBufferVarsInferer,
"Input");
class SlogDeterminantOp : public framework::OperatorWithKernel { class SlogDeterminantOp : public framework::OperatorWithKernel {
public: public:
using framework::OperatorWithKernel::OperatorWithKernel; using framework::OperatorWithKernel::OperatorWithKernel;
...@@ -154,22 +103,6 @@ DECLARE_NO_NEED_BUFFER_VARS_INFERER(SlogDeterminantGradNoNeedBufferVarsInferer, ...@@ -154,22 +103,6 @@ DECLARE_NO_NEED_BUFFER_VARS_INFERER(SlogDeterminantGradNoNeedBufferVarsInferer,
namespace ops = paddle::operators; namespace ops = paddle::operators;
namespace plat = paddle::platform; namespace plat = paddle::platform;
DECLARE_INFER_SHAPE_FUNCTOR(determinant,
DeterminantInferShapeFunctor,
PD_INFER_META(phi::UnchangedInferMeta));
REGISTER_OPERATOR(determinant,
ops::DeterminantOp,
ops::DeterminantOpMaker,
ops::DeterminantGradOpMaker<paddle::framework::OpDesc>,
ops::DeterminantGradOpMaker<paddle::imperative::OpBase>,
DeterminantInferShapeFunctor);
DECLARE_INFER_SHAPE_FUNCTOR(determinant_grad,
DeterminantGradInferShapeFunctor,
PD_INFER_META(phi::GeneralUnaryGradInferMeta));
REGISTER_OPERATOR(determinant_grad,
ops::DeterminantGradOp,
DeterminantGradInferShapeFunctor);
DECLARE_INFER_SHAPE_FUNCTOR(slogdeterminant, DECLARE_INFER_SHAPE_FUNCTOR(slogdeterminant,
SlogDeterminantInferShapeFunctor, SlogDeterminantInferShapeFunctor,
......
...@@ -20,6 +20,28 @@ ...@@ -20,6 +20,28 @@
func : acosh_grad func : acosh_grad
inplace : (out_grad -> x_grad) inplace : (out_grad -> x_grad)
- backward_op : angle_grad
forward : angle (Tensor x) -> Tensor(out)
args : (Tensor x, Tensor out_grad)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param : [x]
kernel :
func : angle_grad
- backward_op : argsort_grad
forward : argsort (Tensor x, int axis, bool descending) -> Tensor(out), Tensor(indices)
args : (Tensor indices, Tensor x, Tensor out_grad, int axis, bool descending)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param : [x]
kernel :
func : argsort_grad
data_type : out_grad
no_need_buffer : x
- backward_op : asin_grad - backward_op : asin_grad
forward : asin (Tensor x) -> Tensor(out) forward : asin (Tensor x) -> Tensor(out)
args : (Tensor x, Tensor out_grad) args : (Tensor x, Tensor out_grad)
...@@ -74,6 +96,16 @@ ...@@ -74,6 +96,16 @@
func : atanh_grad func : atanh_grad
inplace : (out_grad -> x_grad) inplace : (out_grad -> x_grad)
- backward_op : bmm_grad
forward : bmm (Tensor x, Tensor y) -> Tensor(out)
args : (Tensor x, Tensor y, Tensor out_grad)
output : Tensor(x_grad), Tensor(y_grad)
infer_meta :
func : BmmGradInferMeta
kernel :
func : bmm_grad
data_type : out_grad
- backward_op : cholesky_grad - backward_op : cholesky_grad
forward : cholesky (Tensor x, bool upper) -> Tensor(out) forward : cholesky (Tensor x, bool upper) -> Tensor(out)
args : (Tensor out, Tensor out_grad, bool upper) args : (Tensor out, Tensor out_grad, bool upper)
...@@ -127,6 +159,17 @@ ...@@ -127,6 +159,17 @@
func : cross_grad func : cross_grad
data_type : out_grad data_type : out_grad
- backward_op : det_grad
forward : det (Tensor x) -> Tensor(out)
args : (Tensor x, Tensor out, Tensor out_grad)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param : [x]
kernel :
func : determinant_grad
data_type : out_grad
- backward_op : diag_grad - backward_op : diag_grad
forward : diag (Tensor x, int offset, float padding_value) -> Tensor(out) forward : diag (Tensor x, int offset, float padding_value) -> Tensor(out)
args : (Tensor x, Tensor out_grad, int offset) args : (Tensor x, Tensor out_grad, int offset)
......
...@@ -109,7 +109,7 @@ KernelSignature {{api["op_name"] | to_pascal_case }}OpArgumentMapping(const Argu ...@@ -109,7 +109,7 @@ KernelSignature {{api["op_name"] | to_pascal_case }}OpArgumentMapping(const Argu
{% endfor %} {% endfor %}
{{get_output_list(api["outputs"], kernel_args)}}; {{get_output_list(api["outputs"], kernel_args)}};
{% if api["kernel"]["func"] | length == 1 %} {% if api["kernel"]["func"] | length == 1 %}
KernelSignature sig("{{api["name"]}}", std::move(inputs), std::move(attrs), std::move(outputs)); KernelSignature sig("{{api["kernel"]["func"][0]}}", std::move(inputs), std::move(attrs), std::move(outputs));
return sig; return sig;
{% else %}{# it has kernel for selected rows #} {% else %}{# it has kernel for selected rows #}
const char* kernel_name = ctx.IsSelectedRowsInput({{kernel_args[0] | to_opmaker_name_cstr}}) ? "{{api["kernel"]["func"][1]}}" : "{{api["kernel"]["func"][0]}}"; const char* kernel_name = ctx.IsSelectedRowsInput({{kernel_args[0] | to_opmaker_name_cstr}}) ? "{{api["kernel"]["func"][1]}}" : "{{api["kernel"]["func"][0]}}";
......
...@@ -100,30 +100,6 @@ ...@@ -100,30 +100,6 @@
kernel : kernel :
func : amin_grad func : amin_grad
- backward_op : angle_grad
forward : angle (Tensor x) -> Tensor(out)
args : (Tensor x, Tensor out_grad)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param : [x]
kernel :
func : angle_grad
data_transform:
skip_transform : out_grad
- backward_op : argsort_grad
forward : argsort (Tensor x, int axis, bool descending) -> Tensor(out), Tensor(indices)
args : (Tensor indices, Tensor x, Tensor out_grad, int axis, bool descending)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param : [x]
kernel :
func : argsort_grad
data_type : out_grad
no_need_buffer : x
- backward_op : as_complex_grad - backward_op : as_complex_grad
forward : as_complex (Tensor x) -> Tensor(out) forward : as_complex (Tensor x) -> Tensor(out)
args : (Tensor out_grad) args : (Tensor out_grad)
...@@ -222,15 +198,6 @@ ...@@ -222,15 +198,6 @@
kernel : kernel :
func : bilinear_tensor_product_grad func : bilinear_tensor_product_grad
- backward_op : bmm_grad
forward : bmm (Tensor x, Tensor y) -> Tensor(out)
args : (Tensor x, Tensor y, Tensor out_grad)
output : Tensor(x_grad), Tensor(y_grad)
infer_meta :
func : BmmGradInferMeta
kernel :
func : bmm_grad
- backward_op : brelu_grad - backward_op : brelu_grad
forward : brelu (Tensor x, float t_min, float t_max) -> Tensor(out) forward : brelu (Tensor x, float t_min, float t_max) -> Tensor(out)
args : (Tensor x, Tensor out_grad, float t_min, float t_max) args : (Tensor x, Tensor out_grad, float t_min, float t_max)
...@@ -515,16 +482,6 @@ ...@@ -515,16 +482,6 @@
kernel : kernel :
func : depthwise_conv2d_transpose_grad func : depthwise_conv2d_transpose_grad
- backward_op : det_grad
forward : det (Tensor x) -> Tensor(out)
args : (Tensor x, Tensor out, Tensor out_grad)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param : [x]
kernel :
func : determinant_grad
- backward_op : divide_double_grad - backward_op : divide_double_grad
forward : divide_grad (Tensor x, Tensor y, Tensor out, Tensor grad_out, int axis = -1) -> Tensor(grad_x), Tensor(grad_y) forward : divide_grad (Tensor x, Tensor y, Tensor out, Tensor grad_out, int axis = -1) -> Tensor(grad_x), Tensor(grad_y)
args : (Tensor y, Tensor out, Tensor grad_x, Tensor grad_x_grad, Tensor grad_y_grad, int axis = -1) args : (Tensor y, Tensor out, Tensor grad_x, Tensor grad_x_grad, Tensor grad_y_grad, int axis = -1)
......
...@@ -144,15 +144,6 @@ ...@@ -144,15 +144,6 @@
func : amin func : amin
backward : amin_grad backward : amin_grad
- op : angle
args : (Tensor x)
output : Tensor
infer_meta :
func : RealAndImagInferMeta
kernel :
func : angle
backward : angle_grad
- op : any - op : any
args : (Tensor x, int64_t[] axis={}, bool keepdim=false) args : (Tensor x, int64_t[] axis={}, bool keepdim=false)
output : Tensor(out) output : Tensor(out)
...@@ -191,15 +182,6 @@ ...@@ -191,15 +182,6 @@
kernel : kernel :
func : arg_min func : arg_min
- op : argsort
args : (Tensor x, int axis=-1, bool descending=false)
output : Tensor(out), Tensor(indices)
infer_meta :
func : ArgsortInferMeta
kernel :
func : argsort
backward : argsort_grad
- op : as_complex - op : as_complex
args : (Tensor x) args : (Tensor x)
output : Tensor output : Tensor
...@@ -355,15 +337,6 @@ ...@@ -355,15 +337,6 @@
kernel : kernel :
func : bitwise_xor func : bitwise_xor
- op : bmm
args : (Tensor x, Tensor y)
output : Tensor
infer_meta :
func : BmmInferMeta
kernel :
func : bmm
backward : bmm_grad
- op : box_coder - op : box_coder
args : (Tensor prior_box, Tensor prior_box_var, Tensor target_box, str code_type, bool box_normalized, int axis, float[] variance) args : (Tensor prior_box, Tensor prior_box_var, Tensor target_box, str code_type, bool box_normalized, int axis, float[] variance)
output : Tensor(output_box) output : Tensor(output_box)
...@@ -618,15 +591,6 @@ ...@@ -618,15 +591,6 @@
func : depthwise_conv2d_transpose func : depthwise_conv2d_transpose
backward : depthwise_conv2d_transpose_grad backward : depthwise_conv2d_transpose_grad
- op : det
args : (Tensor x)
output : Tensor
infer_meta :
func : UnchangedInferMeta
kernel :
func : determinant
backward : det_grad
- op : diag_embed - op : diag_embed
args : (Tensor input, int offset, int dim1, int dim2) args : (Tensor input, int offset, int dim1, int dim2)
output : Tensor(out) output : Tensor(out)
......
...@@ -41,9 +41,20 @@ ...@@ -41,9 +41,20 @@
- op : angle - op : angle
backward : angle_grad backward : angle_grad
inputs :
x : X
outputs :
out : Out
extra : extra :
attrs : [bool use_mkldnn = false] attrs : [bool use_mkldnn = false]
- op : argsort
inputs :
x : X
outputs :
out : Out
indices : Indices
- op : asin - op : asin
inputs : inputs :
x : X x : X
...@@ -101,6 +112,12 @@ ...@@ -101,6 +112,12 @@
extra : extra :
attrs : [bool use_mkldnn = false] attrs : [bool use_mkldnn = false]
- op : bmm
inputs :
{x : X, y : Y}
outputs :
out : Out
- op : ceil - op : ceil
backward : ceil_grad backward : ceil_grad
extra : extra :
...@@ -226,6 +243,13 @@ ...@@ -226,6 +243,13 @@
extra : extra :
attrs : [float moving_rate = 0.9] attrs : [float moving_rate = 0.9]
- op : det (determinant)
backward : det_grad (determinant_grad)
inputs :
x : Input
outputs :
out : Out
- op : diag (diag_v2) - op : diag (diag_v2)
backward : diag_grad (diag_v2_grad) backward : diag_grad (diag_v2_grad)
inputs : inputs :
......
...@@ -16,6 +16,24 @@ ...@@ -16,6 +16,24 @@
func : acosh func : acosh
backward : acosh_grad backward : acosh_grad
- op : angle
args : (Tensor x)
output : Tensor
infer_meta :
func : RealAndImagInferMeta
kernel :
func : angle
backward : angle_grad
- op : argsort
args : (Tensor x, int axis=-1, bool descending=false)
output : Tensor(out), Tensor(indices)
infer_meta :
func : ArgsortInferMeta
kernel :
func : argsort
backward : argsort_grad
- op : asin - op : asin
args : (Tensor x) args : (Tensor x)
output : Tensor output : Tensor
...@@ -69,6 +87,15 @@ ...@@ -69,6 +87,15 @@
kernel : kernel :
func : bernoulli func : bernoulli
- op : bmm
args : (Tensor x, Tensor y)
output : Tensor
infer_meta :
func : BmmInferMeta
kernel :
func : bmm
backward : bmm_grad
- op : cholesky - op : cholesky
args : (Tensor x, bool upper=false) args : (Tensor x, bool upper=false)
output : Tensor output : Tensor
...@@ -115,6 +142,15 @@ ...@@ -115,6 +142,15 @@
data_type : x data_type : x
backward : cross_grad backward : cross_grad
- op : det
args : (Tensor x)
output : Tensor
infer_meta :
func : UnchangedInferMeta
kernel :
func : determinant
backward : det_grad
- op : diag - op : diag
args : (Tensor x, int offset = 0, float padding_value = 0.0) args : (Tensor x, int offset = 0, float padding_value = 0.0)
output : Tensor output : Tensor
......
...@@ -25,4 +25,6 @@ PD_REGISTER_KERNEL(angle_grad, ...@@ -25,4 +25,6 @@ PD_REGISTER_KERNEL(angle_grad,
float, float,
double, double,
phi::dtype::complex<float>, phi::dtype::complex<float>,
phi::dtype::complex<double>) {} phi::dtype::complex<double>) {
kernel->InputAt(1).SetDataType(phi::dtype::ToReal(kernel_key.dtype()));
}
...@@ -25,4 +25,6 @@ PD_REGISTER_KERNEL(angle_grad, ...@@ -25,4 +25,6 @@ PD_REGISTER_KERNEL(angle_grad,
float, float,
double, double,
phi::dtype::complex<float>, phi::dtype::complex<float>,
phi::dtype::complex<double>) {} phi::dtype::complex<double>) {
kernel->InputAt(1).SetDataType(phi::dtype::ToReal(kernel_key.dtype()));
}
/* 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/core/compat/op_utils.h"
namespace phi {
KernelSignature AngleOpArgumentMapping(const ArgumentMappingContext& ctx) {
return KernelSignature("angle", {"X"}, {}, {"Out"});
}
KernelSignature AngleGradOpArgumentMapping(const ArgumentMappingContext& ctx) {
return KernelSignature("angle_grad", {"X", "Out@GRAD"}, {}, {"X@GRAD"});
}
} // namespace phi
PD_REGISTER_ARG_MAPPING_FN(angle, phi::AngleOpArgumentMapping);
PD_REGISTER_ARG_MAPPING_FN(angle_grad, phi::AngleGradOpArgumentMapping);
// 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/core/compat/op_utils.h"
namespace phi {
KernelSignature ArgsortGradOpArgumentMapping(
const ArgumentMappingContext& ctx) {
return KernelSignature("argsort_grad",
{"Indices", "X", "Out@GRAD"},
{"axis", "descending"},
{"X@GRAD"});
}
} // namespace phi
PD_REGISTER_ARG_MAPPING_FN(argsort_grad, phi::ArgsortGradOpArgumentMapping);
// 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/core/compat/op_utils.h"
namespace phi {
KernelSignature BmmGradOpArgumentMapping(const ArgumentMappingContext& ctx) {
return KernelSignature(
"bmm_grad", {"X", "Y", "Out@GRAD"}, {}, {"X@GRAD", "Y@GRAD"});
}
} // namespace phi
PD_REGISTER_ARG_MAPPING_FN(bmm_grad, phi::BmmGradOpArgumentMapping);
// 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/core/compat/op_utils.h"
namespace phi {
KernelSignature DeterminantGradOpArgumentMapping(
const ArgumentMappingContext& ctx) {
return KernelSignature(
"determinant_grad", {"Input", "Out", "Out@GRAD"}, {}, {"Input@GRAD"});
}
} // namespace phi
PD_REGISTER_ARG_MAPPING_FN(determinant_grad,
phi::DeterminantGradOpArgumentMapping);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册