Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
0fd4a04a
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
0fd4a04a
编写于
12月 29, 2017
作者:
Y
Yang Yu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove debug codes
上级
dd0a4c35
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
2 addition
and
36 deletion
+2
-36
paddle/framework/tensor_impl.h
paddle/framework/tensor_impl.h
+2
-11
paddle/operators/fill_constant_op.cc
paddle/operators/fill_constant_op.cc
+0
-1
paddle/operators/shrink_rnn_memory_op.cc
paddle/operators/shrink_rnn_memory_op.cc
+0
-1
paddle/operators/while_op.cc
paddle/operators/while_op.cc
+0
-23
未找到文件。
paddle/framework/tensor_impl.h
浏览文件 @
0fd4a04a
...
...
@@ -134,17 +134,8 @@ inline void* Tensor::mutable_data(platform::Place place, std::type_index type) {
#endif
offset_
=
0
;
}
void
*
buf
=
reinterpret_cast
<
void
*>
(
reinterpret_cast
<
uintptr_t
>
(
holder_
->
ptr
())
+
offset_
);
if
(
type
.
hash_code
()
==
typeid
(
float
).
hash_code
()
||
type
.
hash_code
()
==
typeid
(
double
).
hash_code
())
{
float
*
tmp
=
(
float
*
)(
buf
);
for
(
int64_t
i
=
0
;
i
<
numel
();
++
i
)
{
tmp
[
i
]
=
NAN
;
}
}
return
buf
;
return
reinterpret_cast
<
void
*>
(
reinterpret_cast
<
uintptr_t
>
(
holder_
->
ptr
())
+
offset_
);
}
inline
void
*
Tensor
::
mutable_data
(
platform
::
Place
place
)
{
...
...
paddle/operators/fill_constant_op.cc
浏览文件 @
0fd4a04a
...
...
@@ -51,7 +51,6 @@ class FillConstantOp : public framework::OperatorBase {
platform
::
DeviceContextPool
&
pool
=
platform
::
DeviceContextPool
::
Instance
();
auto
&
dev_ctx
=
*
pool
.
Get
(
dev_place
);
VLOG
(
10
)
<<
"FillConstant to "
<<
&
out
;
math
::
set_constant
(
dev_ctx
,
&
out
,
value
);
}
};
...
...
paddle/operators/shrink_rnn_memory_op.cc
浏览文件 @
0fd4a04a
...
...
@@ -116,7 +116,6 @@ class ShrinkRNNMemoryGradOp : public ArrayOp {
auto
height
=
dout_tensor
.
dims
()[
0
];
auto
slice
=
dx_tensor
.
Slice
(
0
,
static_cast
<
int
>
(
height
));
framework
::
CopyFrom
(
dout_tensor
,
dout_tensor
.
place
(),
dev_ctx
,
&
slice
);
VLOG
(
10
)
<<
dx_tensor
.
dims
()[
0
]
<<
", "
<<
height
;
if
(
dx_tensor
.
dims
()[
0
]
>
height
)
{
auto
rest_tensor
=
dx_tensor
.
Slice
(
static_cast
<
int
>
(
height
),
static_cast
<
int
>
(
dx_tensor
.
dims
()[
0
]));
...
...
paddle/operators/while_op.cc
浏览文件 @
0fd4a04a
...
...
@@ -12,7 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include <cmath>
#include <vector>
#include "paddle/framework/executor.h"
#include "paddle/framework/lod_tensor_array.h"
...
...
@@ -195,36 +194,14 @@ class WhileGradOp : public framework::OperatorBase {
}
}
auto
check_var_no_nan
=
[](
const
framework
::
Scope
&
scope
,
const
std
::
string
&
var_name
)
{
auto
*
var
=
scope
.
FindVar
(
var_name
);
if
(
var
->
IsType
<
LoDTensor
>
())
{
VLOG
(
10
)
<<
"Checking "
<<
var_name
;
PADDLE_ENFORCE
(
!
framework
::
HasNAN
(
var
->
Get
<
framework
::
LoDTensor
>
()),
"%s has NAN"
,
var_name
);
if
(
var
->
Get
<
framework
::
LoDTensor
>
().
type
()
==
typeid
(
float
))
{
// NOLINT
auto
&
tensor
=
var
->
Get
<
framework
::
LoDTensor
>
();
auto
*
buf
=
tensor
.
data
<
float
>
();
for
(
int64_t
i
=
0
;
i
<
tensor
.
numel
();
++
i
)
{
PADDLE_ENFORCE
(
!
std
::
isnan
(
buf
[
i
]));
}
VLOG
(
10
)
<<
buf
[
0
];
}
}
};
check_var_no_nan
(
cur_scope
,
inside_grad_name
);
auto
new_inside_name
=
cur_scope
.
Rename
(
inside_grad_name
);
check_var_no_nan
(
cur_scope
,
new_inside_name
);
auto
sum_op
=
framework
::
OpRegistry
::
CreateOp
(
"sum"
,
{{
"X"
,
{
pg_names
[
param_id
],
new_inside_name
}}},
{{
"Out"
,
{
pg_names
[
param_id
]}}},
framework
::
AttributeMap
{});
sum_op
->
Run
(
cur_scope
,
dev_place
);
check_var_no_nan
(
scope
,
pg_names
[
param_id
]);
cur_scope
.
Rename
(
new_inside_name
,
inside_grad_name
);
}
}
VLOG
(
1
)
<<
"Complete WhileOpGrad"
;
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录