diff --git a/paddle/pten/api/ext/op_meta_info.h b/paddle/pten/api/ext/op_meta_info.h index c461d0f9eb6b72359d7380d3a9628c82a8533dd8..ac37d724698fa42e9ee540dee1791c97facaad29 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 0b9f4284aa70be7362f39296db7735c98c117f24..14cb0aa7c716d8449c672231f5399027275f8c5d 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}; }