Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
5745a63f
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看板
未验证
提交
5745a63f
编写于
5月 25, 2023
作者:
L
Leo Chen
提交者:
GitHub
5月 25, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add log for memory stats (#54083)
* add log for memory stats * fix string_split in einsum
上级
ae360000
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
16 deletion
+23
-16
paddle/fluid/memory/stats.h
paddle/fluid/memory/stats.h
+15
-2
paddle/phi/kernels/impl/einsum_grad_impl.h
paddle/phi/kernels/impl/einsum_grad_impl.h
+2
-3
paddle/phi/kernels/impl/einsum_impl.h
paddle/phi/kernels/impl/einsum_impl.h
+4
-7
paddle/utils/string/string_helper.h
paddle/utils/string/string_helper.h
+2
-4
未找到文件。
paddle/fluid/memory/stats.h
浏览文件 @
5745a63f
...
...
@@ -22,6 +22,7 @@ limitations under the License. */
#include "paddle/fluid/platform/errors.h"
#include "paddle/fluid/platform/macros.h"
#include "paddle/phi/common/thread_data_registry.h"
#include "paddle/utils/string/string_helper.h"
namespace
paddle
{
namespace
memory
{
...
...
@@ -74,6 +75,13 @@ class Stat : public StatBase {
thread_data_registry
.
GetMutableCurrentThreadData
();
thread_local_stat
->
current
+=
increment
;
VLOG
(
8
)
<<
string
::
split_string
(
phi
::
enforce
::
demangle
(
typeid
(
*
thread_local_stat
).
name
()),
"::"
)
.
back
()
<<
": Update current_value with "
<<
increment
<<
", after update, current value = "
<<
GetCurrentValue
();
if
(
thread_local_stat
->
current
>
thread_local_stat
->
peak
)
{
thread_local_stat
->
peak
=
thread_local_stat
->
current
;
int64_t
current_value
=
GetCurrentValue
();
...
...
@@ -81,8 +89,13 @@ class Stat : public StatBase {
while
(
prev_value
<
current_value
&&
!
peak_value_
.
compare_exchange_weak
(
prev_value
,
current_value
))
{
}
VLOG
(
8
)
<<
"Update peak_value, after update, peak_value = "
<<
peak_value_
.
load
()
<<
" , current value = "
<<
current_value
;
VLOG
(
8
)
<<
string
::
split_string
(
phi
::
enforce
::
demangle
(
typeid
(
*
thread_local_stat
).
name
()),
"::"
)
.
back
()
<<
": Update current_value with "
<<
increment
<<
", after update, peak_value = "
<<
peak_value_
.
load
()
<<
" , current value = "
<<
current_value
;
}
}
...
...
paddle/phi/kernels/impl/einsum_grad_impl.h
浏览文件 @
5745a63f
...
...
@@ -152,7 +152,7 @@ void EinsumGradKernel(const Context& dev_ctx,
if
(
x
.
size
()
==
1
)
{
// Unary
auto
splits
=
paddle
::
string
::
split_string
(
equation
,
"->"
);
auto
left
=
splits
[
0
];
right
=
splits
[
1
]
.
substr
(
1
)
;
right
=
splits
[
1
];
auto
new_equation
=
right
+
"->"
+
gather_labels_except_reduction
(
left
);
auto
new_operands
=
std
::
vector
<
const
DenseTensor
*>
();
new_operands
.
push_back
(
&
out_grad
);
...
...
@@ -171,8 +171,7 @@ void EinsumGradKernel(const Context& dev_ctx,
auto
splits
=
paddle
::
string
::
split_string
(
equation
,
"->"
);
auto
left
=
splits
[
0
];
auto
ops
=
paddle
::
string
::
split_string
(
left
,
","
);
right
=
splits
[
1
].
substr
(
1
);
right
=
splits
[
1
];
auto
equation_for_A
=
ops
[
1
]
+
","
+
right
+
"->"
+
gather_labels_except_reduction
(
ops
[
0
]);
auto
equation_for_B
=
...
...
paddle/phi/kernels/impl/einsum_impl.h
浏览文件 @
5745a63f
...
...
@@ -326,19 +326,16 @@ inline static void ParseEinsumEquation(
std
::
vector
<
int
>*
output_dims
,
std
::
string
*
right
,
std
::
vector
<
std
::
string
>*
input_strs
)
{
VLOG
(
5
)
<<
"Start ParseEinsumEquation
"
;
VLOG
(
5
)
<<
"Start ParseEinsumEquation
"
<<
equation
;
auto
results
=
paddle
::
string
::
split_string
(
equation
,
"->"
);
auto
left
=
results
[
0
];
ReplaceEllipsis
(
left
);
*
right
=
results
[
1
]
.
substr
(
1
)
;
*
right
=
results
[
1
];
ReplaceEllipsis
(
*
right
);
auto
op_labels
=
paddle
::
string
::
split_string
(
left
,
","
);
// split_string("i,") -> ["i"], we push back a "".
// split_string("i,") -> ["i"
, ""
], we push back a "".
// split_string("->") -> [], we push back a "".
if
(
op_labels
.
size
()
==
0
)
op_labels
.
push_back
(
""
);
else
if
(
left
[
left
.
size
()
-
1
]
==
','
)
op_labels
.
push_back
(
""
);
if
(
op_labels
.
size
()
==
0
)
op_labels
.
push_back
(
""
);
std
::
for_each
(
op_labels
.
begin
(),
op_labels
.
end
(),
ReplaceEllipsis
);
GlobalInfo
(
op_labels
,
*
right
,
labeltype
,
all_labels
);
InferLabelShape
(
op_labels
,
inputs
,
labelshape
,
ellipsis_dims
,
broadcast_dims
);
...
...
paddle/utils/string/string_helper.h
浏览文件 @
5745a63f
...
...
@@ -127,12 +127,10 @@ std::vector<T> split_string(const std::string& str, const std::string& delim) {
while
((
pos
=
str
.
find
(
delim
,
pre_pos
))
!=
std
::
string
::
npos
)
{
tmp_str
.
assign
(
str
,
pre_pos
,
pos
-
pre_pos
);
res_list
.
push_back
(
tmp_str
);
pre_pos
=
pos
+
1
;
pre_pos
=
pos
+
delim
.
size
()
;
}
tmp_str
.
assign
(
str
,
pre_pos
,
str
.
length
()
-
pre_pos
);
if
(
!
tmp_str
.
empty
())
{
res_list
.
push_back
(
tmp_str
);
}
res_list
.
push_back
(
tmp_str
);
return
res_list
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录