diff --git a/paddle/fluid/eager/auto_code_generator/generator/eager_gen.py b/paddle/fluid/eager/auto_code_generator/generator/eager_gen.py index ec765cd170e166ee9943f2457ea94f9df9dc817b..facfd3b8994b104714f1ccc3a59e02826f9206bb 100644 --- a/paddle/fluid/eager/auto_code_generator/generator/eager_gen.py +++ b/paddle/fluid/eager/auto_code_generator/generator/eager_gen.py @@ -1469,9 +1469,12 @@ class DygraphForwardFunctionGenerator(DygraphFunctionGeneratorBase): # Get return type list & outputs returns_type_list = ["" for i in range(num_outputs)] returns_list = ["" for i in range(num_outputs)] + num_visited_intermediate_outputs = 0 for name, (rtype, pos) in forward_outputs_position_map.items(): if name in intermediate_outputs: + num_visited_intermediate_outputs += 1 continue + pos -= num_visited_intermediate_outputs returns_list[pos] = f"{name}" if IsPlainTensorType(rtype): diff --git a/paddle/fluid/operators/detection/multiclass_nms_op.cc b/paddle/fluid/operators/detection/multiclass_nms_op.cc index 7c02f37fa3ef936e291f10c056125e343453bee7..c2a967fff9f9feec956b1269767f4292f3071c6c 100644 --- a/paddle/fluid/operators/detection/multiclass_nms_op.cc +++ b/paddle/fluid/operators/detection/multiclass_nms_op.cc @@ -607,45 +607,12 @@ class MultiClassNMS2OpMaker : public MultiClassNMSOpMaker { } }; -class MultiClassNMS3Op : public MultiClassNMS2Op { - public: - MultiClassNMS3Op(const std::string& type, - const framework::VariableNameMap& inputs, - const framework::VariableNameMap& outputs, - const framework::AttributeMap& attrs) - : MultiClassNMS2Op(type, inputs, outputs, attrs) {} - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - return phi::KernelKey( - OperatorWithKernel::IndicateVarDataType(ctx, "Scores"), ctx.GetPlace()); - } -}; - -class MultiClassNMS3OpMaker : public MultiClassNMS2OpMaker { - public: - void Make() override { - MultiClassNMS2OpMaker::Make(); - AddInput("RoisNum", - "(Tensor) The number of RoIs in shape (B)," - "B is the number of images") - .AsDispensable(); - AddOutput("NmsRoisNum", "(Tensor), The number of NMS RoIs in each image") - .AsDispensable(); - } -}; - template class MultiClassNMS2Kernel : public MultiClassNMSKernel {}; } // namespace operators } // namespace paddle -DECLARE_INFER_SHAPE_FUNCTOR(multiclass_nms3, - MultiClassNMSShapeFunctor, - PD_INFER_META(phi::MultiClassNMSInferMeta)); - namespace ops = paddle::operators; REGISTER_OPERATOR( multiclass_nms, @@ -668,11 +635,3 @@ PD_REGISTER_STRUCT_KERNEL(multiclass_nms2, ops::MultiClassNMS2Kernel, float, double) {} - -REGISTER_OPERATOR( - multiclass_nms3, - ops::MultiClassNMS3Op, - ops::MultiClassNMS3OpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - MultiClassNMSShapeFunctor); diff --git a/paddle/phi/api/yaml/legacy_ops.yaml b/paddle/phi/api/yaml/legacy_ops.yaml index 532e445a1a7821813631443b6b1ed6802a80140d..01adff8b5d5569da907f07dc347da78e17fe5dbe 100755 --- a/paddle/phi/api/yaml/legacy_ops.yaml +++ b/paddle/phi/api/yaml/legacy_ops.yaml @@ -666,15 +666,6 @@ func : mish backward : mish_grad -- op : multiclass_nms3 - args : (Tensor bboxes, Tensor scores, Tensor rois_num, float score_threshold, int nms_top_k, int keep_top_k, float nms_threshold=0.3, bool normalized=true, float nms_eta=1.0, int background_label=0) - output : Tensor(out), Tensor(index), Tensor(nms_rois_num) - infer_meta : - func : MultiClassNMSInferMeta - kernel : - func : multiclass_nms3 - optional : rois_num - - op : multiply args : (Tensor x, Tensor y) output : Tensor diff --git a/paddle/phi/api/yaml/op_compat.yaml b/paddle/phi/api/yaml/op_compat.yaml index 9f2aa2d20becced974e747160f202ebc9fe7bb22..3e70e296607681d7f9416518cf21024801bc62de 100755 --- a/paddle/phi/api/yaml/op_compat.yaml +++ b/paddle/phi/api/yaml/op_compat.yaml @@ -1702,6 +1702,12 @@ out : Out drop_empty_grad : [x_grad] +- op : multiclass_nms3 + inputs : + {bboxes : BBoxes, scores : Scores, rois_num : RoisNum} + outputs : + {out : Out, index : Index, nms_rois_num : NmsRoisNum} + - op : multinomial inputs : {x : X} diff --git a/paddle/phi/api/yaml/ops.yaml b/paddle/phi/api/yaml/ops.yaml index 043527bbdef22a969a8d490cd6fc6978637a6cc6..ffbd8bcc034d525c0de5f0598b57c4b268e88998 100644 --- a/paddle/phi/api/yaml/ops.yaml +++ b/paddle/phi/api/yaml/ops.yaml @@ -1548,6 +1548,16 @@ func : multi_dot backward : multi_dot_grad +- op : multiclass_nms3 + args : (Tensor bboxes, Tensor scores, Tensor rois_num, float score_threshold, int nms_top_k, int keep_top_k, float nms_threshold=0.3, bool normalized=true, float nms_eta=1.0, int background_label=0) + output : Tensor(out), Tensor(index), Tensor(nms_rois_num) + infer_meta : + func : MultiClassNMSInferMeta + kernel : + func : multiclass_nms3 + data_type : scores + optional : rois_num, nms_rois_num + - op : multinomial args : (Tensor x, Scalar(int) num_samples = 1, bool replacement = false) output : Tensor(out) diff --git a/paddle/phi/ops/compat/multiclass_nms3_sig.cc b/paddle/phi/ops/compat/multiclass_nms3_sig.cc deleted file mode 100644 index 68dab33b552dc42ec6a412ef31ccc81d99190bea..0000000000000000000000000000000000000000 --- a/paddle/phi/ops/compat/multiclass_nms3_sig.cc +++ /dev/null @@ -1,36 +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 MultiClassNMS3OpArgumentMapping( - const ArgumentMappingContext& ctx UNUSED) { - return KernelSignature("multiclass_nms3", - {"BBoxes", "Scores", "RoisNum"}, - {"score_threshold", - "nms_top_k", - "keep_top_k", - "nms_threshold", - "normalized", - "nms_eta", - "background_label"}, - {"Out", "Index", "NmsRoisNum"}); -} - -} // namespace phi - -PD_REGISTER_ARG_MAPPING_FN(multiclass_nms3, - phi::MultiClassNMS3OpArgumentMapping);