From 038ca68d5c72e2c471970578e7b205dc29bbf512 Mon Sep 17 00:00:00 2001 From: Chen Weihang Date: Tue, 14 Dec 2021 20:45:29 -0600 Subject: [PATCH] revert attr type change (#38129) --- paddle/pten/api/ext/op_meta_info.h | 15 +++++++++++++++ .../fluid/tests/custom_op/attr_test_op.cc | 18 +++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/paddle/pten/api/ext/op_meta_info.h b/paddle/pten/api/ext/op_meta_info.h index c461d0f9eb..ac37d72469 100644 --- a/paddle/pten/api/ext/op_meta_info.h +++ b/paddle/pten/api/ext/op_meta_info.h @@ -186,6 +186,14 @@ struct KernelFuncImpl { PD_SPECIALIZE_ComputeCallHelper(const float&); PD_SPECIALIZE_ComputeCallHelper(const int64_t&); + // NOTE(chenweihang): Used to be compatible with the 2.1 released + // interface, but not recommended + PD_SPECIALIZE_ComputeCallHelper(std::string); + PD_SPECIALIZE_ComputeCallHelper(std::vector); + PD_SPECIALIZE_ComputeCallHelper(std::vector); + PD_SPECIALIZE_ComputeCallHelper(std::vector); + PD_SPECIALIZE_ComputeCallHelper(std::vector); + // end: base template template struct ComputeCallHelper> { @@ -329,6 +337,13 @@ struct InferShapeFuncImpl { PD_SPECIALIZE_InferShapeCallHelper_FOR_ATTR(const float&); PD_SPECIALIZE_InferShapeCallHelper_FOR_ATTR(const int64_t&); + // NOTE(chenweihang): Used to be compatible with the 2.1 released + // interface, but not recommended + PD_SPECIALIZE_InferShapeCallHelper_FOR_ATTR(std::string); + PD_SPECIALIZE_InferShapeCallHelper_FOR_ATTR(std::vector); + PD_SPECIALIZE_InferShapeCallHelper_FOR_ATTR(std::vector); + PD_SPECIALIZE_InferShapeCallHelper_FOR_ATTR(std::vector); + // end: base template template struct InferShapeCallHelper> { diff --git a/python/paddle/fluid/tests/custom_op/attr_test_op.cc b/python/paddle/fluid/tests/custom_op/attr_test_op.cc index 0b9f4284aa..14cb0aa7c7 100644 --- a/python/paddle/fluid/tests/custom_op/attr_test_op.cc +++ b/python/paddle/fluid/tests/custom_op/attr_test_op.cc @@ -127,11 +127,11 @@ std::vector AttrTestForward( int int_attr, float float_attr, int64_t int64_attr, - const std::string& str_attr, - const std::vector& int_vec_attr, - const std::vector& float_vec_attr, - const std::vector& int64_vec_attr, - const std::vector& str_vec_attr) { + std::string str_attr, + std::vector int_vec_attr, + std::vector float_vec_attr, + std::vector int64_vec_attr, + std::vector str_vec_attr) { auto out = paddle::Tensor(paddle::PlaceType::kCPU, x.shape()); PD_DISPATCH_FLOATING_TYPES( @@ -160,10 +160,10 @@ std::vector> AttrTestInferShape( int int_attr, float float_attr, int64_t int64_attr, - const std::string& str_attr, - const std::vector& int_vec_attr, - const std::vector& float_vec_attr, - const std::vector& str_vec_attr) { + std::string str_attr, + std::vector int_vec_attr, + std::vector float_vec_attr, + std::vector str_vec_attr) { return {x_shape}; } -- GitLab