From 66cd0bbb9d224cfba9fa2970755a1c7f0addb846 Mon Sep 17 00:00:00 2001 From: Chen Weihang Date: Mon, 6 Dec 2021 05:36:30 -0600 Subject: [PATCH] rename pd_dll_decl to paddle_api (#37876) --- paddle/pten/api/ext/dll_decl.h | 10 +-- paddle/pten/api/ext/op_meta_info.h | 8 +- paddle/pten/api/include/tensor.h | 2 +- paddle/pten/api/include/utils.h | 2 +- paddle/pten/api/lib/api_registry.h | 6 +- paddle/pten/api/lib/tensor.cc | 114 ++++++++++++------------ paddle/pten/api/lib/utils.cc | 2 +- python/paddle/utils/code_gen/api_gen.py | 6 +- 8 files changed, 75 insertions(+), 75 deletions(-) diff --git a/paddle/pten/api/ext/dll_decl.h b/paddle/pten/api/ext/dll_decl.h index 3dbea5e6df..37c637c102 100644 --- a/paddle/pten/api/ext/dll_decl.h +++ b/paddle/pten/api/ext/dll_decl.h @@ -15,13 +15,13 @@ #pragma once #if defined(_WIN32) -#ifndef PD_DLL_DECL +#ifndef PADDLE_API #ifdef PADDLE_DLL_EXPORT -#define PD_DLL_DECL __declspec(dllexport) +#define PADDLE_API __declspec(dllexport) #else -#define PD_DLL_DECL __declspec(dllimport) +#define PADDLE_API __declspec(dllimport) #endif // PADDLE_DLL_EXPORT -#endif // PD_DLL_DECL +#endif // PADDLE_API #else -#define PD_DLL_DECL +#define PADDLE_API #endif // _WIN32 diff --git a/paddle/pten/api/ext/op_meta_info.h b/paddle/pten/api/ext/op_meta_info.h index 140874f93a..351e88b57b 100644 --- a/paddle/pten/api/ext/op_meta_info.h +++ b/paddle/pten/api/ext/op_meta_info.h @@ -33,7 +33,7 @@ limitations under the License. */ namespace paddle { namespace framework { -class PD_DLL_DECL OpMetaInfoHelper; +class PADDLE_API OpMetaInfoHelper; } // namespace framework using Tensor = paddle::Tensor; @@ -425,7 +425,7 @@ struct InferDtypeFuncImpl { ////////////////////// Op Meta Info ////////////////////// -class PD_DLL_DECL OpMetaInfo { +class PADDLE_API OpMetaInfo { public: explicit OpMetaInfo(const std::string& op_name) : name_(op_name) {} @@ -464,7 +464,7 @@ class PD_DLL_DECL OpMetaInfo { //////////////// Op Meta Info Map ///////////////// -class PD_DLL_DECL OpMetaInfoMap { +class PADDLE_API OpMetaInfoMap { public: // this function's impl should keep in header file. // if move to cc file, meta info can not be added @@ -488,7 +488,7 @@ class PD_DLL_DECL OpMetaInfoMap { //////////////// Op Meta Info Builder ///////////////// -class PD_DLL_DECL OpMetaInfoBuilder { +class PADDLE_API OpMetaInfoBuilder { public: explicit OpMetaInfoBuilder(std::string&& name, size_t index); OpMetaInfoBuilder& Inputs(std::vector&& inputs); diff --git a/paddle/pten/api/include/tensor.h b/paddle/pten/api/include/tensor.h index 3eb1f89225..6693dbf78f 100644 --- a/paddle/pten/api/include/tensor.h +++ b/paddle/pten/api/include/tensor.h @@ -84,7 +84,7 @@ class AbstractAutogradMeta { * another simple Tensor design may be required for inference. */ -class PD_DLL_DECL Tensor final { +class PADDLE_API Tensor final { public: /* Part 1: Construction and destruction methods */ diff --git a/paddle/pten/api/include/utils.h b/paddle/pten/api/include/utils.h index c038e503d4..b8b955090b 100644 --- a/paddle/pten/api/include/utils.h +++ b/paddle/pten/api/include/utils.h @@ -21,7 +21,7 @@ namespace paddle { namespace experimental { // TODO(chenweihang): Replace backend by place when place is ready -PD_DLL_DECL Tensor copy_to(const Tensor& x, Backend backend, bool blocking); +PADDLE_API Tensor copy_to(const Tensor& x, Backend backend, bool blocking); } // namespace experimental } // namespace paddle diff --git a/paddle/pten/api/lib/api_registry.h b/paddle/pten/api/lib/api_registry.h index abb31451d5..d75774a1a1 100644 --- a/paddle/pten/api/lib/api_registry.h +++ b/paddle/pten/api/lib/api_registry.h @@ -37,10 +37,10 @@ namespace experimental { // use to declare symbol #define PT_REGISTER_API(name) \ - PD_DLL_DECL int RegisterSymbolsFor##name() { return 0; } + PADDLE_API int RegisterSymbolsFor##name() { return 0; } -#define PT_DECLARE_API(name) \ - extern PD_DLL_DECL int RegisterSymbolsFor##name(); \ +#define PT_DECLARE_API(name) \ + extern PADDLE_API int RegisterSymbolsFor##name(); \ UNUSED static int use_pten_api_##name = RegisterSymbolsFor##name() } // namespace experimental diff --git a/paddle/pten/api/lib/tensor.cc b/paddle/pten/api/lib/tensor.cc index 6b4a3b1950..f6cccf0b35 100644 --- a/paddle/pten/api/lib/tensor.cc +++ b/paddle/pten/api/lib/tensor.cc @@ -159,19 +159,19 @@ T *Tensor::mutable_data() { return nullptr; } -template PD_DLL_DECL float *Tensor::mutable_data(); -template PD_DLL_DECL double *Tensor::mutable_data(); -template PD_DLL_DECL int64_t *Tensor::mutable_data(); -template PD_DLL_DECL int32_t *Tensor::mutable_data(); -template PD_DLL_DECL uint8_t *Tensor::mutable_data(); -template PD_DLL_DECL int8_t *Tensor::mutable_data(); -template PD_DLL_DECL int16_t *Tensor::mutable_data(); -template PD_DLL_DECL bool *Tensor::mutable_data(); -template PD_DLL_DECL paddle::platform::complex +template PADDLE_API float *Tensor::mutable_data(); +template PADDLE_API double *Tensor::mutable_data(); +template PADDLE_API int64_t *Tensor::mutable_data(); +template PADDLE_API int32_t *Tensor::mutable_data(); +template PADDLE_API uint8_t *Tensor::mutable_data(); +template PADDLE_API int8_t *Tensor::mutable_data(); +template PADDLE_API int16_t *Tensor::mutable_data(); +template PADDLE_API bool *Tensor::mutable_data(); +template PADDLE_API paddle::platform::complex *Tensor::mutable_data>(); -template PD_DLL_DECL paddle::platform::complex +template PADDLE_API paddle::platform::complex *Tensor::mutable_data>(); -template PD_DLL_DECL paddle::platform::float16 * +template PADDLE_API paddle::platform::float16 * Tensor::mutable_data(); template @@ -185,25 +185,25 @@ T *Tensor::mutable_data(const PlaceType &place) { return mutable_data(); } -template PD_DLL_DECL float *Tensor::mutable_data(const PlaceType &place); -template PD_DLL_DECL double *Tensor::mutable_data( +template PADDLE_API float *Tensor::mutable_data(const PlaceType &place); +template PADDLE_API double *Tensor::mutable_data( const PlaceType &place); -template PD_DLL_DECL int64_t *Tensor::mutable_data( +template PADDLE_API int64_t *Tensor::mutable_data( const PlaceType &place); -template PD_DLL_DECL int32_t *Tensor::mutable_data( +template PADDLE_API int32_t *Tensor::mutable_data( const PlaceType &place); -template PD_DLL_DECL uint8_t *Tensor::mutable_data( +template PADDLE_API uint8_t *Tensor::mutable_data( const PlaceType &place); -template PD_DLL_DECL int8_t *Tensor::mutable_data( +template PADDLE_API int8_t *Tensor::mutable_data( const PlaceType &place); -template PD_DLL_DECL int16_t *Tensor::mutable_data( +template PADDLE_API int16_t *Tensor::mutable_data( const PlaceType &place); -template PD_DLL_DECL bool *Tensor::mutable_data(const PlaceType &place); -template PD_DLL_DECL paddle::platform::complex * +template PADDLE_API bool *Tensor::mutable_data(const PlaceType &place); +template PADDLE_API paddle::platform::complex * Tensor::mutable_data>(const PlaceType &place); -template PD_DLL_DECL paddle::platform::complex * +template PADDLE_API paddle::platform::complex * Tensor::mutable_data>(const PlaceType &place); -template PD_DLL_DECL paddle::platform::float16 * +template PADDLE_API paddle::platform::float16 * Tensor::mutable_data(const PlaceType &place); template @@ -214,22 +214,22 @@ const T *Tensor::data() const { return nullptr; } -template PD_DLL_DECL const float *Tensor::data() const; -template PD_DLL_DECL const double *Tensor::data() const; -template PD_DLL_DECL const int64_t *Tensor::data() const; -template PD_DLL_DECL const int32_t *Tensor::data() const; -template PD_DLL_DECL const uint8_t *Tensor::data() const; -template PD_DLL_DECL const int8_t *Tensor::data() const; -template PD_DLL_DECL const int16_t *Tensor::data() const; -template PD_DLL_DECL const uint16_t *Tensor::data() const; -template PD_DLL_DECL const bool *Tensor::data() const; -template PD_DLL_DECL const paddle::platform::complex +template PADDLE_API const float *Tensor::data() const; +template PADDLE_API const double *Tensor::data() const; +template PADDLE_API const int64_t *Tensor::data() const; +template PADDLE_API const int32_t *Tensor::data() const; +template PADDLE_API const uint8_t *Tensor::data() const; +template PADDLE_API const int8_t *Tensor::data() const; +template PADDLE_API const int16_t *Tensor::data() const; +template PADDLE_API const uint16_t *Tensor::data() const; +template PADDLE_API const bool *Tensor::data() const; +template PADDLE_API const paddle::platform::complex *Tensor::data>() const; -template PD_DLL_DECL const paddle::platform::complex +template PADDLE_API const paddle::platform::complex *Tensor::data>() const; -template PD_DLL_DECL const paddle::platform::float16 * +template PADDLE_API const paddle::platform::float16 * Tensor::data() const; -template PD_DLL_DECL const paddle::platform::bfloat16 * +template PADDLE_API const paddle::platform::bfloat16 * Tensor::data() const; template @@ -241,19 +241,19 @@ T *Tensor::data() { return nullptr; } -template PD_DLL_DECL float *Tensor::data(); -template PD_DLL_DECL double *Tensor::data(); -template PD_DLL_DECL int64_t *Tensor::data(); -template PD_DLL_DECL int32_t *Tensor::data(); -template PD_DLL_DECL uint8_t *Tensor::data(); -template PD_DLL_DECL int8_t *Tensor::data(); -template PD_DLL_DECL int16_t *Tensor::data(); -template PD_DLL_DECL bool *Tensor::data(); -template PD_DLL_DECL paddle::platform::complex +template PADDLE_API float *Tensor::data(); +template PADDLE_API double *Tensor::data(); +template PADDLE_API int64_t *Tensor::data(); +template PADDLE_API int32_t *Tensor::data(); +template PADDLE_API uint8_t *Tensor::data(); +template PADDLE_API int8_t *Tensor::data(); +template PADDLE_API int16_t *Tensor::data(); +template PADDLE_API bool *Tensor::data(); +template PADDLE_API paddle::platform::complex *Tensor::data>(); -template PD_DLL_DECL paddle::platform::complex +template PADDLE_API paddle::platform::complex *Tensor::data>(); -template PD_DLL_DECL paddle::platform::float16 * +template PADDLE_API paddle::platform::float16 * Tensor::data(); // TODO(chenweihang): replace slice impl by API @@ -294,27 +294,27 @@ Tensor Tensor::copy_to(const PlaceType &target_place) const { return copy_to(ConvertExtPlaceToBackend(target_place), /*blocking=*/false); } -template PD_DLL_DECL Tensor +template PADDLE_API Tensor Tensor::copy_to(const PlaceType &target_place) const; -template PD_DLL_DECL Tensor +template PADDLE_API Tensor Tensor::copy_to(const PlaceType &target_place) const; -template PD_DLL_DECL Tensor +template PADDLE_API Tensor Tensor::copy_to(const PlaceType &target_place) const; -template PD_DLL_DECL Tensor +template PADDLE_API Tensor Tensor::copy_to(const PlaceType &target_place) const; -template PD_DLL_DECL Tensor +template PADDLE_API Tensor Tensor::copy_to(const PlaceType &target_place) const; -template PD_DLL_DECL Tensor +template PADDLE_API Tensor Tensor::copy_to(const PlaceType &target_place) const; -template PD_DLL_DECL Tensor +template PADDLE_API Tensor Tensor::copy_to(const PlaceType &target_place) const; -template PD_DLL_DECL Tensor +template PADDLE_API Tensor Tensor::copy_to(const PlaceType &target_place) const; -template PD_DLL_DECL Tensor Tensor::copy_to>( +template PADDLE_API Tensor Tensor::copy_to>( const PlaceType &target_place) const; -template PD_DLL_DECL Tensor Tensor::copy_to>( +template PADDLE_API Tensor Tensor::copy_to>( const PlaceType &target_place) const; -template PD_DLL_DECL Tensor +template PADDLE_API Tensor Tensor::copy_to(const PlaceType &target_place) const; Tensor Tensor::copy_to(Backend backend, bool blocking) const { diff --git a/paddle/pten/api/lib/utils.cc b/paddle/pten/api/lib/utils.cc index 0948ba5d69..e17b19d9f6 100644 --- a/paddle/pten/api/lib/utils.cc +++ b/paddle/pten/api/lib/utils.cc @@ -34,7 +34,7 @@ PT_DECLARE_MODULE(UtilsCUDA); namespace paddle { namespace experimental { -PD_DLL_DECL Tensor copy_to(const Tensor& x, Backend backend, bool blocking) { +PADDLE_API Tensor copy_to(const Tensor& x, Backend backend, bool blocking) { // 1. Get kernel signature and kernel auto kernel_key_set = ParseKernelKeyByInputArgs(x); kernel_key_set.backend_set = kernel_key_set.backend_set | BackendSet(backend); diff --git a/python/paddle/utils/code_gen/api_gen.py b/python/paddle/utils/code_gen/api_gen.py index cd81d001b8..5506ee95bd 100644 --- a/python/paddle/utils/code_gen/api_gen.py +++ b/python/paddle/utils/code_gen/api_gen.py @@ -111,7 +111,7 @@ class API: def gene_api_declaration(self): return f""" -PD_DLL_DECL {self.output} {self.api}({self.args['args_declare']}); +PADDLE_API {self.output} {self.api}({self.args['args_declare']}); """ def gene_kernel_select(self, input_names, attrs, kernel): @@ -312,7 +312,7 @@ PD_DLL_DECL {self.output} {self.api}({self.args['args_declare']}); def gene_api_code(self): if self.is_base_api: return f""" -PD_DLL_DECL {self.output} {self.api}({self.args["args_define"]}) {{ +PADDLE_API {self.output} {self.api}({self.args["args_define"]}) {{ {self.gene_kernel_select(self.args['inputs']['names'], self.args['attrs'], self.kernel)} {self.gene_kernel_context(self.args['inputs']['names'], self.args['attrs'], self.infer_meta, self.kernel['param'])} @@ -323,7 +323,7 @@ PD_DLL_DECL {self.output} {self.api}({self.args["args_define"]}) {{ else: return f""" -PD_DLL_DECL {self.output} {self.api}({self.args["args_define"]}) {{ +PADDLE_API {self.output} {self.api}({self.args["args_define"]}) {{ return {self.invoke}; }} """ -- GitLab