diff --git a/paddle/pten/api/ext/dll_decl.h b/paddle/pten/api/ext/dll_decl.h index 3dbea5e6dffc271cd2edc4e399d96e18e259d936..37c637c102c3b84dd3a95c72ef6a503055da8d2a 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 140874f93aed72ac1a4a56937e0b8a6fe908cdf4..351e88b57bd8b8dd767ec266018604e568c8d5ba 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 3eb1f89225414e333da82929b791df2df49ebfd6..6693dbf78f4d63cb1fa20833c570674dd8e09533 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 c038e503d47bb71295c13140949adc7100ae0adc..b8b955090b99a88bad56ea1c02128bce0a27fdcc 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 abb31451d522ebc948ad156c2feb4f50a9dd6d4f..d75774a1a12be9e595d282f9a54910f23e17d429 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 6b4a3b1950a98c828188d0dba1100e163e52ce1c..f6cccf0b357ce16d6a2672c87ee4e031b29c839a 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 0948ba5d698a67281fa61192420461bf9a705af3..e17b19d9f689e18eecbeeb6f0d0730cfde1aa3e5 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 cd81d001b8f6b0f7b26e45c6f5a65e5b495587db..5506ee95bd7c9ed40f4b53a23109530f2e7a46cf 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}; }} """