From 1c969d2089d434bb5e000c6c1d0122172cc339a9 Mon Sep 17 00:00:00 2001 From: Chen Weihang Date: Tue, 23 Nov 2021 21:28:14 -0600 Subject: [PATCH] [PTen] Standardized unittest namespace (#37456) * standarded unittest namespace * fix detail error --- paddle/pten/api/lib/tensor.cc | 2 +- paddle/pten/tests/api/test_cast_api.cc | 4 ++-- 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_pten_exception.cc | 13 +++++++++---- paddle/pten/tests/api/test_pten_tensor.cc | 4 ++-- paddle/pten/tests/api/test_reshape_api.cc | 4 ++-- paddle/pten/tests/api/test_slice_api.cc | 4 ++-- paddle/pten/tests/api/test_storage.cc | 12 ++++++------ paddle/pten/tests/api/test_tensor_utils.cc | 18 +++++++++--------- paddle/pten/tests/api/test_to_api.cc | 4 ++-- paddle/pten/tests/common/test_backend.cc | 6 ++++++ paddle/pten/tests/common/test_data_layout.cc | 6 ++++++ paddle/pten/tests/common/test_data_type.cc | 6 ++++++ paddle/pten/tests/core/test_kernel_factory.cc | 6 ++++++ paddle/pten/tests/kernels/test_cast_dev_api.cc | 6 ++++++ paddle/pten/tests/kernels/test_copy_dev_api.cc | 6 ++++++ paddle/pten/tests/kernels/test_dot_dev_api.cc | 6 ++++++ .../tests/kernels/test_elementwise_dev_api.cc | 6 ++++++ paddle/pten/tests/kernels/test_fill_dev_api.cc | 6 ++++++ .../pten/tests/kernels/test_flatten_dev_api.cc | 6 ++++++ paddle/pten/tests/kernels/test_mean_dev_api.cc | 6 ++++++ .../pten/tests/kernels/test_reshape_dev_api.cc | 6 ++++++ .../pten/tests/kernels/test_scale_dev_api.cc | 6 ++++++ 28 files changed, 149 insertions(+), 30 deletions(-) diff --git a/paddle/pten/api/lib/tensor.cc b/paddle/pten/api/lib/tensor.cc index 2ec66803d1..8a9ce5e859 100644 --- a/paddle/pten/api/lib/tensor.cc +++ b/paddle/pten/api/lib/tensor.cc @@ -283,7 +283,7 @@ template Tensor Tensor::copy_to(const PlaceType &target_place) const { LOG(WARNING) << "The Tensor's `copy_to` method is deprecated since version " "2.3, and will be removed in version 2.4, please use " - "`copy_to` method without template argumentinstead. " + "`copy_to` method without template argument instead. " "reason: copying a Tensor to another device does not need " "to specify the data type template argument."; return copy_to(ConvertExtPlaceToBackend(target_place), /*blocking=*/false); diff --git a/paddle/pten/tests/api/test_cast_api.cc b/paddle/pten/tests/api/test_cast_api.cc index 1f7c238817..ef110e8e33 100644 --- a/paddle/pten/tests/api/test_cast_api.cc +++ b/paddle/pten/tests/api/test_cast_api.cc @@ -22,7 +22,7 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" -namespace pten { +namespace paddle { namespace tests { namespace framework = paddle::framework; @@ -85,4 +85,4 @@ TEST(Tensor, cast) { } } // namespace tests -} // namespace pten +} // namespace paddle diff --git a/paddle/pten/tests/api/test_dot_api.cc b/paddle/pten/tests/api/test_dot_api.cc index e9f623096e..972e065596 100644 --- a/paddle/pten/tests/api/test_dot_api.cc +++ b/paddle/pten/tests/api/test_dot_api.cc @@ -21,6 +21,9 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" +namespace paddle { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -76,3 +79,6 @@ TEST(API, dot) { ASSERT_NEAR(expect_result[1], actual_result1, 1e-6f); ASSERT_NEAR(expect_result[2], actual_result2, 1e-6f); } + +} // namespace tests +} // namespace paddle diff --git a/paddle/pten/tests/api/test_elementwise_api.cc b/paddle/pten/tests/api/test_elementwise_api.cc index be4e45370c..795a0176c2 100644 --- a/paddle/pten/tests/api/test_elementwise_api.cc +++ b/paddle/pten/tests/api/test_elementwise_api.cc @@ -21,6 +21,9 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" +namespace paddle { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -185,3 +188,6 @@ TEST(API, divide) { ASSERT_NEAR(expect_result[0][1], actual_result1, 1e-6f); ASSERT_NEAR(expect_result[1][0], actual_result2, 1e-6f); } + +} // namespace tests +} // namespace paddle diff --git a/paddle/pten/tests/api/test_fill_api.cc b/paddle/pten/tests/api/test_fill_api.cc index 8eb698f732..552c5e0ef9 100644 --- a/paddle/pten/tests/api/test_fill_api.cc +++ b/paddle/pten/tests/api/test_fill_api.cc @@ -21,6 +21,9 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" +namespace paddle { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -151,3 +154,6 @@ TEST(API, full) { ASSERT_NEAR(actual_result[i], val, 1e-6f); } } + +} // namespace tests +} // namespace paddle diff --git a/paddle/pten/tests/api/test_flatten_api.cc b/paddle/pten/tests/api/test_flatten_api.cc index ff4e16ef03..2fcf00efc6 100644 --- a/paddle/pten/tests/api/test_flatten_api.cc +++ b/paddle/pten/tests/api/test_flatten_api.cc @@ -21,6 +21,9 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" +namespace paddle { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -64,3 +67,6 @@ TEST(API, flatten) { } ASSERT_EQ(value_equal, true); } + +} // namespace tests +} // namespace paddle diff --git a/paddle/pten/tests/api/test_matmul_api.cc b/paddle/pten/tests/api/test_matmul_api.cc index 9cf59aa209..d3652db54e 100644 --- a/paddle/pten/tests/api/test_matmul_api.cc +++ b/paddle/pten/tests/api/test_matmul_api.cc @@ -22,6 +22,9 @@ limitations under the License. */ #include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/kernels/cuda/utils.h" +namespace paddle { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -152,3 +155,6 @@ TEST(API, matmul_cuda) { } #endif + +} // namespace tests +} // namespace paddle diff --git a/paddle/pten/tests/api/test_mean_api.cc b/paddle/pten/tests/api/test_mean_api.cc index 26b6b73019..aecbdddc25 100644 --- a/paddle/pten/tests/api/test_mean_api.cc +++ b/paddle/pten/tests/api/test_mean_api.cc @@ -21,6 +21,9 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" +namespace paddle { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -61,3 +64,6 @@ TEST(API, mean) { auto actual_result = dense_out->data()[0]; ASSERT_NEAR(expect_result, actual_result, 1e-6f); } + +} // namespace tests +} // namespace paddle diff --git a/paddle/pten/tests/api/test_pten_exception.cc b/paddle/pten/tests/api/test_pten_exception.cc index a987e9bc31..1096d719c2 100644 --- a/paddle/pten/tests/api/test_pten_exception.cc +++ b/paddle/pten/tests/api/test_pten_exception.cc @@ -14,6 +14,9 @@ limitations under the License. */ #include "gtest/gtest.h" #include "paddle/pten/api/ext/exception.h" +namespace paddle { +namespace tests { + TEST(PD_THROW, empty) { bool caught_exception = false; try { @@ -23,12 +26,11 @@ TEST(PD_THROW, empty) { std::string err_msg = e.what(); EXPECT_TRUE(err_msg.find("An error occurred.") != std::string::npos); #if _WIN32 - EXPECT_TRUE(err_msg.find("tests\\api\\test_pten_exception.cc:20") != + EXPECT_TRUE(err_msg.find("tests\\api\\test_pten_exception.cc") != std::string::npos); #else - EXPECT_TRUE( - err_msg.find("paddle/pten/tests/api/test_pten_exception.cc:20") != - std::string::npos); + EXPECT_TRUE(err_msg.find("paddle/pten/tests/api/test_pten_exception.cc") != + std::string::npos); #endif } EXPECT_TRUE(caught_exception); @@ -156,3 +158,6 @@ TEST(PD_CHECK, FAILED) { } EXPECT_TRUE(caught_exception); } + +} // namespace tests +} // namespace paddle diff --git a/paddle/pten/tests/api/test_pten_tensor.cc b/paddle/pten/tests/api/test_pten_tensor.cc index 9cadd2664b..8cdd769558 100644 --- a/paddle/pten/tests/api/test_pten_tensor.cc +++ b/paddle/pten/tests/api/test_pten_tensor.cc @@ -17,7 +17,7 @@ #include "paddle/pten/api/include/tensor.h" #include "paddle/pten/api/lib/ext_compat_utils.h" -namespace pten { +namespace paddle { namespace tests { template @@ -224,4 +224,4 @@ TEST(PtenTensor, All) { } } // namespace tests -} // namespace pten +} // namespace paddle diff --git a/paddle/pten/tests/api/test_reshape_api.cc b/paddle/pten/tests/api/test_reshape_api.cc index 719bc4a3f0..643551ec1c 100644 --- a/paddle/pten/tests/api/test_reshape_api.cc +++ b/paddle/pten/tests/api/test_reshape_api.cc @@ -27,7 +27,7 @@ PT_DECLARE_MODULE(ManipulationCPU); PT_DECLARE_MODULE(ManipulationCUDA); #endif -namespace pten { +namespace paddle { namespace tests { namespace framework = paddle::framework; @@ -86,4 +86,4 @@ TEST(Tensor, old_reshape) { } } // namespace tests -} // namespace pten +} // namespace paddle diff --git a/paddle/pten/tests/api/test_slice_api.cc b/paddle/pten/tests/api/test_slice_api.cc index 03d4b14208..31a96c392d 100644 --- a/paddle/pten/tests/api/test_slice_api.cc +++ b/paddle/pten/tests/api/test_slice_api.cc @@ -19,7 +19,7 @@ limitations under the License. */ #include "paddle/pten/api/include/tensor.h" #include "paddle/pten/core/kernel_registry.h" -namespace pten { +namespace paddle { namespace tests { TEST(Tensor, slice) { @@ -41,4 +41,4 @@ TEST(Tensor, slice) { } } // namespace tests -} // namespace pten +} // namespace paddle diff --git a/paddle/pten/tests/api/test_storage.cc b/paddle/pten/tests/api/test_storage.cc index fc95f95f26..1a5d95f941 100644 --- a/paddle/pten/tests/api/test_storage.cc +++ b/paddle/pten/tests/api/test_storage.cc @@ -20,13 +20,12 @@ limitations under the License. */ #include "paddle/pten/api/lib/utils/storage.h" namespace paddle { -namespace experimental { namespace tests { TEST(host_storage, external_stroage) { const size_t size{100}; - const auto a = - std::make_shared(paddle::platform::CPUPlace()); + const auto a = std::make_shared( + paddle::platform::CPUPlace()); pten::intrusive_ptr in_storage = pten::make_intrusive(a, size); char* data = static_cast(in_storage->data()); @@ -35,7 +34,8 @@ TEST(host_storage, external_stroage) { } const size_t delta{1}; const size_t n{10}; - auto ex_storage = pten::make_intrusive(in_storage, delta, n); + auto ex_storage = + pten::make_intrusive(in_storage, delta, n); CHECK_EQ(ex_storage->size(), n); CHECK(paddle::platform::is_cpu_place(ex_storage->place())); CHECK(!ex_storage->OwnsMemory()); @@ -51,7 +51,7 @@ TEST(host_storage, external_vector) { } const size_t delta{1}; const size_t n{10}; - auto ex_storage = pten::make_intrusive( + auto ex_storage = pten::make_intrusive( data.data(), n, paddle::platform::CPUPlace()); CHECK_EQ(ex_storage->size(), n); CHECK(paddle::platform::is_cpu_place(ex_storage->place())); @@ -60,6 +60,6 @@ TEST(host_storage, external_vector) { CHECK_EQ(data[i], static_cast(i)); } } + } // namespace tests -} // namespace experimental } // namespace paddle diff --git a/paddle/pten/tests/api/test_tensor_utils.cc b/paddle/pten/tests/api/test_tensor_utils.cc index cebb0fc07e..c445e18679 100644 --- a/paddle/pten/tests/api/test_tensor_utils.cc +++ b/paddle/pten/tests/api/test_tensor_utils.cc @@ -17,7 +17,6 @@ limitations under the License. */ #include "paddle/pten/api/lib/utils/tensor_utils.h" namespace paddle { -namespace experimental { namespace tests { using DDim = paddle::framework::DDim; @@ -34,7 +33,8 @@ TEST(tensor_utils, dense_tensor_to_lod_tensor) { const std::vector> lod{{0, 2}}; DenseTensorMeta meta(dtype, dims, layout, lod); - auto alloc = std::make_shared(platform::CPUPlace()); + auto alloc = + std::make_shared(platform::CPUPlace()); DenseTensor dense_tensor(alloc, meta); float* data = dense_tensor.mutable_data(); @@ -42,7 +42,7 @@ TEST(tensor_utils, dense_tensor_to_lod_tensor) { data[1] = 2.1f; framework::LoDTensor lod_tensor; - MovesStorage(&dense_tensor, &lod_tensor); + experimental::MovesStorage(&dense_tensor, &lod_tensor); CHECK(dense_tensor.lod().size() == lod_tensor.lod().size()); CHECK(dense_tensor.lod()[0] == @@ -55,7 +55,7 @@ TEST(tensor_utils, dense_tensor_to_lod_tensor) { CHECK(lod_tensor.data()[0] == 1.0f); CHECK(lod_tensor.data()[1] == 2.1f); - auto dense_tensor_1 = MakePtenDenseTensor(lod_tensor); + auto dense_tensor_1 = experimental::MakePtenDenseTensor(lod_tensor); CHECK(dense_tensor_1->dims() == dims); CHECK(dense_tensor_1->dtype() == dtype); CHECK(dense_tensor_1->layout() == layout); @@ -72,7 +72,8 @@ TEST(tensor_utils, dense_tensor_to_tensor) { const DataLayout layout{DataLayout::NCHW}; DenseTensorMeta meta(dtype, dims, layout); - auto alloc = std::make_shared(platform::CPUPlace()); + auto alloc = + std::make_shared(platform::CPUPlace()); DenseTensor dense_tensor(alloc, meta); float* data = dense_tensor.mutable_data(); @@ -80,7 +81,7 @@ TEST(tensor_utils, dense_tensor_to_tensor) { data[1] = 2.1f; framework::Tensor tensor; - MovesStorage(&dense_tensor, &tensor); + experimental::MovesStorage(&dense_tensor, &tensor); CHECK(dense_tensor.dtype() == pten::TransToPtenDataType(tensor.type())); CHECK(dense_tensor.layout() == pten::TransToPtenDataLayout(tensor.layout())); @@ -89,7 +90,7 @@ TEST(tensor_utils, dense_tensor_to_tensor) { CHECK(tensor.data()[0] == 1.0f); CHECK(tensor.data()[1] == 2.1f); - auto dense_tensor_1 = MakePtenDenseTensor(tensor); + auto dense_tensor_1 = experimental::MakePtenDenseTensor(tensor); CHECK(dense_tensor_1->dims() == dims); CHECK(dense_tensor_1->dtype() == dtype); CHECK(dense_tensor_1->layout() == layout); @@ -114,11 +115,10 @@ TEST(PtenUtils, VarToPtTensor) { auto tensor_def = pten::TensorArgDef( expect_backend, pten::DataLayout::NCHW, pten::DataType::INT32); // 2. test API - auto tensor_x = MakePtenTensorBaseFromVar(v, tensor_def); + auto tensor_x = experimental::MakePtenTensorBaseFromVar(v, tensor_def); // 3. check result ASSERT_EQ(tensor_x->dtype(), pten::DataType::INT32); } } // namespace tests -} // namespace experimental } // namespace paddle diff --git a/paddle/pten/tests/api/test_to_api.cc b/paddle/pten/tests/api/test_to_api.cc index d08a78cf4c..5bb6f386c7 100644 --- a/paddle/pten/tests/api/test_to_api.cc +++ b/paddle/pten/tests/api/test_to_api.cc @@ -21,7 +21,7 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" -namespace pten { +namespace paddle { namespace tests { namespace framework = paddle::framework; @@ -107,4 +107,4 @@ TEST(Tensor, old_copy_to) { } } // namespace tests -} // namespace pten +} // namespace paddle diff --git a/paddle/pten/tests/common/test_backend.cc b/paddle/pten/tests/common/test_backend.cc index 0aabf22608..148785d4b6 100644 --- a/paddle/pten/tests/common/test_backend.cc +++ b/paddle/pten/tests/common/test_backend.cc @@ -18,6 +18,9 @@ limitations under the License. */ #include "paddle/pten/api/ext/exception.h" #include "paddle/pten/common/backend.h" +namespace pten { +namespace tests { + TEST(Backend, OStream) { std::ostringstream oss; oss << pten::Backend::UNDEFINED; @@ -48,3 +51,6 @@ TEST(Backend, OStream) { EXPECT_TRUE(ex_msg.find("Invalid enum backend type") != std::string::npos); } } + +} // namespace tests +} // namespace pten diff --git a/paddle/pten/tests/common/test_data_layout.cc b/paddle/pten/tests/common/test_data_layout.cc index 4de75a7bd7..22c503b591 100644 --- a/paddle/pten/tests/common/test_data_layout.cc +++ b/paddle/pten/tests/common/test_data_layout.cc @@ -19,6 +19,9 @@ limitations under the License. */ #include "paddle/pten/api/ext/exception.h" #include "paddle/pten/common/layout.h" +namespace pten { +namespace tests { + TEST(DataLayout, OStream) { std::ostringstream oss; oss << pten::DataLayout::UNDEFINED; @@ -44,3 +47,6 @@ TEST(DataLayout, OStream) { std::string::npos); } } + +} // namespace tests +} // namespace pten diff --git a/paddle/pten/tests/common/test_data_type.cc b/paddle/pten/tests/common/test_data_type.cc index 95957260de..2f1d2ff86b 100644 --- a/paddle/pten/tests/common/test_data_type.cc +++ b/paddle/pten/tests/common/test_data_type.cc @@ -19,6 +19,9 @@ limitations under the License. */ #include "paddle/pten/api/ext/exception.h" #include "paddle/pten/common/data_type.h" +namespace pten { +namespace tests { + TEST(DataType, OStream) { std::ostringstream oss; oss << pten::DataType::UNDEFINED; @@ -67,3 +70,6 @@ TEST(DataType, OStream) { EXPECT_TRUE(ex_msg.find("Invalid enum data type") != std::string::npos); } } + +} // namespace tests +} // namespace pten diff --git a/paddle/pten/tests/core/test_kernel_factory.cc b/paddle/pten/tests/core/test_kernel_factory.cc index c1c17171b5..5ee4b17c9d 100644 --- a/paddle/pten/tests/core/test_kernel_factory.cc +++ b/paddle/pten/tests/core/test_kernel_factory.cc @@ -19,6 +19,9 @@ limitations under the License. */ #include "gtest/gtest.h" +namespace pten { +namespace tests { + // TODO(chenweihang): add more unittests later TEST(KernelName, ConstructAndOStream) { @@ -45,3 +48,6 @@ TEST(KernelKey, ConstructAndOStream) { // EXPECT_EQ(oss.str(), "scale.host"); oss.flush(); } + +} // namespace tests +} // namespace pten diff --git a/paddle/pten/tests/kernels/test_cast_dev_api.cc b/paddle/pten/tests/kernels/test_cast_dev_api.cc index 64b60a540f..5bbaf2a2c3 100644 --- a/paddle/pten/tests/kernels/test_cast_dev_api.cc +++ b/paddle/pten/tests/kernels/test_cast_dev_api.cc @@ -23,6 +23,9 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" +namespace pten { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -66,3 +69,6 @@ TEST(DEV_API, cast) { ASSERT_NEAR(actual_result[i], static_cast(dense_x_data[i]), 1e-6f); } } + +} // namespace tests +} // namespace pten diff --git a/paddle/pten/tests/kernels/test_copy_dev_api.cc b/paddle/pten/tests/kernels/test_copy_dev_api.cc index 16192be0e1..9cc994c569 100644 --- a/paddle/pten/tests/kernels/test_copy_dev_api.cc +++ b/paddle/pten/tests/kernels/test_copy_dev_api.cc @@ -21,6 +21,9 @@ limitations under the License. */ #include "paddle/pten/api/lib/utils/allocator.h" #include "paddle/pten/core/dense_tensor.h" +namespace pten { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -61,3 +64,6 @@ TEST(DEV_API, copy) { ASSERT_EQ(dense_src->data()[i], dense_dst->data()[i]); } } + +} // namespace tests +} // namespace pten diff --git a/paddle/pten/tests/kernels/test_dot_dev_api.cc b/paddle/pten/tests/kernels/test_dot_dev_api.cc index 5485ef2843..3fda81d3b5 100644 --- a/paddle/pten/tests/kernels/test_dot_dev_api.cc +++ b/paddle/pten/tests/kernels/test_dot_dev_api.cc @@ -21,6 +21,9 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" +namespace pten { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -73,3 +76,6 @@ TEST(DEV_API, dot) { ASSERT_NEAR(expect_result[1], actual_result1, 1e-6f); ASSERT_NEAR(expect_result[2], actual_result2, 1e-6f); } + +} // namespace tests +} // namespace pten diff --git a/paddle/pten/tests/kernels/test_elementwise_dev_api.cc b/paddle/pten/tests/kernels/test_elementwise_dev_api.cc index 6e9c25e23f..b22a37f1bb 100644 --- a/paddle/pten/tests/kernels/test_elementwise_dev_api.cc +++ b/paddle/pten/tests/kernels/test_elementwise_dev_api.cc @@ -21,6 +21,9 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" +namespace pten { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -182,3 +185,6 @@ TEST(DEV_API, divide) { ASSERT_NEAR(expect_result[0][1], actual_result1, 1e-6f); ASSERT_NEAR(expect_result[1][0], actual_result2, 1e-6f); } + +} // namespace tests +} // namespace pten diff --git a/paddle/pten/tests/kernels/test_fill_dev_api.cc b/paddle/pten/tests/kernels/test_fill_dev_api.cc index aa66877881..90a16e3c46 100644 --- a/paddle/pten/tests/kernels/test_fill_dev_api.cc +++ b/paddle/pten/tests/kernels/test_fill_dev_api.cc @@ -21,6 +21,9 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" +namespace pten { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -58,3 +61,6 @@ TEST(DEV_API, fill_any_like) { ASSERT_NEAR(actual_result[i], val, 1e-6f); } } + +} // namespace tests +} // namespace pten diff --git a/paddle/pten/tests/kernels/test_flatten_dev_api.cc b/paddle/pten/tests/kernels/test_flatten_dev_api.cc index a9be6108d2..a351be3cf6 100644 --- a/paddle/pten/tests/kernels/test_flatten_dev_api.cc +++ b/paddle/pten/tests/kernels/test_flatten_dev_api.cc @@ -21,6 +21,9 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" +namespace pten { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -67,3 +70,6 @@ TEST(DEV_API, flatten) { } ASSERT_EQ(value_equal, true); } + +} // namespace tests +} // namespace pten diff --git a/paddle/pten/tests/kernels/test_mean_dev_api.cc b/paddle/pten/tests/kernels/test_mean_dev_api.cc index b16d339e18..4dd3f0227d 100644 --- a/paddle/pten/tests/kernels/test_mean_dev_api.cc +++ b/paddle/pten/tests/kernels/test_mean_dev_api.cc @@ -21,6 +21,9 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" +namespace pten { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -56,3 +59,6 @@ TEST(DEV_API, mean) { auto actual_result = out.data()[0]; ASSERT_NEAR(expect_result, actual_result, 1e-6f); } + +} // namespace tests +} // namespace pten diff --git a/paddle/pten/tests/kernels/test_reshape_dev_api.cc b/paddle/pten/tests/kernels/test_reshape_dev_api.cc index b227d3b009..64efdc6f67 100644 --- a/paddle/pten/tests/kernels/test_reshape_dev_api.cc +++ b/paddle/pten/tests/kernels/test_reshape_dev_api.cc @@ -21,6 +21,9 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" +namespace pten { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -65,3 +68,6 @@ TEST(DEV_API, reshape) { } ASSERT_EQ(value_equal, true); } + +} // namespace tests +} // namespace pten diff --git a/paddle/pten/tests/kernels/test_scale_dev_api.cc b/paddle/pten/tests/kernels/test_scale_dev_api.cc index b876921372..ac2922b36f 100644 --- a/paddle/pten/tests/kernels/test_scale_dev_api.cc +++ b/paddle/pten/tests/kernels/test_scale_dev_api.cc @@ -21,6 +21,9 @@ limitations under the License. */ #include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/kernel_registry.h" +namespace pten { +namespace tests { + namespace framework = paddle::framework; using DDim = paddle::framework::DDim; @@ -108,3 +111,6 @@ TEST(DEV_API, scale_host) { auto actual_result = out.data()[11]; ASSERT_NEAR(expect_result, actual_result, 1e-6f); } + +} // namespace tests +} // namespace pten -- GitLab