From e87545cef9df8932dd6d3026f17496b81e950c16 Mon Sep 17 00:00:00 2001 From: Zhanlue Yang Date: Mon, 22 Nov 2021 15:43:35 +0800 Subject: [PATCH] Moved Pten Module Declaration inside Kernel APIs (#37371) --- paddle/pten/api/lib/creation.cc | 7 +++++++ paddle/pten/api/lib/linalg.cc | 7 +++++++ paddle/pten/api/lib/manipulation.cc | 7 +++++++ paddle/pten/api/lib/math.cc | 7 +++++++ paddle/pten/tests/api/test_dot_api.cc | 6 ------ paddle/pten/tests/api/test_elementwise_api.cc | 6 ------ paddle/pten/tests/api/test_fill_api.cc | 6 ------ paddle/pten/tests/api/test_flatten_api.cc | 6 ------ paddle/pten/tests/api/test_matmul_api.cc | 6 ------ paddle/pten/tests/api/test_mean_api.cc | 6 ------ paddle/pten/tests/api/test_slice_api.cc | 6 ------ 11 files changed, 28 insertions(+), 42 deletions(-) diff --git a/paddle/pten/api/lib/creation.cc b/paddle/pten/api/lib/creation.cc index f39baa0207c..5745267156c 100644 --- a/paddle/pten/api/lib/creation.cc +++ b/paddle/pten/api/lib/creation.cc @@ -21,9 +21,16 @@ limitations under the License. */ #include "paddle/pten/api/include/registry.h" #include "paddle/pten/api/lib/kernel_dispatch.h" #include "paddle/pten/api/lib/utils/allocator.h" +#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/include/core.h" #include "paddle/pten/include/infershape.h" +PT_DECLARE_MODULE(CreationCPU); + +#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) +PT_DECLARE_MODULE(CreationCUDA); +#endif + namespace paddle { namespace experimental { diff --git a/paddle/pten/api/lib/linalg.cc b/paddle/pten/api/lib/linalg.cc index 66c7b570b38..2ea142be716 100644 --- a/paddle/pten/api/lib/linalg.cc +++ b/paddle/pten/api/lib/linalg.cc @@ -24,9 +24,16 @@ limitations under the License. */ #include "paddle/pten/core/convert_utils.h" #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_context.h" +#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/include/core.h" #include "paddle/pten/include/infershape.h" +PT_DECLARE_MODULE(LinalgCPU); + +#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) +PT_DECLARE_MODULE(LinalgCUDA); +#endif + namespace paddle { namespace experimental { diff --git a/paddle/pten/api/lib/manipulation.cc b/paddle/pten/api/lib/manipulation.cc index 62affde5ec2..f3cc647e702 100644 --- a/paddle/pten/api/lib/manipulation.cc +++ b/paddle/pten/api/lib/manipulation.cc @@ -20,9 +20,16 @@ limitations under the License. */ #include "paddle/pten/api/include/registry.h" #include "paddle/pten/api/lib/kernel_dispatch.h" #include "paddle/pten/api/lib/utils/allocator.h" +#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/include/core.h" #include "paddle/pten/infermeta/unary.h" +PT_DECLARE_MODULE(ManipulationCPU); + +#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) +PT_DECLARE_MODULE(ManipulationCUDA); +#endif + namespace paddle { namespace experimental { diff --git a/paddle/pten/api/lib/math.cc b/paddle/pten/api/lib/math.cc index b86391a3e44..e5c955b623c 100644 --- a/paddle/pten/api/lib/math.cc +++ b/paddle/pten/api/lib/math.cc @@ -21,10 +21,17 @@ limitations under the License. */ #include "paddle/pten/api/include/registry.h" #include "paddle/pten/api/lib/kernel_dispatch.h" #include "paddle/pten/api/lib/utils/allocator.h" +#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/include/core.h" #include "paddle/pten/include/infershape.h" #include "paddle/pten/infermeta/unary.h" +PT_DECLARE_MODULE(MathCPU); + +#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) +PT_DECLARE_MODULE(MathCUDA); +#endif + namespace paddle { namespace experimental { diff --git a/paddle/pten/tests/api/test_dot_api.cc b/paddle/pten/tests/api/test_dot_api.cc index 50363a3bf95..e9f623096ed 100644 --- a/paddle/pten/tests/api/test_dot_api.cc +++ b/paddle/pten/tests/api/test_dot_api.cc @@ -21,12 +21,6 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" -PT_DECLARE_MODULE(LinalgCPU); - -#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PT_DECLARE_MODULE(LinalgCUDA); -#endif - namespace framework = paddle::framework; using DDim = paddle::framework::DDim; diff --git a/paddle/pten/tests/api/test_elementwise_api.cc b/paddle/pten/tests/api/test_elementwise_api.cc index 8265624579d..e6ac253e1ad 100644 --- a/paddle/pten/tests/api/test_elementwise_api.cc +++ b/paddle/pten/tests/api/test_elementwise_api.cc @@ -21,12 +21,6 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" -PT_DECLARE_MODULE(MathCPU); - -#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PT_DECLARE_MODULE(MathCUDA); -#endif - namespace framework = paddle::framework; using DDim = paddle::framework::DDim; diff --git a/paddle/pten/tests/api/test_fill_api.cc b/paddle/pten/tests/api/test_fill_api.cc index 0b8d0e2e98d..8eb698f7323 100644 --- a/paddle/pten/tests/api/test_fill_api.cc +++ b/paddle/pten/tests/api/test_fill_api.cc @@ -21,12 +21,6 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" -PT_DECLARE_MODULE(CreationCPU); - -#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PT_DECLARE_MODULE(CreationCUDA); -#endif - namespace framework = paddle::framework; using DDim = paddle::framework::DDim; diff --git a/paddle/pten/tests/api/test_flatten_api.cc b/paddle/pten/tests/api/test_flatten_api.cc index 5bcf60febff..ff4e16ef031 100644 --- a/paddle/pten/tests/api/test_flatten_api.cc +++ b/paddle/pten/tests/api/test_flatten_api.cc @@ -21,12 +21,6 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" -PT_DECLARE_MODULE(ManipulationCPU); - -#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PT_DECLARE_MODULE(ManipulationCUDA); -#endif - namespace framework = paddle::framework; using DDim = paddle::framework::DDim; diff --git a/paddle/pten/tests/api/test_matmul_api.cc b/paddle/pten/tests/api/test_matmul_api.cc index 377173370de..9cf59aa2094 100644 --- a/paddle/pten/tests/api/test_matmul_api.cc +++ b/paddle/pten/tests/api/test_matmul_api.cc @@ -22,12 +22,6 @@ limitations under the License. */ #include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/kernels/cuda/utils.h" -PT_DECLARE_MODULE(LinalgCPU); - -#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PT_DECLARE_MODULE(LinalgCUDA); -#endif - namespace framework = paddle::framework; using DDim = paddle::framework::DDim; diff --git a/paddle/pten/tests/api/test_mean_api.cc b/paddle/pten/tests/api/test_mean_api.cc index ee38e9d49cb..26b6b730193 100644 --- a/paddle/pten/tests/api/test_mean_api.cc +++ b/paddle/pten/tests/api/test_mean_api.cc @@ -21,12 +21,6 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" -PT_DECLARE_MODULE(MathCPU); - -#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PT_DECLARE_MODULE(MathCUDA); -#endif - namespace framework = paddle::framework; using DDim = paddle::framework::DDim; diff --git a/paddle/pten/tests/api/test_slice_api.cc b/paddle/pten/tests/api/test_slice_api.cc index eb8be21bcbb..03d4b142080 100644 --- a/paddle/pten/tests/api/test_slice_api.cc +++ b/paddle/pten/tests/api/test_slice_api.cc @@ -19,12 +19,6 @@ limitations under the License. */ #include "paddle/pten/api/include/tensor.h" #include "paddle/pten/core/kernel_registry.h" -PT_DECLARE_MODULE(CreationCPU); - -#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PT_DECLARE_MODULE(CreationCUDA); -#endif - namespace pten { namespace tests { -- GitLab