From 75f81233aeeef200cd600c262651d9c76479f180 Mon Sep 17 00:00:00 2001 From: Chen Weihang Date: Thu, 18 Feb 2021 20:06:20 -0600 Subject: [PATCH] fix regex error & simplify marco name (#31031) --- paddle/fluid/extension/include/op_meta_info.h | 4 ++-- paddle/fluid/extension/src/tensor.cc | 2 -- python/paddle/fluid/tests/custom_op/relu_op3_simple.cc | 2 +- python/paddle/fluid/tests/custom_op/relu_op_simple.cc | 2 +- python/paddle/utils/cpp_extension/extension_utils.py | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/paddle/fluid/extension/include/op_meta_info.h b/paddle/fluid/extension/include/op_meta_info.h index 2f3d973a8f..a670e345ba 100644 --- a/paddle/fluid/extension/include/op_meta_info.h +++ b/paddle/fluid/extension/include/op_meta_info.h @@ -290,12 +290,12 @@ class OpMetaInfoBuilder { /////////////////////// Op register API ///////////////////////// // For inference: compile directly with framework -// Call after PD_BUILD_OPERATOR(...) +// Call after PD_BUILD_OP(...) void RegisterAllCustomOperator(); /////////////////////// Op register Macro ///////////////////////// -#define PD_BUILD_OPERATOR(op_name) \ +#define PD_BUILD_OP(op_name) \ static ::paddle::OpMetaInfoBuilder __op_meta_info_##__COUNTER__##__ = \ ::paddle::OpMetaInfoBuilder(op_name) diff --git a/paddle/fluid/extension/src/tensor.cc b/paddle/fluid/extension/src/tensor.cc index ef747567b2..12f701a131 100644 --- a/paddle/fluid/extension/src/tensor.cc +++ b/paddle/fluid/extension/src/tensor.cc @@ -125,8 +125,6 @@ T *Tensor::mutable_data() { #ifdef PADDLE_WITH_CUDA case static_cast(PlaceType::kGPU): { int device_num = platform::GetCurrentDeviceId(); - VLOG(1) << "Custom Operator: mutable data cuda device id - " - << device_num; return tensor->mutable_data(platform::CUDAPlace(device_num)); } #endif diff --git a/python/paddle/fluid/tests/custom_op/relu_op3_simple.cc b/python/paddle/fluid/tests/custom_op/relu_op3_simple.cc index 9a72db1006..9df808a38a 100644 --- a/python/paddle/fluid/tests/custom_op/relu_op3_simple.cc +++ b/python/paddle/fluid/tests/custom_op/relu_op3_simple.cc @@ -31,7 +31,7 @@ std::vector ReluInferDType(paddle::DataType x_dtype); // Reuse codes in `relu_op_simple.cc/cu` to register another custom operator // to test jointly compile multi operators at same time. -PD_BUILD_OPERATOR("relu3") +PD_BUILD_OP("relu3") .Inputs({"X"}) .Outputs({"Out"}) .SetKernelFn(PD_KERNEL(ReluForward)) diff --git a/python/paddle/fluid/tests/custom_op/relu_op_simple.cc b/python/paddle/fluid/tests/custom_op/relu_op_simple.cc index 684466a734..5abd1b77da 100644 --- a/python/paddle/fluid/tests/custom_op/relu_op_simple.cc +++ b/python/paddle/fluid/tests/custom_op/relu_op_simple.cc @@ -104,7 +104,7 @@ std::vector ReluInferDType(paddle::DataType x_dtype) { return {x_dtype}; } -PD_BUILD_OPERATOR("relu2") +PD_BUILD_OP("relu2") .Inputs({"X"}) .Outputs({"Out"}) .SetKernelFn(PD_KERNEL(ReluForward)) diff --git a/python/paddle/utils/cpp_extension/extension_utils.py b/python/paddle/utils/cpp_extension/extension_utils.py index f4c8399862..ea855c7e2c 100644 --- a/python/paddle/utils/cpp_extension/extension_utils.py +++ b/python/paddle/utils/cpp_extension/extension_utils.py @@ -612,7 +612,7 @@ def parse_op_name_from(sources): def regex(content): if USING_NEW_CUSTOM_OP_LOAD_METHOD: - pattern = re.compile(r'BUILD_OPERATOR\(([^,]+),') + pattern = re.compile(r'PD_BUILD_OP\(([^,\)]+)\)') else: pattern = re.compile(r'REGISTER_OPERATOR\(([^,]+),') -- GitLab