Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wzpei9
Paddle
提交
5cf395be
P
Paddle
项目概览
wzpei9
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5cf395be
编写于
9月 28, 2018
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug in uts
上级
a6fbf7ec
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
31 deletion
+25
-31
paddle/fluid/framework/tensor_util_test.cc
paddle/fluid/framework/tensor_util_test.cc
+3
-1
paddle/fluid/operators/CMakeLists.txt
paddle/fluid/operators/CMakeLists.txt
+1
-1
paddle/fluid/operators/scatter_test.cc
paddle/fluid/operators/scatter_test.cc
+21
-25
paddle/fluid/platform/transform_test.cu
paddle/fluid/platform/transform_test.cu
+0
-4
未找到文件。
paddle/fluid/framework/tensor_util_test.cc
浏览文件 @
5cf395be
...
...
@@ -319,7 +319,9 @@ TEST(Tensor, FromAndToStream) {
TensorToStream
(
oss
,
gpu_tensor
,
gpu_ctx
);
std
::
istringstream
iss
(
oss
.
str
());
TensorFromStream
(
iss
,
&
dst_tensor
,
gpu_ctx
);
TensorFromStream
(
iss
,
&
dst_tensor
,
*
platform
::
DeviceContextPool
::
Instance
().
Get
(
platform
::
CPUPlace
()));
int
*
dst_ptr
=
dst_tensor
.
mutable_data
<
int
>
(
platform
::
CPUPlace
());
for
(
int
i
=
0
;
i
<
6
;
++
i
)
{
...
...
paddle/fluid/operators/CMakeLists.txt
浏览文件 @
5cf395be
...
...
@@ -341,7 +341,7 @@ set(GLOB_OP_LIB ${OP_LIBRARY} CACHE INTERNAL "Global OP library")
set
(
GLOB_DISTRIBUTE_DEPS
${
DISTRIBUTE_DEPS
}
CACHE INTERNAL
"distributed dependency"
)
cc_test
(
gather_test SRCS gather_test.cc DEPS tensor
)
cc_test
(
scatter_test SRCS scatter_test.cc DEPS tensor
)
cc_test
(
scatter_test SRCS scatter_test.cc DEPS tensor
math_function
)
cc_test
(
beam_search_decode_op_test SRCS beam_search_decode_op_test.cc DEPS lod_tensor
)
cc_test
(
beam_search_op_test SRCS beam_search_op_test.cc DEPS lod_tensor beam_search_op
)
cc_test
(
strided_memcpy_test SRCS strided_memcpy_test.cc DEPS tensor memory
)
...
...
paddle/fluid/operators/scatter_test.cc
浏览文件 @
5cf395be
...
...
@@ -21,42 +21,38 @@ limitations under the License. */
#include "paddle/fluid/platform/place.h"
TEST
(
scatter
,
ScatterUpdate
)
{
// using namespace paddle::framework;
// using namespace paddle::platform;
// using namespace paddle::operators;
paddle
::
framework
::
Tensor
*
src
=
new
paddle
::
framework
::
Tensor
();
paddle
::
framework
::
Tensor
*
index
=
new
paddle
::
framework
::
Tensor
();
paddle
::
framework
::
Tensor
*
output
=
new
paddle
::
framework
::
Tensor
();
float
*
p_src
=
nullptr
;
int
*
p_index
=
nullptr
;
p_src
=
src
->
mutable_data
<
float
>
(
paddle
::
framework
::
make_ddim
({
1
,
4
}),
paddle
::
platform
::
CPUPlace
());
p_index
=
index
->
mutable_data
<
int
>
(
paddle
::
framework
::
make_ddim
({
1
}),
paddle
::
platform
::
CPUPlace
());
for
(
size_t
i
=
0
;
i
<
4
;
++
i
)
p_src
[
i
]
=
static_cast
<
float
>
(
i
);
paddle
::
framework
::
Tensor
src
;
paddle
::
framework
::
Tensor
index
;
paddle
::
framework
::
Tensor
output
;
auto
*
p_src
=
src
.
mutable_data
<
float
>
(
paddle
::
framework
::
make_ddim
({
1
,
4
}),
paddle
::
platform
::
CPUPlace
());
auto
*
p_index
=
index
.
mutable_data
<
int
>
(
paddle
::
framework
::
make_ddim
({
1
}),
paddle
::
platform
::
CPUPlace
());
for
(
size_t
i
=
0
;
i
<
4
;
++
i
)
{
p_src
[
i
]
=
static_cast
<
float
>
(
i
);
}
p_index
[
0
]
=
1
;
float
*
p_output
=
output
->
mutable_data
<
float
>
(
auto
*
p_output
=
output
.
mutable_data
<
float
>
(
paddle
::
framework
::
make_ddim
({
4
,
4
}),
paddle
::
platform
::
CPUPlace
());
for
(
int64_t
i
=
0
;
i
<
output
.
numel
();
++
i
)
{
p_output
[
i
]
=
0
;
}
auto
*
cpu_place
=
new
paddle
::
platform
::
CPUPlace
();
paddle
::
platform
::
CPUDeviceContext
ctx
(
*
cpu_place
);
paddle
::
operators
::
ScatterAssign
<
float
>
(
ctx
,
*
src
,
*
index
,
output
);
paddle
::
operators
::
ScatterAssign
<
float
>
(
ctx
,
src
,
index
,
&
output
);
for
(
size_t
i
=
0
;
i
<
4
;
++
i
)
EXPECT_EQ
(
p_output
[
i
],
0.0
f
);
for
(
size_t
i
=
0
;
i
<
4
;
++
i
)
EXPECT_EQ
(
output
->
data
<
float
>
()[
i
],
0.0
f
);
for
(
size_t
i
=
0
;
i
<
4
;
++
i
)
EXPECT_EQ
(
output
.
data
<
float
>
()[
i
],
0.0
f
);
for
(
size_t
i
=
4
;
i
<
8
;
++
i
)
{
EXPECT_EQ
(
p_output
[
i
],
static_cast
<
float
>
(
i
-
4
));
}
for
(
size_t
i
=
4
;
i
<
8
;
++
i
)
EXPECT_EQ
(
output
->
data
<
float
>
()[
i
],
static_cast
<
float
>
(
i
-
4
));
EXPECT_EQ
(
output
.
data
<
float
>
()[
i
],
static_cast
<
float
>
(
i
-
4
));
for
(
size_t
i
=
8
;
i
<
16
;
++
i
)
EXPECT_EQ
(
p_output
[
i
],
0.0
f
);
for
(
size_t
i
=
8
;
i
<
16
;
++
i
)
EXPECT_EQ
(
output
->
data
<
float
>
()[
i
],
0.0
f
);
delete
src
;
delete
index
;
delete
output
;
for
(
size_t
i
=
8
;
i
<
16
;
++
i
)
EXPECT_EQ
(
output
.
data
<
float
>
()[
i
],
0.0
f
);
}
paddle/fluid/platform/transform_test.cu
浏览文件 @
5cf395be
...
...
@@ -18,8 +18,6 @@ limitations under the License. */
#include "paddle/fluid/platform/hostdevice.h"
#include "paddle/fluid/platform/transform.h"
namespace
{
template
<
typename
T
>
class
Scale
{
public:
...
...
@@ -36,8 +34,6 @@ class Multiply {
HOSTDEVICE
T
operator
()(
const
T
&
a
,
const
T
&
b
)
const
{
return
a
*
b
;
}
};
}
// namespace
using
paddle
::
memory
::
Alloc
;
using
paddle
::
memory
::
Copy
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录