Skip to content

Commit 0e7d3bd

Browse files
committed
update phi common tests
1 parent b33b266 commit 0e7d3bd

3 files changed

Lines changed: 12 additions & 15 deletions

File tree

test/cpp/phi/common/test_backend.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ TEST(Backend, StringToBackend) {
6666
#else
6767
EXPECT_EQ(Backend::KPS, StringToBackend("KPS"));
6868
#endif
69-
EXPECT_EQ(static_cast<Backend>(
70-
static_cast<size_t>(Backend::NUM_BACKENDS) +
71-
phi::CustomRegisteredDeviceMap::Instance()
72-
.GetOrRegisterGlobalDeviceTypeId("CustomBackend")),
73-
StringToBackend("CustomBackend"));
69+
EXPECT_EQ(
70+
static_cast<Backend>(
71+
static_cast<size_t>(Backend::NUM_BACKENDS) +
72+
CustomRegisteredDeviceMap::Instance().GetOrRegisterGlobalDeviceTypeId(
73+
"CustomBackend")),
74+
StringToBackend("CustomBackend"));
7475
}
7576

7677
} // namespace tests

test/cpp/phi/common/test_int_array.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ TEST(IntArray, ThrowException) {
9595
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
9696
TEST(IntArray, ConstructFromGPUDenseTensor) {
9797
auto& pool = paddle::experimental::DeviceContextPool::Instance();
98-
const auto* dev_ctx =
99-
static_cast<const phi::GPUContext*>(pool.Get(GPUPlace()));
98+
const auto* dev_ctx = static_cast<const GPUContext*>(pool.Get(GPUPlace()));
10099
DenseTensor shape = Full<int>(*dev_ctx, {2}, 3);
101100
DenseTensor out = Full<int>(*dev_ctx, shape, 1);
102101
ASSERT_EQ(out.dims().size(), 2);
@@ -107,8 +106,7 @@ TEST(IntArray, ConstructFromGPUDenseTensor) {
107106

108107
TEST(IntArray, ConstructFromGPUDenseTensorVector) {
109108
auto& pool = paddle::experimental::DeviceContextPool::Instance();
110-
const auto* dev_ctx =
111-
static_cast<const phi::GPUContext*>(pool.Get(GPUPlace()));
109+
const auto* dev_ctx = static_cast<const GPUContext*>(pool.Get(GPUPlace()));
112110
DenseTensor shape0 = Full<int>(*dev_ctx, {1}, 3);
113111
DenseTensor shape1 = Full<int64_t>(*dev_ctx, {1}, 3);
114112
std::vector<DenseTensor> shape{shape0, shape1};

test/cpp/phi/common/test_scalar.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ TEST(Scalar, Formatting) {
5050
s = paddle::experimental::Scalar(std::complex<double>(42.1, 42.1));
5151
ASSERT_PRED2(StartsWith, s.ToString(), "Scalar(complex128(");
5252

53-
s = paddle::experimental::Scalar(static_cast<phi::float16>(42.1));
53+
s = paddle::experimental::Scalar(static_cast<float16>(42.1));
5454
ASSERT_PRED2(StartsWith, s.ToString(), "Scalar(float16(");
5555

56-
s = paddle::experimental::Scalar(static_cast<phi::bfloat16>(42.1));
56+
s = paddle::experimental::Scalar(static_cast<bfloat16>(42.1));
5757
ASSERT_PRED2(StartsWith, s.ToString(), "Scalar(bfloat16(");
5858

5959
s = paddle::experimental::Scalar(static_cast<int8_t>(42.1));
@@ -93,10 +93,8 @@ TEST(Scalar, Equality) {
9393
auto s_uint32 = paddle::experimental::Scalar(static_cast<uint32_t>(42.1));
9494
auto s_uint64 = paddle::experimental::Scalar(static_cast<uint64_t>(42.1));
9595

96-
auto s_float16 =
97-
paddle::experimental::Scalar(static_cast<phi::float16>(42.1));
98-
auto s_bfloat16 =
99-
paddle::experimental::Scalar(static_cast<phi::bfloat16>(42.1));
96+
auto s_float16 = paddle::experimental::Scalar(static_cast<float16>(42.1));
97+
auto s_bfloat16 = paddle::experimental::Scalar(static_cast<bfloat16>(42.1));
10098
auto s_float = paddle::experimental::Scalar(static_cast<float>(42.1));
10199
auto s_double = paddle::experimental::Scalar(static_cast<double>(42.1));
102100

0 commit comments

Comments
 (0)