Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6b18b3cc
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
提交
6b18b3cc
编写于
11月 30, 2017
作者:
G
guosheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://github.com/PaddlePaddle/paddle
into enhance-include-pool
上级
cb5a7a8b
0d40a4db
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
23 addition
and
7 deletion
+23
-7
paddle/framework/shape_inference.cc
paddle/framework/shape_inference.cc
+6
-0
paddle/framework/shape_inference.h
paddle/framework/shape_inference.h
+1
-0
paddle/operators/tensor_array_read_write_op.cc
paddle/operators/tensor_array_read_write_op.cc
+9
-3
paddle/operators/while_op.cc
paddle/operators/while_op.cc
+3
-3
python/paddle/v2/fluid/layers.py
python/paddle/v2/fluid/layers.py
+4
-1
未找到文件。
paddle/framework/shape_inference.cc
浏览文件 @
6b18b3cc
...
...
@@ -22,6 +22,12 @@ std::vector<framework::DDim> InferShapeContext::GetInputsDim(
return
GetDims
(
names
);
}
DDim
InferShapeContext
::
GetInputsElementDim
(
const
std
::
string
&
name
,
int
idx
)
const
{
const
std
::
vector
<
std
::
string
>
&
names
=
Inputs
(
name
);
return
this
->
GetDim
(
names
[
idx
]);
}
void
InferShapeContext
::
SetOutputsDim
(
const
std
::
string
&
name
,
const
std
::
vector
<
framework
::
DDim
>
&
dims
)
{
auto
&
names
=
Outputs
(
name
);
...
...
paddle/framework/shape_inference.h
浏览文件 @
6b18b3cc
...
...
@@ -37,6 +37,7 @@ class InferShapeContext {
virtual
framework
::
DDim
GetInputDim
(
const
std
::
string
&
name
)
const
=
0
;
std
::
vector
<
framework
::
DDim
>
GetInputsDim
(
const
std
::
string
&
name
)
const
;
DDim
GetInputsElementDim
(
const
std
::
string
&
name
,
int
idx
)
const
;
virtual
void
SetOutputDim
(
const
std
::
string
&
name
,
const
DDim
&
dim
)
=
0
;
void
SetOutputsDim
(
const
std
::
string
&
name
,
...
...
paddle/operators/tensor_array_read_write_op.cc
浏览文件 @
6b18b3cc
...
...
@@ -37,9 +37,15 @@ class WriteToArrayOp : public ArrayOp {
<<
" to "
<<
offset
+
1
;
out
->
resize
(
offset
+
1
);
}
auto
*
out_tensor
=
&
out
->
at
(
offset
);
CopyFrom
(
x_tensor
,
dev_ctx
.
GetPlace
(),
dev_ctx
,
out_tensor
);
out_tensor
->
set_lod
(
x_tensor
.
lod
());
if
(
x_tensor
.
memory_size
()
>
0
)
{
auto
*
out_tensor
=
&
out
->
at
(
offset
);
CopyFrom
(
x_tensor
,
dev_ctx
.
GetPlace
(),
dev_ctx
,
out_tensor
);
out_tensor
->
set_lod
(
x_tensor
.
lod
());
}
else
{
VLOG
(
10
)
<<
"WARNING: The input tensor 'x_tensor' holds no memory, so "
"nothing has been written to output array["
<<
offset
<<
"]."
;
}
}
};
...
...
paddle/operators/while_op.cc
浏览文件 @
6b18b3cc
...
...
@@ -287,7 +287,6 @@ class WhileGradOpShapeInference : public framework::InferShapeBase {
auto
p_names
=
ctx
->
Inputs
(
kParameters
);
auto
pg_names
=
ctx
->
Outputs
(
kParamGrads
);
auto
dims
=
ctx
->
GetInputsDim
(
kParameters
);
auto
var_types
=
ctx
->
GetInputsVarType
(
kParameters
);
std
::
vector
<
std
::
string
>
names_to_set
;
std
::
vector
<
framework
::
DDim
>
dims_to_set
;
...
...
@@ -295,13 +294,14 @@ class WhileGradOpShapeInference : public framework::InferShapeBase {
if
(
pg_names
[
i
]
==
framework
::
kEmptyVarName
)
{
continue
;
}
auto
dims
=
ctx
->
GetInputsElementDim
(
kParameters
,
i
);
if
(
var_types
[
i
]
==
framework
::
VarDesc
::
LOD_TENSOR
)
{
names_to_set
.
push_back
(
pg_names
[
i
]);
dims_to_set
.
push_back
(
dims
[
i
]
);
dims_to_set
.
push_back
(
dims
);
}
else
if
(
var_types
[
i
]
==
framework
::
VarDesc
::
LOD_TENSOR_ARRAY
)
{
// not sure how to set the dim of LOD_TENSOR_ARRAY
names_to_set
.
push_back
(
pg_names
[
i
]);
dims_to_set
.
push_back
(
dims
[
i
]
);
dims_to_set
.
push_back
(
dims
);
}
}
ctx
->
SetDims
(
names_to_set
,
dims_to_set
);
...
...
python/paddle/v2/fluid/layers.py
浏览文件 @
6b18b3cc
...
...
@@ -185,6 +185,7 @@ def data(name,
shape
,
append_batch_size
=
True
,
dtype
=
'float32'
,
lod_level
=
0
,
type
=
core
.
VarDesc
.
VarType
.
LOD_TENSOR
,
main_program
=
None
,
startup_program
=
None
,
...
...
@@ -198,6 +199,7 @@ def data(name,
append_batch_size: Whether or not to append the data as a batch.
dtype: The type of data : float32, float_16, int etc
type: The output type. By default it is LOD_TENSOR.
lod_level(int): The LoD Level. 0 means the input data is not a sequence.
main_program: Name of the main program that calls this
startup_program: Name of the startup program
stop_gradient: A boolean that mentions whether gradient should flow.
...
...
@@ -228,7 +230,8 @@ def data(name,
shape
=
shape
,
dtype
=
dtype
,
type
=
type
,
stop_gradient
=
stop_gradient
)
stop_gradient
=
stop_gradient
,
lod_level
=
lod_level
)
def
create_tensor
(
dtype
,
name
=
None
,
main_program
=
None
,
startup_program
=
None
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录