@@ -62,7 +62,7 @@ def _atexit_print_fn():
62
62
else :
63
63
destination_file = config .profiling__destination
64
64
65
- with extended_open (destination_file , mode = "w" ):
65
+ with extended_open (destination_file , mode = "w" ) as f :
66
66
# Reverse sort in the order of compile+exec time
67
67
for ps in sorted (
68
68
_atexit_print_list , key = lambda a : a .compile_time + a .fct_call_time
@@ -73,7 +73,7 @@ def _atexit_print_fn():
73
73
or getattr (ps , "callcount" , 0 ) > 1
74
74
):
75
75
ps .summary (
76
- file = destination_file ,
76
+ file = f ,
77
77
n_ops_to_print = config .profiling__n_ops ,
78
78
n_apply_to_print = config .profiling__n_apply ,
79
79
)
@@ -131,7 +131,7 @@ def _atexit_print_fn():
131
131
cum .rewriter_profile = None
132
132
133
133
cum .summary (
134
- file = destination_file ,
134
+ file = f ,
135
135
n_ops_to_print = config .profiling__n_ops ,
136
136
n_apply_to_print = config .profiling__n_apply ,
137
137
)
@@ -157,7 +157,7 @@ def print_global_stats():
157
157
else :
158
158
destination_file = config .profiling__destination
159
159
160
- with extended_open (destination_file , mode = "w" ):
160
+ with extended_open (destination_file , mode = "w" ) as f :
161
161
print ("=" * 50 , file = destination_file )
162
162
print (
163
163
(
@@ -167,9 +167,9 @@ def print_global_stats():
167
167
"Time spent compiling PyTensor functions: "
168
168
f"rewriting = { total_graph_rewrite_time :6.3f} s, linking = { total_time_linker :6.3f} s " ,
169
169
),
170
- file = destination_file ,
170
+ file = f ,
171
171
)
172
- print ("=" * 50 , file = destination_file )
172
+ print ("=" * 50 , file = f )
173
173
174
174
175
175
_profiler_printers = []
0 commit comments