diff --git a/paddle/fluid/operators/clip_by_norm_op.cc b/paddle/fluid/operators/clip_by_norm_op.cc deleted file mode 100644 index 3805e11d752e3ee4f04bcd85f586835869fc583b..0000000000000000000000000000000000000000 --- a/paddle/fluid/operators/clip_by_norm_op.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* 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 "paddle/fluid/operators/clip_by_norm_op.h" -#include "paddle/fluid/framework/infershape_utils.h" -#include "paddle/phi/core/infermeta_utils.h" -#include "paddle/phi/infermeta/unary.h" - -namespace ops = paddle::operators; - -DECLARE_INFER_SHAPE_FUNCTOR(clip_by_norm, - ClipByNormInferShapeFunctor, - PD_INFER_META(phi::ClipByNormInferMeta)); - -REGISTER_OP_WITHOUT_GRADIENT(clip_by_norm, - ops::ClipByNormOp, - ops::ClipByNormOpMaker, - ClipByNormInferShapeFunctor); diff --git a/paddle/phi/api/yaml/legacy_ops.yaml b/paddle/phi/api/yaml/legacy_ops.yaml index 100329f555bea07e2cfcedd5219dea46de2025fb..abd42601a8fa0054606b94998859e3e78d901ecb 100755 --- a/paddle/phi/api/yaml/legacy_ops.yaml +++ b/paddle/phi/api/yaml/legacy_ops.yaml @@ -222,14 +222,6 @@ kernel : func : class_center_sample -- op : clip_by_norm - args : (Tensor x, float max_norm) - output : Tensor(out) - infer_meta : - func : ClipByNormInferMeta - kernel : - func : clip_by_norm - - op : coalesce_tensor args : (Tensor[] input, DataType dtype, bool copy_data = false, bool set_constant = false, bool persist_output = false, float constant = 0.0, bool use_align = true, int align_size = -1, int size_of_dtype = -1, int64_t[] concated_shapes = {}, int64_t[] concated_ranks = {}) output : Tensor[](output){input.size()}, Tensor(fused_output) diff --git a/paddle/phi/api/yaml/op_compat.yaml b/paddle/phi/api/yaml/op_compat.yaml index bfbab2d52af4ea04e05c7889111b5eac448556ef..44f065feb7d72d2ea8879e8f59fdd86631130df6 100644 --- a/paddle/phi/api/yaml/op_compat.yaml +++ b/paddle/phi/api/yaml/op_compat.yaml @@ -356,6 +356,12 @@ extra : attrs : [bool use_mkldnn = false, str mkldnn_data_type = "float32"] +- op : clip_by_norm + inputs : + x : X + outputs : + out : Out + - op : complex backward : complex_grad inputs : diff --git a/paddle/phi/api/yaml/ops.yaml b/paddle/phi/api/yaml/ops.yaml index 980505ddeb2f1dcb0e90262bd7e615aaf52292ac..20adbd31aca06dcd383bd14cd2e7e6ff5aa074fe 100644 --- a/paddle/phi/api/yaml/ops.yaml +++ b/paddle/phi/api/yaml/ops.yaml @@ -355,6 +355,15 @@ data_type : x backward : clip_grad +- op : clip_by_norm + args : (Tensor x, float max_norm) + output : Tensor(out) + infer_meta : + func : ClipByNormInferMeta + kernel : + func : clip_by_norm {dense -> dense} + clip_by_norm_sr {selected_rows -> selected_rows} + - op : complex args : (Tensor real, Tensor imag) output : Tensor diff --git a/paddle/phi/ops/compat/clip_by_norm_sig.cc b/paddle/phi/ops/compat/clip_by_norm_sig.cc deleted file mode 100644 index 8a2cecc0293d3f658067580401c4586e37aa35a5..0000000000000000000000000000000000000000 --- a/paddle/phi/ops/compat/clip_by_norm_sig.cc +++ /dev/null @@ -1,30 +0,0 @@ -/* 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 ClipByNormOpArgumentMapping(const ArgumentMappingContext& ctx) { - if (ctx.IsDenseTensorInput("X")) { - return KernelSignature("clip_by_norm", {"X"}, {"max_norm"}, {"Out"}); - } else if (ctx.IsSelectedRowsInput("X")) { - return KernelSignature("clip_by_norm_sr", {"X"}, {"max_norm"}, {"Out"}); - } - return KernelSignature("unregistered", {}, {}, {}); -} - -} // namespace phi - -PD_REGISTER_ARG_MAPPING_FN(clip_by_norm, phi::ClipByNormOpArgumentMapping);