Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
3fdb0312
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看板
提交
3fdb0312
编写于
10月 08, 2019
作者:
S
silingtong123
提交者:
Tao Luo
10月 08, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test=release/1.6, Modify the style of function names (#20118)
上级
2c6d0757
变更
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
浏览文件 @
3fdb0312
...
...
@@ -33,9 +33,9 @@ class CPUUniformRandomKernel : public framework::OpKernel<T> {
if
(
list_new_shape_tensor
.
size
()
>
0
||
ctx
.
HasInput
(
"ShapeTensor"
))
{
if
(
ctx
.
HasInput
(
"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
)
{
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 {
AddInput
(
"ShapeTensor"
,
"(Tensor<int64_t>, optional). If provided, uniform_ranodom "
"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 "
"set correctly to gurantee shape inference in compile time."
)
.
AsDispensable
();
AddInput
(
"ShapeTensorList"
,
"(vector<Tensor<int64_t>>, optional). If provided, uniform_random "
"
will use this
"
"The shape of the tensor in vector MUST BE [1]"
"
use this.
"
"The shape of the tensor in vector MUST BE [1]
,
"
"it has the highest priority compare with Input(Shape) and "
"attr(shape)."
)
.
AsDuplicable
()
...
...
paddle/fluid/operators/uniform_random_op.cu
浏览文件 @
3fdb0312
...
...
@@ -64,9 +64,9 @@ class GPUUniformRandomKernel : public framework::OpKernel<T> {
if
(
list_new_shape_tensor
.
size
()
>
0
||
context
.
HasInput
(
"ShapeTensor"
))
{
if
(
context
.
HasInput
(
"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
)
{
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
浏览文件 @
3fdb0312
...
...
@@ -22,7 +22,7 @@ namespace paddle {
namespace
operators
{
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
)
{
auto
*
new_data
=
new_data_tensor
->
data
<
int64_t
>
();
if
(
platform
::
is_gpu_place
(
new_data_tensor
->
place
()))
{
...
...
@@ -35,7 +35,7 @@ inline std::vector<int64_t> get_new_data_from_shape_tensor(
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
)
{
std
::
vector
<
int64_t
>
vec_new_shape
;
vec_new_shape
.
reserve
(
list_new_shape_tensor
.
size
());
...
...
@@ -46,10 +46,9 @@ inline std::vector<int64_t> get_new_shape_from_shape_tensorlist(
if
(
platform
::
is_gpu_place
(
tensor
->
place
()))
{
framework
::
Tensor
temp
;
TensorCopySync
(
*
tensor
,
platform
::
CPUPlace
(),
&
temp
);
vec_new_shape
.
push_back
(
static_cast
<
int64_t
>
(
*
temp
.
data
<
int64_t
>
()));
vec_new_shape
.
push_back
(
*
temp
.
data
<
int64_t
>
());
}
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录