23
23
from ..fluid .profiler import profiler # noqa: F401
24
24
from ..fluid .profiler import stop_profiler
25
25
from ..fluid .profiler import reset_profiler
26
-
27
- __all__ = [ #noqa
28
- 'Profiler' , 'get_profiler' , 'ProfilerOptions' , 'cuda_profiler' ,
29
- 'start_profiler' , 'profiler' , 'stop_profiler' , 'reset_profiler'
26
+ from .deprecated import deprecated
27
+
28
+ __all__ = [ # noqa
29
+ 'Profiler' ,
30
+ 'get_profiler' ,
31
+ 'ProfilerOptions' ,
32
+ 'cuda_profiler' ,
33
+ 'start_profiler' ,
34
+ 'profiler' ,
35
+ 'stop_profiler' ,
36
+ 'reset_profiler' ,
30
37
]
31
38
32
39
40
+ @deprecated (
41
+ since = "2.4.2" ,
42
+ update_to = "paddle.profiler.Profiler" ,
43
+ level = 1 ,
44
+ reason = "Please use new profiler tool, this profiler tool is no longer maintained." ,
45
+ )
33
46
class ProfilerOptions (object ):
34
-
35
47
def __init__ (self , options = None ):
36
48
self .options = {
37
49
'state' : 'All' ,
@@ -41,7 +53,7 @@ def __init__(self, options=None):
41
53
'output_thread_detail' : False ,
42
54
'profile_path' : 'none' ,
43
55
'timeline_path' : 'none' ,
44
- 'op_summary_path' : 'none'
56
+ 'op_summary_path' : 'none' ,
45
57
}
46
58
if options is not None :
47
59
for key in self .options .keys ():
@@ -56,10 +68,13 @@ def with_state(self, state):
56
68
def __getitem__ (self , name ):
57
69
if self .options .get (name , None ) is None :
58
70
raise ValueError (
59
- "ProfilerOptions does not have an option named %s." % name )
71
+ "ProfilerOptions does not have an option named %s." % name
72
+ )
60
73
else :
61
- if isinstance (self .options [name ],
62
- str ) and self .options [name ] == 'none' :
74
+ if (
75
+ isinstance (self .options [name ], str )
76
+ and self .options [name ] == 'none'
77
+ ):
63
78
return None
64
79
else :
65
80
return self .options [name ]
@@ -68,8 +83,13 @@ def __getitem__(self, name):
68
83
_current_profiler = None
69
84
70
85
86
+ @deprecated (
87
+ since = "2.4.2" ,
88
+ update_to = "paddle.profiler.Profiler" ,
89
+ level = 1 ,
90
+ reason = "Please use new profiler tool, this profiler tool is no longer maintained." ,
91
+ )
71
92
class Profiler (object ):
72
-
73
93
def __init__ (self , enabled = True , options = None ):
74
94
if options is not None :
75
95
self .profiler_options = options
@@ -101,22 +121,28 @@ def start(self):
101
121
try :
102
122
start_profiler (
103
123
state = self .profiler_options ['state' ],
104
- tracer_option = self .profiler_options ['tracer_level' ])
124
+ tracer_option = self .profiler_options ['tracer_level' ],
125
+ )
105
126
except Exception as e :
106
127
warnings .warn (
107
- "Profiler is not enabled becuase following exception:\n {}" .
108
- format (e ))
128
+ "Profiler is not enabled becuase following exception:\n {}" .format (
129
+ e
130
+ )
131
+ )
109
132
110
133
def stop (self ):
111
134
if self .enabled :
112
135
try :
113
136
stop_profiler (
114
137
sorted_key = self .profiler_options ['sorted_key' ],
115
- profile_path = self .profiler_options ['profile_path' ])
138
+ profile_path = self .profiler_options ['profile_path' ],
139
+ )
116
140
except Exception as e :
117
141
warnings .warn (
118
- "Profiler is not disabled becuase following exception:\n {}" .
119
- format (e ))
142
+ "Profiler is not disabled becuase following exception:\n {}" .format (
143
+ e
144
+ )
145
+ )
120
146
121
147
def reset (self ):
122
148
if self .enabled and core .is_profiler_enabled ():
@@ -137,6 +163,12 @@ def record_step(self, change_profiler_status=True):
137
163
self .stop ()
138
164
139
165
166
+ @deprecated (
167
+ since = "2.4.2" ,
168
+ update_to = "paddle.profiler.Profiler" ,
169
+ level = 1 ,
170
+ reason = "Please use new profiler tool, this profiler tool is no longer maintained." ,
171
+ )
140
172
def get_profiler ():
141
173
global _current_profiler
142
174
if _current_profiler is None :
0 commit comments