未验证 提交 1c969d20 编写于 作者: C Chen Weihang 提交者: GitHub

[PTen] Standardized unittest namespace (#37456)

* standarded unittest namespace

* fix detail error
上级 52edad6a
...@@ -283,7 +283,7 @@ template <typename T> ...@@ -283,7 +283,7 @@ template <typename T>
Tensor Tensor::copy_to(const PlaceType &target_place) const { Tensor Tensor::copy_to(const PlaceType &target_place) const {
LOG(WARNING) << "The Tensor's `copy_to` method is deprecated since version " LOG(WARNING) << "The Tensor's `copy_to` method is deprecated since version "
"2.3, and will be removed in version 2.4, please use " "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 " "reason: copying a Tensor to another device does not need "
"to specify the data type template argument."; "to specify the data type template argument.";
return copy_to(ConvertExtPlaceToBackend(target_place), /*blocking=*/false); return copy_to(ConvertExtPlaceToBackend(target_place), /*blocking=*/false);
......
...@@ -22,7 +22,7 @@ limitations under the License. */ ...@@ -22,7 +22,7 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace pten { namespace paddle {
namespace tests { namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
...@@ -85,4 +85,4 @@ TEST(Tensor, cast) { ...@@ -85,4 +85,4 @@ TEST(Tensor, cast) {
} }
} // namespace tests } // namespace tests
} // namespace pten } // namespace paddle
...@@ -21,6 +21,9 @@ limitations under the License. */ ...@@ -21,6 +21,9 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace paddle {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -76,3 +79,6 @@ TEST(API, dot) { ...@@ -76,3 +79,6 @@ TEST(API, dot) {
ASSERT_NEAR(expect_result[1], actual_result1, 1e-6f); ASSERT_NEAR(expect_result[1], actual_result1, 1e-6f);
ASSERT_NEAR(expect_result[2], actual_result2, 1e-6f); ASSERT_NEAR(expect_result[2], actual_result2, 1e-6f);
} }
} // namespace tests
} // namespace paddle
...@@ -21,6 +21,9 @@ limitations under the License. */ ...@@ -21,6 +21,9 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace paddle {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -185,3 +188,6 @@ TEST(API, divide) { ...@@ -185,3 +188,6 @@ TEST(API, divide) {
ASSERT_NEAR(expect_result[0][1], actual_result1, 1e-6f); ASSERT_NEAR(expect_result[0][1], actual_result1, 1e-6f);
ASSERT_NEAR(expect_result[1][0], actual_result2, 1e-6f); ASSERT_NEAR(expect_result[1][0], actual_result2, 1e-6f);
} }
} // namespace tests
} // namespace paddle
...@@ -21,6 +21,9 @@ limitations under the License. */ ...@@ -21,6 +21,9 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace paddle {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -151,3 +154,6 @@ TEST(API, full) { ...@@ -151,3 +154,6 @@ TEST(API, full) {
ASSERT_NEAR(actual_result[i], val, 1e-6f); ASSERT_NEAR(actual_result[i], val, 1e-6f);
} }
} }
} // namespace tests
} // namespace paddle
...@@ -21,6 +21,9 @@ limitations under the License. */ ...@@ -21,6 +21,9 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace paddle {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -64,3 +67,6 @@ TEST(API, flatten) { ...@@ -64,3 +67,6 @@ TEST(API, flatten) {
} }
ASSERT_EQ(value_equal, true); ASSERT_EQ(value_equal, true);
} }
} // namespace tests
} // namespace paddle
...@@ -22,6 +22,9 @@ limitations under the License. */ ...@@ -22,6 +22,9 @@ limitations under the License. */
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/kernels/cuda/utils.h" #include "paddle/pten/kernels/cuda/utils.h"
namespace paddle {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -152,3 +155,6 @@ TEST(API, matmul_cuda) { ...@@ -152,3 +155,6 @@ TEST(API, matmul_cuda) {
} }
#endif #endif
} // namespace tests
} // namespace paddle
...@@ -21,6 +21,9 @@ limitations under the License. */ ...@@ -21,6 +21,9 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace paddle {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -61,3 +64,6 @@ TEST(API, mean) { ...@@ -61,3 +64,6 @@ TEST(API, mean) {
auto actual_result = dense_out->data<float>()[0]; auto actual_result = dense_out->data<float>()[0];
ASSERT_NEAR(expect_result, actual_result, 1e-6f); ASSERT_NEAR(expect_result, actual_result, 1e-6f);
} }
} // namespace tests
} // namespace paddle
...@@ -14,6 +14,9 @@ limitations under the License. */ ...@@ -14,6 +14,9 @@ limitations under the License. */
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "paddle/pten/api/ext/exception.h" #include "paddle/pten/api/ext/exception.h"
namespace paddle {
namespace tests {
TEST(PD_THROW, empty) { TEST(PD_THROW, empty) {
bool caught_exception = false; bool caught_exception = false;
try { try {
...@@ -23,12 +26,11 @@ TEST(PD_THROW, empty) { ...@@ -23,12 +26,11 @@ TEST(PD_THROW, empty) {
std::string err_msg = e.what(); std::string err_msg = e.what();
EXPECT_TRUE(err_msg.find("An error occurred.") != std::string::npos); EXPECT_TRUE(err_msg.find("An error occurred.") != std::string::npos);
#if _WIN32 #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); std::string::npos);
#else #else
EXPECT_TRUE( EXPECT_TRUE(err_msg.find("paddle/pten/tests/api/test_pten_exception.cc") !=
err_msg.find("paddle/pten/tests/api/test_pten_exception.cc:20") != std::string::npos);
std::string::npos);
#endif #endif
} }
EXPECT_TRUE(caught_exception); EXPECT_TRUE(caught_exception);
...@@ -156,3 +158,6 @@ TEST(PD_CHECK, FAILED) { ...@@ -156,3 +158,6 @@ TEST(PD_CHECK, FAILED) {
} }
EXPECT_TRUE(caught_exception); EXPECT_TRUE(caught_exception);
} }
} // namespace tests
} // namespace paddle
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "paddle/pten/api/include/tensor.h" #include "paddle/pten/api/include/tensor.h"
#include "paddle/pten/api/lib/ext_compat_utils.h" #include "paddle/pten/api/lib/ext_compat_utils.h"
namespace pten { namespace paddle {
namespace tests { namespace tests {
template <typename T> template <typename T>
...@@ -224,4 +224,4 @@ TEST(PtenTensor, All) { ...@@ -224,4 +224,4 @@ TEST(PtenTensor, All) {
} }
} // namespace tests } // namespace tests
} // namespace pten } // namespace paddle
...@@ -27,7 +27,7 @@ PT_DECLARE_MODULE(ManipulationCPU); ...@@ -27,7 +27,7 @@ PT_DECLARE_MODULE(ManipulationCPU);
PT_DECLARE_MODULE(ManipulationCUDA); PT_DECLARE_MODULE(ManipulationCUDA);
#endif #endif
namespace pten { namespace paddle {
namespace tests { namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
...@@ -86,4 +86,4 @@ TEST(Tensor, old_reshape) { ...@@ -86,4 +86,4 @@ TEST(Tensor, old_reshape) {
} }
} // namespace tests } // namespace tests
} // namespace pten } // namespace paddle
...@@ -19,7 +19,7 @@ limitations under the License. */ ...@@ -19,7 +19,7 @@ limitations under the License. */
#include "paddle/pten/api/include/tensor.h" #include "paddle/pten/api/include/tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace pten { namespace paddle {
namespace tests { namespace tests {
TEST(Tensor, slice) { TEST(Tensor, slice) {
...@@ -41,4 +41,4 @@ TEST(Tensor, slice) { ...@@ -41,4 +41,4 @@ TEST(Tensor, slice) {
} }
} // namespace tests } // namespace tests
} // namespace pten } // namespace paddle
...@@ -20,13 +20,12 @@ limitations under the License. */ ...@@ -20,13 +20,12 @@ limitations under the License. */
#include "paddle/pten/api/lib/utils/storage.h" #include "paddle/pten/api/lib/utils/storage.h"
namespace paddle { namespace paddle {
namespace experimental {
namespace tests { namespace tests {
TEST(host_storage, external_stroage) { TEST(host_storage, external_stroage) {
const size_t size{100}; const size_t size{100};
const auto a = const auto a = std::make_shared<experimental::DefaultAllocator>(
std::make_shared<DefaultAllocator>(paddle::platform::CPUPlace()); paddle::platform::CPUPlace());
pten::intrusive_ptr<pten::Storage> in_storage = pten::intrusive_ptr<pten::Storage> in_storage =
pten::make_intrusive<pten::TensorStorage>(a, size); pten::make_intrusive<pten::TensorStorage>(a, size);
char* data = static_cast<char*>(in_storage->data()); char* data = static_cast<char*>(in_storage->data());
...@@ -35,7 +34,8 @@ TEST(host_storage, external_stroage) { ...@@ -35,7 +34,8 @@ TEST(host_storage, external_stroage) {
} }
const size_t delta{1}; const size_t delta{1};
const size_t n{10}; const size_t n{10};
auto ex_storage = pten::make_intrusive<ExternalStorage>(in_storage, delta, n); auto ex_storage =
pten::make_intrusive<experimental::ExternalStorage>(in_storage, delta, n);
CHECK_EQ(ex_storage->size(), n); CHECK_EQ(ex_storage->size(), n);
CHECK(paddle::platform::is_cpu_place(ex_storage->place())); CHECK(paddle::platform::is_cpu_place(ex_storage->place()));
CHECK(!ex_storage->OwnsMemory()); CHECK(!ex_storage->OwnsMemory());
...@@ -51,7 +51,7 @@ TEST(host_storage, external_vector) { ...@@ -51,7 +51,7 @@ TEST(host_storage, external_vector) {
} }
const size_t delta{1}; const size_t delta{1};
const size_t n{10}; const size_t n{10};
auto ex_storage = pten::make_intrusive<ExternalStorage>( auto ex_storage = pten::make_intrusive<experimental::ExternalStorage>(
data.data(), n, paddle::platform::CPUPlace()); data.data(), n, paddle::platform::CPUPlace());
CHECK_EQ(ex_storage->size(), n); CHECK_EQ(ex_storage->size(), n);
CHECK(paddle::platform::is_cpu_place(ex_storage->place())); CHECK(paddle::platform::is_cpu_place(ex_storage->place()));
...@@ -60,6 +60,6 @@ TEST(host_storage, external_vector) { ...@@ -60,6 +60,6 @@ TEST(host_storage, external_vector) {
CHECK_EQ(data[i], static_cast<char>(i)); CHECK_EQ(data[i], static_cast<char>(i));
} }
} }
} // namespace tests } // namespace tests
} // namespace experimental
} // namespace paddle } // namespace paddle
...@@ -17,7 +17,6 @@ limitations under the License. */ ...@@ -17,7 +17,6 @@ limitations under the License. */
#include "paddle/pten/api/lib/utils/tensor_utils.h" #include "paddle/pten/api/lib/utils/tensor_utils.h"
namespace paddle { namespace paddle {
namespace experimental {
namespace tests { namespace tests {
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -34,7 +33,8 @@ TEST(tensor_utils, dense_tensor_to_lod_tensor) { ...@@ -34,7 +33,8 @@ TEST(tensor_utils, dense_tensor_to_lod_tensor) {
const std::vector<std::vector<size_t>> lod{{0, 2}}; const std::vector<std::vector<size_t>> lod{{0, 2}};
DenseTensorMeta meta(dtype, dims, layout, lod); DenseTensorMeta meta(dtype, dims, layout, lod);
auto alloc = std::make_shared<DefaultAllocator>(platform::CPUPlace()); auto alloc =
std::make_shared<experimental::DefaultAllocator>(platform::CPUPlace());
DenseTensor dense_tensor(alloc, meta); DenseTensor dense_tensor(alloc, meta);
float* data = dense_tensor.mutable_data<float>(); float* data = dense_tensor.mutable_data<float>();
...@@ -42,7 +42,7 @@ TEST(tensor_utils, dense_tensor_to_lod_tensor) { ...@@ -42,7 +42,7 @@ TEST(tensor_utils, dense_tensor_to_lod_tensor) {
data[1] = 2.1f; data[1] = 2.1f;
framework::LoDTensor lod_tensor; 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().size() == lod_tensor.lod().size());
CHECK(dense_tensor.lod()[0] == CHECK(dense_tensor.lod()[0] ==
...@@ -55,7 +55,7 @@ TEST(tensor_utils, dense_tensor_to_lod_tensor) { ...@@ -55,7 +55,7 @@ TEST(tensor_utils, dense_tensor_to_lod_tensor) {
CHECK(lod_tensor.data<float>()[0] == 1.0f); CHECK(lod_tensor.data<float>()[0] == 1.0f);
CHECK(lod_tensor.data<float>()[1] == 2.1f); CHECK(lod_tensor.data<float>()[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->dims() == dims);
CHECK(dense_tensor_1->dtype() == dtype); CHECK(dense_tensor_1->dtype() == dtype);
CHECK(dense_tensor_1->layout() == layout); CHECK(dense_tensor_1->layout() == layout);
...@@ -72,7 +72,8 @@ TEST(tensor_utils, dense_tensor_to_tensor) { ...@@ -72,7 +72,8 @@ TEST(tensor_utils, dense_tensor_to_tensor) {
const DataLayout layout{DataLayout::NCHW}; const DataLayout layout{DataLayout::NCHW};
DenseTensorMeta meta(dtype, dims, layout); DenseTensorMeta meta(dtype, dims, layout);
auto alloc = std::make_shared<DefaultAllocator>(platform::CPUPlace()); auto alloc =
std::make_shared<experimental::DefaultAllocator>(platform::CPUPlace());
DenseTensor dense_tensor(alloc, meta); DenseTensor dense_tensor(alloc, meta);
float* data = dense_tensor.mutable_data<float>(); float* data = dense_tensor.mutable_data<float>();
...@@ -80,7 +81,7 @@ TEST(tensor_utils, dense_tensor_to_tensor) { ...@@ -80,7 +81,7 @@ TEST(tensor_utils, dense_tensor_to_tensor) {
data[1] = 2.1f; data[1] = 2.1f;
framework::Tensor tensor; framework::Tensor tensor;
MovesStorage(&dense_tensor, &tensor); experimental::MovesStorage(&dense_tensor, &tensor);
CHECK(dense_tensor.dtype() == pten::TransToPtenDataType(tensor.type())); CHECK(dense_tensor.dtype() == pten::TransToPtenDataType(tensor.type()));
CHECK(dense_tensor.layout() == pten::TransToPtenDataLayout(tensor.layout())); CHECK(dense_tensor.layout() == pten::TransToPtenDataLayout(tensor.layout()));
...@@ -89,7 +90,7 @@ TEST(tensor_utils, dense_tensor_to_tensor) { ...@@ -89,7 +90,7 @@ TEST(tensor_utils, dense_tensor_to_tensor) {
CHECK(tensor.data<float>()[0] == 1.0f); CHECK(tensor.data<float>()[0] == 1.0f);
CHECK(tensor.data<float>()[1] == 2.1f); CHECK(tensor.data<float>()[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->dims() == dims);
CHECK(dense_tensor_1->dtype() == dtype); CHECK(dense_tensor_1->dtype() == dtype);
CHECK(dense_tensor_1->layout() == layout); CHECK(dense_tensor_1->layout() == layout);
...@@ -114,11 +115,10 @@ TEST(PtenUtils, VarToPtTensor) { ...@@ -114,11 +115,10 @@ TEST(PtenUtils, VarToPtTensor) {
auto tensor_def = pten::TensorArgDef( auto tensor_def = pten::TensorArgDef(
expect_backend, pten::DataLayout::NCHW, pten::DataType::INT32); expect_backend, pten::DataLayout::NCHW, pten::DataType::INT32);
// 2. test API // 2. test API
auto tensor_x = MakePtenTensorBaseFromVar(v, tensor_def); auto tensor_x = experimental::MakePtenTensorBaseFromVar(v, tensor_def);
// 3. check result // 3. check result
ASSERT_EQ(tensor_x->dtype(), pten::DataType::INT32); ASSERT_EQ(tensor_x->dtype(), pten::DataType::INT32);
} }
} // namespace tests } // namespace tests
} // namespace experimental
} // namespace paddle } // namespace paddle
...@@ -21,7 +21,7 @@ limitations under the License. */ ...@@ -21,7 +21,7 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace pten { namespace paddle {
namespace tests { namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
...@@ -107,4 +107,4 @@ TEST(Tensor, old_copy_to) { ...@@ -107,4 +107,4 @@ TEST(Tensor, old_copy_to) {
} }
} // namespace tests } // namespace tests
} // namespace pten } // namespace paddle
...@@ -18,6 +18,9 @@ limitations under the License. */ ...@@ -18,6 +18,9 @@ limitations under the License. */
#include "paddle/pten/api/ext/exception.h" #include "paddle/pten/api/ext/exception.h"
#include "paddle/pten/common/backend.h" #include "paddle/pten/common/backend.h"
namespace pten {
namespace tests {
TEST(Backend, OStream) { TEST(Backend, OStream) {
std::ostringstream oss; std::ostringstream oss;
oss << pten::Backend::UNDEFINED; oss << pten::Backend::UNDEFINED;
...@@ -48,3 +51,6 @@ TEST(Backend, OStream) { ...@@ -48,3 +51,6 @@ TEST(Backend, OStream) {
EXPECT_TRUE(ex_msg.find("Invalid enum backend type") != std::string::npos); EXPECT_TRUE(ex_msg.find("Invalid enum backend type") != std::string::npos);
} }
} }
} // namespace tests
} // namespace pten
...@@ -19,6 +19,9 @@ limitations under the License. */ ...@@ -19,6 +19,9 @@ limitations under the License. */
#include "paddle/pten/api/ext/exception.h" #include "paddle/pten/api/ext/exception.h"
#include "paddle/pten/common/layout.h" #include "paddle/pten/common/layout.h"
namespace pten {
namespace tests {
TEST(DataLayout, OStream) { TEST(DataLayout, OStream) {
std::ostringstream oss; std::ostringstream oss;
oss << pten::DataLayout::UNDEFINED; oss << pten::DataLayout::UNDEFINED;
...@@ -44,3 +47,6 @@ TEST(DataLayout, OStream) { ...@@ -44,3 +47,6 @@ TEST(DataLayout, OStream) {
std::string::npos); std::string::npos);
} }
} }
} // namespace tests
} // namespace pten
...@@ -19,6 +19,9 @@ limitations under the License. */ ...@@ -19,6 +19,9 @@ limitations under the License. */
#include "paddle/pten/api/ext/exception.h" #include "paddle/pten/api/ext/exception.h"
#include "paddle/pten/common/data_type.h" #include "paddle/pten/common/data_type.h"
namespace pten {
namespace tests {
TEST(DataType, OStream) { TEST(DataType, OStream) {
std::ostringstream oss; std::ostringstream oss;
oss << pten::DataType::UNDEFINED; oss << pten::DataType::UNDEFINED;
...@@ -67,3 +70,6 @@ TEST(DataType, OStream) { ...@@ -67,3 +70,6 @@ TEST(DataType, OStream) {
EXPECT_TRUE(ex_msg.find("Invalid enum data type") != std::string::npos); EXPECT_TRUE(ex_msg.find("Invalid enum data type") != std::string::npos);
} }
} }
} // namespace tests
} // namespace pten
...@@ -19,6 +19,9 @@ limitations under the License. */ ...@@ -19,6 +19,9 @@ limitations under the License. */
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace pten {
namespace tests {
// TODO(chenweihang): add more unittests later // TODO(chenweihang): add more unittests later
TEST(KernelName, ConstructAndOStream) { TEST(KernelName, ConstructAndOStream) {
...@@ -45,3 +48,6 @@ TEST(KernelKey, ConstructAndOStream) { ...@@ -45,3 +48,6 @@ TEST(KernelKey, ConstructAndOStream) {
// EXPECT_EQ(oss.str(), "scale.host"); // EXPECT_EQ(oss.str(), "scale.host");
oss.flush(); oss.flush();
} }
} // namespace tests
} // namespace pten
...@@ -23,6 +23,9 @@ limitations under the License. */ ...@@ -23,6 +23,9 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace pten {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -66,3 +69,6 @@ TEST(DEV_API, cast) { ...@@ -66,3 +69,6 @@ TEST(DEV_API, cast) {
ASSERT_NEAR(actual_result[i], static_cast<double>(dense_x_data[i]), 1e-6f); ASSERT_NEAR(actual_result[i], static_cast<double>(dense_x_data[i]), 1e-6f);
} }
} }
} // namespace tests
} // namespace pten
...@@ -21,6 +21,9 @@ limitations under the License. */ ...@@ -21,6 +21,9 @@ limitations under the License. */
#include "paddle/pten/api/lib/utils/allocator.h" #include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
namespace pten {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -61,3 +64,6 @@ TEST(DEV_API, copy) { ...@@ -61,3 +64,6 @@ TEST(DEV_API, copy) {
ASSERT_EQ(dense_src->data<float>()[i], dense_dst->data<float>()[i]); ASSERT_EQ(dense_src->data<float>()[i], dense_dst->data<float>()[i]);
} }
} }
} // namespace tests
} // namespace pten
...@@ -21,6 +21,9 @@ limitations under the License. */ ...@@ -21,6 +21,9 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace pten {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -73,3 +76,6 @@ TEST(DEV_API, dot) { ...@@ -73,3 +76,6 @@ TEST(DEV_API, dot) {
ASSERT_NEAR(expect_result[1], actual_result1, 1e-6f); ASSERT_NEAR(expect_result[1], actual_result1, 1e-6f);
ASSERT_NEAR(expect_result[2], actual_result2, 1e-6f); ASSERT_NEAR(expect_result[2], actual_result2, 1e-6f);
} }
} // namespace tests
} // namespace pten
...@@ -21,6 +21,9 @@ limitations under the License. */ ...@@ -21,6 +21,9 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace pten {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -182,3 +185,6 @@ TEST(DEV_API, divide) { ...@@ -182,3 +185,6 @@ TEST(DEV_API, divide) {
ASSERT_NEAR(expect_result[0][1], actual_result1, 1e-6f); ASSERT_NEAR(expect_result[0][1], actual_result1, 1e-6f);
ASSERT_NEAR(expect_result[1][0], actual_result2, 1e-6f); ASSERT_NEAR(expect_result[1][0], actual_result2, 1e-6f);
} }
} // namespace tests
} // namespace pten
...@@ -21,6 +21,9 @@ limitations under the License. */ ...@@ -21,6 +21,9 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace pten {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -58,3 +61,6 @@ TEST(DEV_API, fill_any_like) { ...@@ -58,3 +61,6 @@ TEST(DEV_API, fill_any_like) {
ASSERT_NEAR(actual_result[i], val, 1e-6f); ASSERT_NEAR(actual_result[i], val, 1e-6f);
} }
} }
} // namespace tests
} // namespace pten
...@@ -21,6 +21,9 @@ limitations under the License. */ ...@@ -21,6 +21,9 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace pten {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -67,3 +70,6 @@ TEST(DEV_API, flatten) { ...@@ -67,3 +70,6 @@ TEST(DEV_API, flatten) {
} }
ASSERT_EQ(value_equal, true); ASSERT_EQ(value_equal, true);
} }
} // namespace tests
} // namespace pten
...@@ -21,6 +21,9 @@ limitations under the License. */ ...@@ -21,6 +21,9 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace pten {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -56,3 +59,6 @@ TEST(DEV_API, mean) { ...@@ -56,3 +59,6 @@ TEST(DEV_API, mean) {
auto actual_result = out.data<float>()[0]; auto actual_result = out.data<float>()[0];
ASSERT_NEAR(expect_result, actual_result, 1e-6f); ASSERT_NEAR(expect_result, actual_result, 1e-6f);
} }
} // namespace tests
} // namespace pten
...@@ -21,6 +21,9 @@ limitations under the License. */ ...@@ -21,6 +21,9 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace pten {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -65,3 +68,6 @@ TEST(DEV_API, reshape) { ...@@ -65,3 +68,6 @@ TEST(DEV_API, reshape) {
} }
ASSERT_EQ(value_equal, true); ASSERT_EQ(value_equal, true);
} }
} // namespace tests
} // namespace pten
...@@ -21,6 +21,9 @@ limitations under the License. */ ...@@ -21,6 +21,9 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h" #include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h" #include "paddle/pten/core/kernel_registry.h"
namespace pten {
namespace tests {
namespace framework = paddle::framework; namespace framework = paddle::framework;
using DDim = paddle::framework::DDim; using DDim = paddle::framework::DDim;
...@@ -108,3 +111,6 @@ TEST(DEV_API, scale_host) { ...@@ -108,3 +111,6 @@ TEST(DEV_API, scale_host) {
auto actual_result = out.data<float>()[11]; auto actual_result = out.data<float>()[11];
ASSERT_NEAR(expect_result, actual_result, 1e-6f); ASSERT_NEAR(expect_result, actual_result, 1e-6f);
} }
} // namespace tests
} // namespace pten
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册