Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
1c969d20
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1c969d20
编写于
11月 23, 2021
作者:
C
Chen Weihang
提交者:
GitHub
11月 24, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[PTen] Standardized unittest namespace (#37456)
* standarded unittest namespace * fix detail error
上级
52edad6a
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
149 addition
and
30 deletion
+149
-30
paddle/pten/api/lib/tensor.cc
paddle/pten/api/lib/tensor.cc
+1
-1
paddle/pten/tests/api/test_cast_api.cc
paddle/pten/tests/api/test_cast_api.cc
+2
-2
paddle/pten/tests/api/test_dot_api.cc
paddle/pten/tests/api/test_dot_api.cc
+6
-0
paddle/pten/tests/api/test_elementwise_api.cc
paddle/pten/tests/api/test_elementwise_api.cc
+6
-0
paddle/pten/tests/api/test_fill_api.cc
paddle/pten/tests/api/test_fill_api.cc
+6
-0
paddle/pten/tests/api/test_flatten_api.cc
paddle/pten/tests/api/test_flatten_api.cc
+6
-0
paddle/pten/tests/api/test_matmul_api.cc
paddle/pten/tests/api/test_matmul_api.cc
+6
-0
paddle/pten/tests/api/test_mean_api.cc
paddle/pten/tests/api/test_mean_api.cc
+6
-0
paddle/pten/tests/api/test_pten_exception.cc
paddle/pten/tests/api/test_pten_exception.cc
+9
-4
paddle/pten/tests/api/test_pten_tensor.cc
paddle/pten/tests/api/test_pten_tensor.cc
+2
-2
paddle/pten/tests/api/test_reshape_api.cc
paddle/pten/tests/api/test_reshape_api.cc
+2
-2
paddle/pten/tests/api/test_slice_api.cc
paddle/pten/tests/api/test_slice_api.cc
+2
-2
paddle/pten/tests/api/test_storage.cc
paddle/pten/tests/api/test_storage.cc
+6
-6
paddle/pten/tests/api/test_tensor_utils.cc
paddle/pten/tests/api/test_tensor_utils.cc
+9
-9
paddle/pten/tests/api/test_to_api.cc
paddle/pten/tests/api/test_to_api.cc
+2
-2
paddle/pten/tests/common/test_backend.cc
paddle/pten/tests/common/test_backend.cc
+6
-0
paddle/pten/tests/common/test_data_layout.cc
paddle/pten/tests/common/test_data_layout.cc
+6
-0
paddle/pten/tests/common/test_data_type.cc
paddle/pten/tests/common/test_data_type.cc
+6
-0
paddle/pten/tests/core/test_kernel_factory.cc
paddle/pten/tests/core/test_kernel_factory.cc
+6
-0
paddle/pten/tests/kernels/test_cast_dev_api.cc
paddle/pten/tests/kernels/test_cast_dev_api.cc
+6
-0
paddle/pten/tests/kernels/test_copy_dev_api.cc
paddle/pten/tests/kernels/test_copy_dev_api.cc
+6
-0
paddle/pten/tests/kernels/test_dot_dev_api.cc
paddle/pten/tests/kernels/test_dot_dev_api.cc
+6
-0
paddle/pten/tests/kernels/test_elementwise_dev_api.cc
paddle/pten/tests/kernels/test_elementwise_dev_api.cc
+6
-0
paddle/pten/tests/kernels/test_fill_dev_api.cc
paddle/pten/tests/kernels/test_fill_dev_api.cc
+6
-0
paddle/pten/tests/kernels/test_flatten_dev_api.cc
paddle/pten/tests/kernels/test_flatten_dev_api.cc
+6
-0
paddle/pten/tests/kernels/test_mean_dev_api.cc
paddle/pten/tests/kernels/test_mean_dev_api.cc
+6
-0
paddle/pten/tests/kernels/test_reshape_dev_api.cc
paddle/pten/tests/kernels/test_reshape_dev_api.cc
+6
-0
paddle/pten/tests/kernels/test_scale_dev_api.cc
paddle/pten/tests/kernels/test_scale_dev_api.cc
+6
-0
未找到文件。
paddle/pten/api/lib/tensor.cc
浏览文件 @
1c969d20
...
...
@@ -283,7 +283,7 @@ template <typename T>
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
);
...
...
paddle/pten/tests/api/test_cast_api.cc
浏览文件 @
1c969d20
...
...
@@ -22,7 +22,7 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h"
namespace
p
ten
{
namespace
p
addle
{
namespace
tests
{
namespace
framework
=
paddle
::
framework
;
...
...
@@ -85,4 +85,4 @@ TEST(Tensor, cast) {
}
}
// namespace tests
}
// namespace p
ten
}
// namespace p
addle
paddle/pten/tests/api/test_dot_api.cc
浏览文件 @
1c969d20
...
...
@@ -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-6
f
);
ASSERT_NEAR
(
expect_result
[
2
],
actual_result2
,
1e-6
f
);
}
}
// namespace tests
}
// namespace paddle
paddle/pten/tests/api/test_elementwise_api.cc
浏览文件 @
1c969d20
...
...
@@ -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-6
f
);
ASSERT_NEAR
(
expect_result
[
1
][
0
],
actual_result2
,
1e-6
f
);
}
}
// namespace tests
}
// namespace paddle
paddle/pten/tests/api/test_fill_api.cc
浏览文件 @
1c969d20
...
...
@@ -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-6
f
);
}
}
}
// namespace tests
}
// namespace paddle
paddle/pten/tests/api/test_flatten_api.cc
浏览文件 @
1c969d20
...
...
@@ -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
paddle/pten/tests/api/test_matmul_api.cc
浏览文件 @
1c969d20
...
...
@@ -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
paddle/pten/tests/api/test_mean_api.cc
浏览文件 @
1c969d20
...
...
@@ -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
<
float
>
()[
0
];
ASSERT_NEAR
(
expect_result
,
actual_result
,
1e-6
f
);
}
}
// namespace tests
}
// namespace paddle
paddle/pten/tests/api/test_pten_exception.cc
浏览文件 @
1c969d20
...
...
@@ -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
paddle/pten/tests/api/test_pten_tensor.cc
浏览文件 @
1c969d20
...
...
@@ -17,7 +17,7 @@
#include "paddle/pten/api/include/tensor.h"
#include "paddle/pten/api/lib/ext_compat_utils.h"
namespace
p
ten
{
namespace
p
addle
{
namespace
tests
{
template
<
typename
T
>
...
...
@@ -224,4 +224,4 @@ TEST(PtenTensor, All) {
}
}
// namespace tests
}
// namespace p
ten
}
// namespace p
addle
paddle/pten/tests/api/test_reshape_api.cc
浏览文件 @
1c969d20
...
...
@@ -27,7 +27,7 @@ PT_DECLARE_MODULE(ManipulationCPU);
PT_DECLARE_MODULE
(
ManipulationCUDA
);
#endif
namespace
p
ten
{
namespace
p
addle
{
namespace
tests
{
namespace
framework
=
paddle
::
framework
;
...
...
@@ -86,4 +86,4 @@ TEST(Tensor, old_reshape) {
}
}
// namespace tests
}
// namespace p
ten
}
// namespace p
addle
paddle/pten/tests/api/test_slice_api.cc
浏览文件 @
1c969d20
...
...
@@ -19,7 +19,7 @@ limitations under the License. */
#include "paddle/pten/api/include/tensor.h"
#include "paddle/pten/core/kernel_registry.h"
namespace
p
ten
{
namespace
p
addle
{
namespace
tests
{
TEST
(
Tensor
,
slice
)
{
...
...
@@ -41,4 +41,4 @@ TEST(Tensor, slice) {
}
}
// namespace tests
}
// namespace p
ten
}
// namespace p
addle
paddle/pten/tests/api/test_storage.cc
浏览文件 @
1c969d20
...
...
@@ -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
<
DefaultAllocator
>
(
paddle
::
platform
::
CPUPlace
());
const
auto
a
=
std
::
make_shared
<
experimental
::
DefaultAllocator
>
(
paddle
::
platform
::
CPUPlace
());
pten
::
intrusive_ptr
<
pten
::
Storage
>
in_storage
=
pten
::
make_intrusive
<
pten
::
TensorStorage
>
(
a
,
size
);
char
*
data
=
static_cast
<
char
*>
(
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
<
ExternalStorage
>
(
in_storage
,
delta
,
n
);
auto
ex_storage
=
pten
::
make_intrusive
<
experimental
::
ExternalStorage
>
(
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
<
ExternalStorage
>
(
auto
ex_storage
=
pten
::
make_intrusive
<
experimental
::
ExternalStorage
>
(
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
<
char
>
(
i
));
}
}
}
// namespace tests
}
// namespace experimental
}
// namespace paddle
paddle/pten/tests/api/test_tensor_utils.cc
浏览文件 @
1c969d20
...
...
@@ -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
<
std
::
vector
<
size_t
>>
lod
{{
0
,
2
}};
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
);
float
*
data
=
dense_tensor
.
mutable_data
<
float
>
();
...
...
@@ -42,7 +42,7 @@ TEST(tensor_utils, dense_tensor_to_lod_tensor) {
data
[
1
]
=
2.1
f
;
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
<
float
>
()[
0
]
==
1.0
f
);
CHECK
(
lod_tensor
.
data
<
float
>
()[
1
]
==
2.1
f
);
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
<
DefaultAllocator
>
(
platform
::
CPUPlace
());
auto
alloc
=
std
::
make_shared
<
experimental
::
DefaultAllocator
>
(
platform
::
CPUPlace
());
DenseTensor
dense_tensor
(
alloc
,
meta
);
float
*
data
=
dense_tensor
.
mutable_data
<
float
>
();
...
...
@@ -80,7 +81,7 @@ TEST(tensor_utils, dense_tensor_to_tensor) {
data
[
1
]
=
2.1
f
;
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
<
float
>
()[
0
]
==
1.0
f
);
CHECK
(
tensor
.
data
<
float
>
()[
1
]
==
2.1
f
);
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
paddle/pten/tests/api/test_to_api.cc
浏览文件 @
1c969d20
...
...
@@ -21,7 +21,7 @@ limitations under the License. */
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h"
namespace
p
ten
{
namespace
p
addle
{
namespace
tests
{
namespace
framework
=
paddle
::
framework
;
...
...
@@ -107,4 +107,4 @@ TEST(Tensor, old_copy_to) {
}
}
// namespace tests
}
// namespace p
ten
}
// namespace p
addle
paddle/pten/tests/common/test_backend.cc
浏览文件 @
1c969d20
...
...
@@ -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
paddle/pten/tests/common/test_data_layout.cc
浏览文件 @
1c969d20
...
...
@@ -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
paddle/pten/tests/common/test_data_type.cc
浏览文件 @
1c969d20
...
...
@@ -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
paddle/pten/tests/core/test_kernel_factory.cc
浏览文件 @
1c969d20
...
...
@@ -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
paddle/pten/tests/kernels/test_cast_dev_api.cc
浏览文件 @
1c969d20
...
...
@@ -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
<
double
>
(
dense_x_data
[
i
]),
1e-6
f
);
}
}
}
// namespace tests
}
// namespace pten
paddle/pten/tests/kernels/test_copy_dev_api.cc
浏览文件 @
1c969d20
...
...
@@ -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
<
float
>
()[
i
],
dense_dst
->
data
<
float
>
()[
i
]);
}
}
}
// namespace tests
}
// namespace pten
paddle/pten/tests/kernels/test_dot_dev_api.cc
浏览文件 @
1c969d20
...
...
@@ -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-6
f
);
ASSERT_NEAR
(
expect_result
[
2
],
actual_result2
,
1e-6
f
);
}
}
// namespace tests
}
// namespace pten
paddle/pten/tests/kernels/test_elementwise_dev_api.cc
浏览文件 @
1c969d20
...
...
@@ -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-6
f
);
ASSERT_NEAR
(
expect_result
[
1
][
0
],
actual_result2
,
1e-6
f
);
}
}
// namespace tests
}
// namespace pten
paddle/pten/tests/kernels/test_fill_dev_api.cc
浏览文件 @
1c969d20
...
...
@@ -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-6
f
);
}
}
}
// namespace tests
}
// namespace pten
paddle/pten/tests/kernels/test_flatten_dev_api.cc
浏览文件 @
1c969d20
...
...
@@ -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
paddle/pten/tests/kernels/test_mean_dev_api.cc
浏览文件 @
1c969d20
...
...
@@ -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
<
float
>
()[
0
];
ASSERT_NEAR
(
expect_result
,
actual_result
,
1e-6
f
);
}
}
// namespace tests
}
// namespace pten
paddle/pten/tests/kernels/test_reshape_dev_api.cc
浏览文件 @
1c969d20
...
...
@@ -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
paddle/pten/tests/kernels/test_scale_dev_api.cc
浏览文件 @
1c969d20
...
...
@@ -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
<
float
>
()[
11
];
ASSERT_NEAR
(
expect_result
,
actual_result
,
1e-6
f
);
}
}
// namespace tests
}
// namespace pten
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录