Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
8476c552
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
8476c552
编写于
2月 23, 2023
作者:
Y
YuanRisheng
提交者:
GitHub
2月 23, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[PHI Decoupling]Remove Profiler header (Part3) (#50721)
* move profiler * fix compile bugs
上级
22925c21
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
107 addition
and
71 deletion
+107
-71
paddle/fluid/platform/profiler.cc
paddle/fluid/platform/profiler.cc
+0
-27
paddle/fluid/platform/profiler.h
paddle/fluid/platform/profiler.h
+0
-3
paddle/fluid/platform/profiler/common_event.h
paddle/fluid/platform/profiler/common_event.h
+1
-21
paddle/fluid/platform/profiler/supplement_tracing.h
paddle/fluid/platform/profiler/supplement_tracing.h
+2
-12
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+2
-2
paddle/phi/api/profiler/common_event.h
paddle/phi/api/profiler/common_event.h
+28
-0
paddle/phi/api/profiler/profiler.cc
paddle/phi/api/profiler/profiler.cc
+25
-0
paddle/phi/api/profiler/profiler.h
paddle/phi/api/profiler/profiler.h
+4
-0
paddle/phi/api/profiler/supplement_tracing.h
paddle/phi/api/profiler/supplement_tracing.h
+39
-0
paddle/phi/api/yaml/generator/api_base.py
paddle/phi/api/yaml/generator/api_base.py
+3
-3
paddle/phi/api/yaml/generator/api_gen.py
paddle/phi/api/yaml/generator/api_gen.py
+1
-1
paddle/phi/api/yaml/generator/backward_api_gen.py
paddle/phi/api/yaml/generator/backward_api_gen.py
+1
-1
paddle/phi/api/yaml/generator/intermediate_api_gen.py
paddle/phi/api/yaml/generator/intermediate_api_gen.py
+1
-1
未找到文件。
paddle/fluid/platform/profiler.cc
浏览文件 @
8476c552
...
...
@@ -38,10 +38,6 @@ PADDLE_DEFINE_EXPORTED_bool(enable_rpc_profiler,
false
,
"Enable rpc profiler or not."
);
DEFINE_bool
(
enable_record_op_info
,
false
,
"enable operator supplement info recorder"
);
DEFINE_bool
(
enable_record_memory
,
false
,
"enable memory recorder"
);
namespace
paddle
{
...
...
@@ -110,25 +106,6 @@ RecordOpInfoSupplement::RecordOpInfoSupplement(
PosixInNsec
(),
type
,
input_shapes
,
dtypes
,
attrs
,
op_id
);
}
RecordOpInfoSupplement
::
RecordOpInfoSupplement
(
const
std
::
string
&
type
,
const
std
::
vector
<
std
::
pair
<
const
char
*
,
std
::
vector
<
framework
::
DDim
>>>
&
input_shapes
,
const
framework
::
AttributeMap
&
attrs
)
{
if
(
FLAGS_enable_host_event_recorder_hook
==
false
)
{
return
;
}
if
(
IsEnabled
()
==
false
)
{
return
;
}
std
::
map
<
std
::
string
,
std
::
vector
<
framework
::
proto
::
VarType
::
Type
>>
dtypes
;
uint64_t
op_id
=
0
;
HostEventRecorder
<
OperatorSupplementOriginEvent
>::
GetInstance
().
RecordEvent
(
PosixInNsec
(),
type
,
input_shapes
,
dtypes
,
attrs
,
op_id
);
}
bool
RecordOpInfoSupplement
::
IsEnabled
()
{
return
FLAGS_enable_record_op_info
;
}
bool
RecordMemEvent
::
IsEnabled
()
{
return
FLAGS_enable_record_memory
;
}
std
::
map
<
const
char
*
,
std
::
map
<
uint64_t
,
std
::
vector
<
uint64_t
>>>
...
...
@@ -873,10 +850,6 @@ void DisableHostEventRecorder() {
FLAGS_enable_host_event_recorder_hook
=
false
;
}
void
EnableOpInfoRecorder
()
{
FLAGS_enable_record_op_info
=
true
;
}
void
DisableOpInfoRecorder
()
{
FLAGS_enable_record_op_info
=
false
;
}
void
EnableMemoryRecorder
()
{
FLAGS_enable_record_memory
=
true
;
}
void
DisableMemoryRecorder
()
{
FLAGS_enable_record_memory
=
false
;
}
...
...
paddle/fluid/platform/profiler.h
浏览文件 @
8476c552
...
...
@@ -214,9 +214,6 @@ void DisableHostEventRecorder();
void
EnableMemoryRecorder
();
void
DisableMemoryRecorder
();
void
EnableOpInfoRecorder
();
void
DisableOpInfoRecorder
();
// Defined for UT
std
::
string
PrintHostEvents
();
...
...
paddle/fluid/platform/profiler/common_event.h
浏览文件 @
8476c552
...
...
@@ -50,27 +50,7 @@ struct OperatorSupplementOriginEvent {
strncpy
(
buf
,
type_name
.
c_str
(),
type_name
.
length
()
+
1
);
op_type
=
buf
;
}
OperatorSupplementOriginEvent
(
std
::
function
<
void
*
(
size_t
)
>
arena_allocator
,
uint64_t
timestamp_ns
,
const
std
::
string
&
type_name
,
const
std
::
vector
<
std
::
pair
<
const
char
*
,
std
::
vector
<
framework
::
DDim
>>>
&
shapes
,
const
std
::
map
<
std
::
string
,
std
::
vector
<
framework
::
proto
::
VarType
::
Type
>>
&
dtypes
,
const
framework
::
AttributeMap
&
attributes
,
uint64_t
op_id
)
:
timestamp_ns
(
timestamp_ns
),
dtypes
(
dtypes
),
attributes
(
attributes
),
op_id
(
op_id
)
{
auto
buf
=
static_cast
<
char
*>
(
arena_allocator
(
type_name
.
length
()
+
1
));
strncpy
(
buf
,
type_name
.
c_str
(),
type_name
.
length
()
+
1
);
op_type
=
buf
;
for
(
auto
it
=
shapes
.
begin
();
it
!=
shapes
.
end
();
it
++
)
{
input_shapes
[
std
::
string
((
*
it
).
first
)]
=
(
*
it
).
second
;
}
}
uint64_t
timestamp_ns
;
const
char
*
op_type
=
nullptr
;
// not owned, designed for performance
// input shapes
...
...
paddle/fluid/platform/profiler/supplement_tracing.h
浏览文件 @
8476c552
...
...
@@ -21,6 +21,7 @@ limitations under the License. */
#include "paddle/fluid/framework/shape_inference.h"
#include "paddle/fluid/framework/type_defs.h"
#include "paddle/fluid/platform/profiler/trace_event.h"
#include "paddle/phi/api/profiler/supplement_tracing.h"
#include "paddle/phi/core/compat/arg_map_context.h"
namespace
paddle
{
...
...
@@ -30,10 +31,8 @@ class RuntimeContext;
}
namespace
platform
{
class
RecordOpInfoSupplement
{
class
RecordOpInfoSupplement
:
public
phi
::
RecordOpInfoSupplement
{
public:
static
bool
IsEnabled
();
/**
* @param type: Operator type name.
* @param attrs: Attribute map of op.
...
...
@@ -55,15 +54,6 @@ class RecordOpInfoSupplement {
const
framework
::
AttributeMap
&
attrs
,
const
framework
::
InferShapeContext
&
shape_ctx
,
const
phi
::
KernelSignature
&
kernel_signature
);
/**
*
*/
explicit
RecordOpInfoSupplement
(
const
std
::
string
&
type
,
const
std
::
vector
<
std
::
pair
<
const
char
*
,
std
::
vector
<
framework
::
DDim
>>>&
input_shapes
,
const
framework
::
AttributeMap
&
attrs
);
};
}
// namespace platform
...
...
paddle/fluid/pybind/pybind.cc
浏览文件 @
8476c552
...
...
@@ -2453,8 +2453,8 @@ All parameter, weight, gradient are variables in Paddle.
m
.
def
(
"load_profiler_result"
,
&
paddle
::
platform
::
LoadProfilerResult
);
m
.
def
(
"enable_memory_recorder"
,
&
paddle
::
platform
::
EnableMemoryRecorder
);
m
.
def
(
"disable_memory_recorder"
,
&
paddle
::
platform
::
DisableMemoryRecorder
);
m
.
def
(
"enable_op_info_recorder"
,
&
p
addle
::
platform
::
EnableOpInfoRecorder
);
m
.
def
(
"disable_op_info_recorder"
,
&
p
addle
::
platform
::
DisableOpInfoRecorder
);
m
.
def
(
"enable_op_info_recorder"
,
&
p
hi
::
EnableOpInfoRecorder
);
m
.
def
(
"disable_op_info_recorder"
,
&
p
hi
::
DisableOpInfoRecorder
);
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
m
.
def
(
"set_cublas_switch"
,
platform
::
SetAllowTF32Cublas
);
...
...
paddle/phi/api/profiler/common_event.h
浏览文件 @
8476c552
...
...
@@ -20,6 +20,7 @@
#include "paddle/phi/api/profiler/event.h" // import EventRole, TODO(TIEXING): remove later
#include "paddle/phi/api/profiler/trace_event.h"
#include "paddle/phi/core/attribute.h"
#include "paddle/phi/core/ddim.h"
namespace
phi
{
...
...
@@ -104,4 +105,31 @@ struct CommonMemEvent {
uint64_t
peak_reserved
;
};
struct
OperatorSupplementOriginEvent
{
public:
OperatorSupplementOriginEvent
(
std
::
function
<
void
*
(
size_t
)
>
arena_allocator
,
uint64_t
timestamp_ns
,
const
std
::
string
&
type_name
,
const
std
::
vector
<
std
::
pair
<
const
char
*
,
std
::
vector
<
DDim
>>>
&
shapes
,
const
AttributeMap
&
attributes
,
uint64_t
op_id
)
:
timestamp_ns
(
timestamp_ns
),
attributes
(
attributes
),
op_id
(
op_id
)
{
auto
buf
=
static_cast
<
char
*>
(
arena_allocator
(
type_name
.
length
()
+
1
));
strncpy
(
buf
,
type_name
.
c_str
(),
type_name
.
length
()
+
1
);
op_type
=
buf
;
for
(
auto
it
=
shapes
.
begin
();
it
!=
shapes
.
end
();
it
++
)
{
input_shapes
[
std
::
string
((
*
it
).
first
)]
=
(
*
it
).
second
;
}
}
uint64_t
timestamp_ns
;
const
char
*
op_type
=
nullptr
;
// not owned, designed for performance
// input shapes
std
::
map
<
std
::
string
,
std
::
vector
<
DDim
>>
input_shapes
;
// op attributes
AttributeMap
attributes
;
// op id
uint64_t
op_id
;
};
}
// namespace phi
paddle/phi/api/profiler/profiler.cc
浏览文件 @
8476c552
...
...
@@ -35,6 +35,10 @@ DEFINE_bool(enable_host_event_recorder_hook,
false
,
"enable HostEventRecorder, hook Profiler"
);
DEFINE_bool
(
enable_record_op_info
,
false
,
"enable operator supplement info recorder"
);
namespace
phi
{
ProfilerState
ProfilerHelper
::
g_state
=
ProfilerState
::
kDisabled
;
...
...
@@ -265,4 +269,25 @@ bool RecordEvent::IsEnabled() {
ProfilerHelper
::
g_state
!=
ProfilerState
::
kDisabled
;
}
RecordOpInfoSupplement
::
RecordOpInfoSupplement
(
const
std
::
string
&
type
,
const
std
::
vector
<
std
::
pair
<
const
char
*
,
std
::
vector
<
DDim
>>>
&
input_shapes
,
const
AttributeMap
&
attrs
)
{
if
(
FLAGS_enable_host_event_recorder_hook
==
false
)
{
return
;
}
if
(
IsEnabled
()
==
false
)
{
return
;
}
uint64_t
op_id
=
0
;
HostEventRecorder
<
OperatorSupplementOriginEvent
>::
GetInstance
().
RecordEvent
(
PosixInNsec
(),
type
,
input_shapes
,
attrs
,
op_id
);
}
bool
RecordOpInfoSupplement
::
IsEnabled
()
{
return
FLAGS_enable_record_op_info
;
}
void
EnableOpInfoRecorder
()
{
FLAGS_enable_record_op_info
=
true
;
}
void
DisableOpInfoRecorder
()
{
FLAGS_enable_record_op_info
=
false
;
}
}
// namespace phi
paddle/phi/api/profiler/profiler.h
浏览文件 @
8476c552
...
...
@@ -26,6 +26,7 @@ limitations under the License. */
#include "gflags/gflags.h"
#include "paddle/phi/api/profiler/event_tracing.h"
#include "paddle/phi/api/profiler/supplement_tracing.h"
DECLARE_bool
(
enable_host_event_recorder_hook
);
...
...
@@ -88,4 +89,7 @@ void PopEvent(const std::string& name,
const
EventRole
role
,
const
std
::
string
attr
=
"none"
);
void
EnableOpInfoRecorder
();
void
DisableOpInfoRecorder
();
}
// namespace phi
paddle/phi/api/profiler/supplement_tracing.h
0 → 100644
浏览文件 @
8476c552
/* Copyright (c) 2021 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. */
#pragma once
#include <map>
#include <string>
#include <utility>
#include "paddle/phi/core/attribute.h"
#include "paddle/phi/core/ddim.h"
namespace
phi
{
class
RecordOpInfoSupplement
{
public:
static
bool
IsEnabled
();
RecordOpInfoSupplement
()
=
default
;
explicit
RecordOpInfoSupplement
(
const
std
::
string
&
type
,
const
std
::
vector
<
std
::
pair
<
const
char
*
,
std
::
vector
<
DDim
>>>&
input_shapes
,
const
AttributeMap
&
attrs
);
};
}
// namespace phi
paddle/phi/api/yaml/generator/api_base.py
浏览文件 @
8476c552
...
...
@@ -886,7 +886,7 @@ PADDLE_API {self.get_return_type(inplace_flag=True)} {api_func_name}({self.get_d
input_tensor_code
=
(
input_tensor_code
+
f
"""
{
code_indent
}
if(p
latform
::RecordOpInfoSupplement::IsEnabled()){{"""
{
code_indent
}
if(p
hi
::RecordOpInfoSupplement::IsEnabled()){{"""
)
single_tensor_names
=
[]
list_tensor_names
=
[]
...
...
@@ -1030,7 +1030,7 @@ PADDLE_API {self.get_return_type(inplace_flag=True)} {api_func_name}({self.get_d
)
input_tensor_code
+=
f
"""
{
code_indent
}
framework
::AttributeMap attrs;"""
{
code_indent
}
phi
::AttributeMap attrs;"""
for
attr_name
in
self
.
attrs
[
'names'
]:
if
'IntArray'
in
self
.
attrs
[
'attr_info'
][
attr_name
][
0
]:
...
...
@@ -1096,7 +1096,7 @@ PADDLE_API {self.get_return_type(inplace_flag=True)} {api_func_name}({self.get_d
input_tensor_code
=
(
input_tensor_code
+
f
"""
{
code_indent
}
p
latform
::RecordOpInfoSupplement("
{
self
.
api
}
", input_shapes, attrs);
{
code_indent
}
p
hi
::RecordOpInfoSupplement("
{
self
.
api
}
", input_shapes, attrs);
{
code_indent
}
}}"""
)
kernel_args
=
[
"*dev_ctx"
]
...
...
paddle/phi/api/yaml/generator/api_gen.py
浏览文件 @
8476c552
...
...
@@ -344,7 +344,7 @@ def source_include(header_file_path):
#include "paddle/phi/infermeta/ternary.h"
#include "paddle/phi/api/profiler/event_tracing.h"
#include "paddle/
fluid/platform
/profiler/supplement_tracing.h"
#include "paddle/
phi/api
/profiler/supplement_tracing.h"
DECLARE_bool(conv2d_disable_cudnn);
DECLARE_int32(low_precision_op_list);
...
...
paddle/phi/api/yaml/generator/backward_api_gen.py
浏览文件 @
8476c552
...
...
@@ -287,7 +287,7 @@ def source_include(header_file_path):
#include "paddle/phi/infermeta/unary.h"
#include "paddle/phi/api/profiler/event_tracing.h"
#include "paddle/
fluid/platform
/profiler/supplement_tracing.h"
#include "paddle/
phi/api
/profiler/supplement_tracing.h"
DECLARE_bool(conv2d_disable_cudnn);
DECLARE_int32(low_precision_op_list);
...
...
paddle/phi/api/yaml/generator/intermediate_api_gen.py
浏览文件 @
8476c552
...
...
@@ -53,7 +53,7 @@ def source_include(header_file_path):
#include "paddle/phi/infermeta/sparse/multiary.h"
#include "paddle/phi/api/profiler/event_tracing.h"
#include "paddle/
fluid/platform
/profiler/supplement_tracing.h"
#include "paddle/
phi/api
/profiler/supplement_tracing.h"
DECLARE_int32(low_precision_op_list);
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录