Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
649bcd5f
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
649bcd5f
编写于
9月 30, 2019
作者:
S
silingtong123
提交者:
Tao Luo
9月 30, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modify the style of function names (#20071)
上级
62573d89
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
11 addition
and
12 deletion
+11
-12
paddle/fluid/operators/uniform_random_op.cc
paddle/fluid/operators/uniform_random_op.cc
+5
-5
paddle/fluid/operators/uniform_random_op.cu
paddle/fluid/operators/uniform_random_op.cu
+2
-2
paddle/fluid/operators/uniform_random_op.h
paddle/fluid/operators/uniform_random_op.h
+4
-5
未找到文件。
paddle/fluid/operators/uniform_random_op.cc
浏览文件 @
649bcd5f
...
@@ -33,9 +33,9 @@ class CPUUniformRandomKernel : public framework::OpKernel<T> {
...
@@ -33,9 +33,9 @@ class CPUUniformRandomKernel : public framework::OpKernel<T> {
if
(
list_new_shape_tensor
.
size
()
>
0
||
ctx
.
HasInput
(
"ShapeTensor"
))
{
if
(
list_new_shape_tensor
.
size
()
>
0
||
ctx
.
HasInput
(
"ShapeTensor"
))
{
if
(
ctx
.
HasInput
(
"ShapeTensor"
))
{
if
(
ctx
.
HasInput
(
"ShapeTensor"
))
{
auto
*
shape_tensor
=
ctx
.
Input
<
framework
::
Tensor
>
(
"ShapeTensor"
);
auto
*
shape_tensor
=
ctx
.
Input
<
framework
::
Tensor
>
(
"ShapeTensor"
);
new_shape
=
get_new_data_from_shape_t
ensor
(
shape_tensor
);
new_shape
=
GetNewDataFromShapeT
ensor
(
shape_tensor
);
}
else
if
(
list_new_shape_tensor
.
size
()
>
0
)
{
}
else
if
(
list_new_shape_tensor
.
size
()
>
0
)
{
new_shape
=
get_new_shape_from_shape_tensorl
ist
(
list_new_shape_tensor
);
new_shape
=
GetNewDataFromShapeTensorL
ist
(
list_new_shape_tensor
);
}
}
}
}
...
@@ -169,14 +169,14 @@ class UniformRandomOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -169,14 +169,14 @@ class UniformRandomOpMaker : public framework::OpProtoAndCheckerMaker {
AddInput
(
"ShapeTensor"
,
AddInput
(
"ShapeTensor"
,
"(Tensor<int64_t>, optional). If provided, uniform_ranodom "
"(Tensor<int64_t>, optional). If provided, uniform_ranodom "
"according to "
"according to "
"this given shape.
That is to say
it has a higher priority than "
"this given shape.
It means that
it has a higher priority than "
"the shape attribute, while the shape attribute still should be "
"the shape attribute, while the shape attribute still should be "
"set correctly to gurantee shape inference in compile time."
)
"set correctly to gurantee shape inference in compile time."
)
.
AsDispensable
();
.
AsDispensable
();
AddInput
(
"ShapeTensorList"
,
AddInput
(
"ShapeTensorList"
,
"(vector<Tensor<int64_t>>, optional). If provided, uniform_random "
"(vector<Tensor<int64_t>>, optional). If provided, uniform_random "
"
will use this
"
"
use this.
"
"The shape of the tensor in vector MUST BE [1]"
"The shape of the tensor in vector MUST BE [1]
,
"
"it has the highest priority compare with Input(Shape) and "
"it has the highest priority compare with Input(Shape) and "
"attr(shape)."
)
"attr(shape)."
)
.
AsDuplicable
()
.
AsDuplicable
()
...
...
paddle/fluid/operators/uniform_random_op.cu
浏览文件 @
649bcd5f
...
@@ -64,9 +64,9 @@ class GPUUniformRandomKernel : public framework::OpKernel<T> {
...
@@ -64,9 +64,9 @@ class GPUUniformRandomKernel : public framework::OpKernel<T> {
if
(
list_new_shape_tensor
.
size
()
>
0
||
context
.
HasInput
(
"ShapeTensor"
))
{
if
(
list_new_shape_tensor
.
size
()
>
0
||
context
.
HasInput
(
"ShapeTensor"
))
{
if
(
context
.
HasInput
(
"ShapeTensor"
))
{
if
(
context
.
HasInput
(
"ShapeTensor"
))
{
auto
*
shape_tensor
=
context
.
Input
<
framework
::
Tensor
>
(
"ShapeTensor"
);
auto
*
shape_tensor
=
context
.
Input
<
framework
::
Tensor
>
(
"ShapeTensor"
);
new_shape
=
get_new_data_from_shape_t
ensor
(
shape_tensor
);
new_shape
=
GetNewDataFromShapeT
ensor
(
shape_tensor
);
}
else
if
(
list_new_shape_tensor
.
size
()
>
0
)
{
}
else
if
(
list_new_shape_tensor
.
size
()
>
0
)
{
new_shape
=
get_new_shape_from_shape_tensorl
ist
(
list_new_shape_tensor
);
new_shape
=
GetNewDataFromShapeTensorL
ist
(
list_new_shape_tensor
);
}
}
}
}
...
...
paddle/fluid/operators/uniform_random_op.h
浏览文件 @
649bcd5f
...
@@ -22,7 +22,7 @@ namespace paddle {
...
@@ -22,7 +22,7 @@ namespace paddle {
namespace
operators
{
namespace
operators
{
using
Tensor
=
framework
::
Tensor
;
using
Tensor
=
framework
::
Tensor
;
inline
std
::
vector
<
int64_t
>
get_new_data_from_shape_t
ensor
(
inline
std
::
vector
<
int64_t
>
GetNewDataFromShapeT
ensor
(
const
Tensor
*
new_data_tensor
)
{
const
Tensor
*
new_data_tensor
)
{
auto
*
new_data
=
new_data_tensor
->
data
<
int64_t
>
();
auto
*
new_data
=
new_data_tensor
->
data
<
int64_t
>
();
if
(
platform
::
is_gpu_place
(
new_data_tensor
->
place
()))
{
if
(
platform
::
is_gpu_place
(
new_data_tensor
->
place
()))
{
...
@@ -35,7 +35,7 @@ inline std::vector<int64_t> get_new_data_from_shape_tensor(
...
@@ -35,7 +35,7 @@ inline std::vector<int64_t> get_new_data_from_shape_tensor(
return
vec_new_data
;
return
vec_new_data
;
}
}
inline
std
::
vector
<
int64_t
>
get_new_shape_from_shape_tensorl
ist
(
inline
std
::
vector
<
int64_t
>
GetNewDataFromShapeTensorL
ist
(
const
std
::
vector
<
const
Tensor
*>
&
list_new_shape_tensor
)
{
const
std
::
vector
<
const
Tensor
*>
&
list_new_shape_tensor
)
{
std
::
vector
<
int64_t
>
vec_new_shape
;
std
::
vector
<
int64_t
>
vec_new_shape
;
vec_new_shape
.
reserve
(
list_new_shape_tensor
.
size
());
vec_new_shape
.
reserve
(
list_new_shape_tensor
.
size
());
...
@@ -46,10 +46,9 @@ inline std::vector<int64_t> get_new_shape_from_shape_tensorlist(
...
@@ -46,10 +46,9 @@ inline std::vector<int64_t> get_new_shape_from_shape_tensorlist(
if
(
platform
::
is_gpu_place
(
tensor
->
place
()))
{
if
(
platform
::
is_gpu_place
(
tensor
->
place
()))
{
framework
::
Tensor
temp
;
framework
::
Tensor
temp
;
TensorCopySync
(
*
tensor
,
platform
::
CPUPlace
(),
&
temp
);
TensorCopySync
(
*
tensor
,
platform
::
CPUPlace
(),
&
temp
);
vec_new_shape
.
push_back
(
*
temp
.
data
<
int64_t
>
());
vec_new_shape
.
push_back
(
static_cast
<
int64_t
>
(
*
temp
.
data
<
int64_t
>
()));
}
else
{
}
else
{
vec_new_shape
.
push_back
(
static_cast
<
int64_t
>
(
*
tensor
->
data
<
int64_t
>
()
));
vec_new_shape
.
push_back
(
*
tensor
->
data
<
int64_t
>
(
));
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录