Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
ab575de7
P
Paddle
项目概览
机器未来
/
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看板
提交
ab575de7
编写于
10月 18, 2019
作者:
Z
Zeng Jinle
提交者:
gongweibao
10月 18, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix op run log when memory optimization strategy is enabled (#20695)
上级
a1cd27f1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
84 addition
and
4 deletion
+84
-4
paddle/fluid/framework/operator.cc
paddle/fluid/framework/operator.cc
+11
-4
paddle/fluid/operators/CMakeLists.txt
paddle/fluid/operators/CMakeLists.txt
+2
-0
paddle/fluid/operators/op_debug_string_test.cc
paddle/fluid/operators/op_debug_string_test.cc
+71
-0
未找到文件。
paddle/fluid/framework/operator.cc
浏览文件 @
ab575de7
...
...
@@ -132,9 +132,6 @@ static LoD GetLoDDebug(const Scope& scope, const std::string& name) {
if
(
var
->
IsType
<
LoDTensor
>
())
{
const
LoDTensor
&
tensor
=
var
->
Get
<
LoDTensor
>
();
if
(
UNLIKELY
(
!
tensor
.
IsInitialized
()))
{
return
default_lod
;
}
return
tensor
.
lod
();
}
else
{
return
default_lod
;
...
...
@@ -238,8 +235,16 @@ const std::vector<std::string>& OperatorBase::Outputs(
std
::
string
OperatorBase
::
DebugStringEx
(
const
Scope
*
scope
)
const
{
std
::
stringstream
ss
;
ss
<<
"Op("
<<
type_
<<
"), inputs:{"
;
std
::
unordered_set
<
std
::
string
>
no_need_buffer_vars
;
if
(
info_
&&
info_
->
NoNeedBufferVarsInferer
())
{
no_need_buffer_vars
=
Info
().
NoNeedBufferVarsInferer
()(
Inputs
(),
Outputs
(),
Attrs
());
}
for
(
auto
it
=
inputs_
.
begin
();
it
!=
inputs_
.
end
();)
{
auto
&
input
=
*
it
;
bool
is_no_need_buffer_var
=
(
no_need_buffer_vars
.
count
(
input
.
first
)
>
0
);
ss
<<
input
.
first
<<
"["
;
for
(
size_t
i
=
0
;
i
<
input
.
second
.
size
();
++
i
)
{
auto
var_name
=
input
.
second
[
i
];
...
...
@@ -252,7 +257,9 @@ std::string OperatorBase::DebugStringEx(const Scope* scope) const {
if
(
row_size
>=
0
)
{
ss
<<
"[row_size="
<<
row_size
<<
"]"
;
}
std
::
string
dtype
=
GetDtype
(
*
scope
,
var_name
);
std
::
string
dtype
=
is_no_need_buffer_var
?
"unknown_dtype"
:
GetDtype
(
*
scope
,
var_name
);
ss
<<
":"
<<
dtype
;
ss
<<
"["
<<
GetDimsDebug
(
*
scope
,
var_name
,
true
)
<<
"]"
;
ss
<<
"("
<<
GetLoDDebug
(
*
scope
,
var_name
)
<<
")"
;
...
...
paddle/fluid/operators/CMakeLists.txt
浏览文件 @
ab575de7
...
...
@@ -128,3 +128,5 @@ endif()
set
(
GLOB_OP_LIB
${
OP_LIBRARY
}
CACHE INTERNAL
"Global OP library"
)
add_subdirectory
(
benchmark
)
cc_test
(
op_debug_string_test SRCS op_debug_string_test.cc DEPS elementwise_add_op
)
paddle/fluid/operators/op_debug_string_test.cc
0 → 100644
浏览文件 @
ab575de7
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// 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 <string>
#include "glog/logging.h"
#include "gtest/gtest.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/operator.h"
USE_OP
(
elementwise_add_grad
);
namespace
paddle
{
namespace
operators
{
TEST
(
op_debug_str
,
test_unknown_dtype
)
{
platform
::
Place
place
=
platform
::
CPUPlace
();
framework
::
DDim
dim
{
3
,
4
,
5
,
6
};
const
std
::
string
unknown_dtype
=
"unknown_dtype"
;
framework
::
OpDesc
desc
;
framework
::
Scope
scope
;
desc
.
SetType
(
"elementwise_add_grad"
);
desc
.
SetInput
(
"Y"
,
{
"Y"
});
desc
.
SetInput
(
framework
::
GradVarName
(
"Out"
),
{
framework
::
GradVarName
(
"Out"
)});
desc
.
SetOutput
(
framework
::
GradVarName
(
"X"
),
{
framework
::
GradVarName
(
"X"
)});
desc
.
SetOutput
(
framework
::
GradVarName
(
"Y"
),
{
framework
::
GradVarName
(
"Y"
)});
desc
.
SetAttr
(
"axis"
,
-
1
);
desc
.
SetAttr
(
"use_mkldnn"
,
false
);
desc
.
SetAttr
(
"x_data_format"
,
""
);
desc
.
SetAttr
(
"y_data_format"
,
""
);
auto
y_tensor
=
scope
.
Var
(
"Y"
)
->
GetMutable
<
framework
::
LoDTensor
>
();
y_tensor
->
Resize
(
dim
);
y_tensor
->
mutable_data
<
float
>
(
place
);
auto
out_grad_tensor
=
scope
.
Var
(
framework
::
GradVarName
(
"Out"
))
->
GetMutable
<
framework
::
LoDTensor
>
();
out_grad_tensor
->
Resize
(
dim
);
out_grad_tensor
->
mutable_data
<
float
>
(
place
);
scope
.
Var
(
framework
::
GradVarName
(
"X"
))
->
GetMutable
<
framework
::
LoDTensor
>
();
scope
.
Var
(
framework
::
GradVarName
(
"Y"
))
->
GetMutable
<
framework
::
LoDTensor
>
();
auto
op
=
framework
::
OpRegistry
::
CreateOp
(
desc
);
auto
before_run_str
=
op
->
DebugStringEx
(
&
scope
);
LOG
(
INFO
)
<<
before_run_str
;
ASSERT_TRUE
(
before_run_str
.
find
(
unknown_dtype
)
!=
std
::
string
::
npos
);
op
->
Run
(
scope
,
place
);
platform
::
DeviceContextPool
::
Instance
().
Get
(
place
)
->
Wait
();
auto
after_run_str
=
op
->
DebugStringEx
(
&
scope
);
LOG
(
INFO
)
<<
after_run_str
;
ASSERT_TRUE
(
after_run_str
.
find
(
unknown_dtype
)
!=
std
::
string
::
npos
);
}
}
// namespace operators
}
// namespace paddle
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录