Skip to content

Commit 93fda0a

Browse files
[PIR] delete python use_mkldnn part2 (#59554)
* delete python use_mkldnn part2
1 parent 257f5d3 commit 93fda0a

File tree

22 files changed

+25
-87
lines changed

22 files changed

+25
-87
lines changed

python/paddle/base/backward.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def _accumulate_gradients_by_sum_op_(
478478
"sum",
479479
{"X": renamed_vars[var_name]},
480480
{"Out": [var_name]},
481-
{"use_mkldnn": False, "op_device": op_device},
481+
{"op_device": op_device},
482482
)
483483
)
484484
renamed_vars[var_name] = [var_name]
@@ -505,7 +505,7 @@ def _accumulate_gradients_by_add_ops_(
505505
"grad_add",
506506
{"X": [x_name], "Y": [y_name]},
507507
{"Out": [out_name]},
508-
{"use_mkldnn": False, "op_device": op_device},
508+
{"op_device": op_device},
509509
)
510510
)
511511
renamed_vars[var_name] = [var_name]

python/paddle/base/dygraph_utils.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@
1818

1919

2020
@dygraph_only
21-
def _append_activation_in_dygraph(
22-
input, act=None, use_cudnn=None, use_mkldnn=None
23-
):
21+
def _append_activation_in_dygraph(input, act=None, use_cudnn=None):
2422
"""Append activation in dygraph mode.
2523
2624
Args:
2725
input: the input variable.
2826
act: activation type
29-
use_mkldnn: if use mkldnn
3027
use_cudnn: if use cudnn
3128
3229
Return the Variable after append activation
@@ -37,8 +34,6 @@ def _append_activation_in_dygraph(
3734
attrs = ()
3835
if use_cudnn:
3936
attrs = ('use_cudnn', use_cudnn)
40-
if use_mkldnn:
41-
attrs += ('use_mkldnn', use_mkldnn)
4237

4338
act_op = getattr(_legacy_C_ops, act)
4439
return act_op(input, *attrs)

python/paddle/base/layer_helper.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from .dygraph_utils import _append_activation_in_dygraph
2121
from .framework import (
2222
Parameter,
23-
_global_flags,
2423
dtype_is_floating,
2524
in_dygraph_mode,
2625
)
@@ -156,16 +155,9 @@ def append_activation(self, input_var):
156155
if 'use_cudnn' in self.kwargs and self.kwargs.get('use_cudnn'):
157156
use_cudnn = self.kwargs.get('use_cudnn')
158157
act['use_cudnn'] = use_cudnn
159-
use_mkldnn = self.kwargs.get(
160-
'use_mkldnn', _global_flags().get("FLAGS_use_mkldnn", False)
161-
)
162-
if use_mkldnn:
163-
act['use_mkldnn'] = use_mkldnn
164158
act_type = act.pop('type')
165159
if in_dygraph_mode():
166-
res = _append_activation_in_dygraph(
167-
input_var, act_type, use_cudnn, use_mkldnn
168-
)
160+
res = _append_activation_in_dygraph(input_var, act_type, use_cudnn)
169161
return res
170162
else:
171163
tmp = self.create_variable_for_type_inference(dtype=input_var.dtype)

python/paddle/base/layers/layer_function_generator.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ def _generate_doc_string_(
9292
buf.write('\n')
9393

9494
skip_attrs = OpProtoHolder.generated_op_attr_names()
95-
# attr use_mkldnn and is_test also should not be visible to users.
96-
skip_attrs.add("use_mkldnn")
9795
skip_attrs.add("is_test")
9896
skip_attrs.add("use_cudnn")
9997

python/paddle/distributed/fleet/meta_optimizers/sharding_optimizer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,6 @@ def create_persistable_gradients_and_insert_merge_ops(
18151815
outputs={'Out': gradient_merge_var},
18161816
attrs={
18171817
'axis': -1,
1818-
'use_mkldnn': False,
18191818
OP_ROLE_KEY: OpRole.Backward,
18201819
},
18211820
)
@@ -1884,7 +1883,6 @@ def _create_gm_cond(self, main_block):
18841883
attrs={
18851884
'axis': -1,
18861885
OP_ROLE_KEY: OpRole.Optimize,
1887-
'use_mkldnn': False,
18881886
},
18891887
)
18901888

python/paddle/distributed/passes/auto_parallel_gradient_merge.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ def _get_gm_cond_var(main_program, k_steps, dist_context):
128128
outputs={'Out': step_var},
129129
attrs={
130130
'axis': -1,
131-
'use_mkldnn': False,
132131
OP_ROLE_KEY: OpRole.Backward,
133132
},
134133
)
@@ -235,7 +234,6 @@ def _append_gradient_merge_backward_op(
235234
outputs={'Out': gradient_merge_var},
236235
attrs={
237236
'axis': -1,
238-
'use_mkldnn': False,
239237
OP_ROLE_KEY: OpRole.Backward,
240238
},
241239
)

python/paddle/distributed/transpiler/distribute_transpiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,7 +2198,7 @@ def _create_table_optimize_block(
21982198
type="sum",
21992199
inputs={"X": pserver_side_table_grad_list},
22002200
outputs={"Out": [grad_var]},
2201-
attrs={"use_mkldnn": False},
2201+
attrs={},
22022202
)
22032203
else:
22042204
# in async_mode, for table gradient, it also need to be split to each parameter server
@@ -2490,7 +2490,7 @@ def _append_pserver_grad_merge_ops(
24902490
type="sum",
24912491
inputs={"X": vars2merge},
24922492
outputs={"Out": merged_var},
2493-
attrs={"use_mkldnn": False},
2493+
attrs={},
24942494
)
24952495
optimize_block.append_op(
24962496
type="scale",

python/paddle/incubate/asp/asp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,6 @@ def _insert_sparse_mask_ops(cls, main_program, params):
910910
outputs={'Out': param},
911911
attrs={
912912
'axis': -1,
913-
'use_mkldnn': False,
914913
OP_ROLE_KEY: int(OpRole.Optimize),
915914
},
916915
)

python/paddle/incubate/distributed/fleet/parameter_server/ir/pserver_pass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def _append_pserver_grad_merge_ops(
445445
type="sum",
446446
inputs={"X": vars2merge},
447447
outputs={"Out": merged_var},
448-
attrs={"use_mkldnn": False},
448+
attrs={},
449449
)
450450
optimize_block.append_op(
451451
type="scale",

python/paddle/incubate/optimizer/gradient_merge.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def _get_gm_cond_var(self, main_block):
233233
type='elementwise_mod',
234234
inputs={'X': step_var, 'Y': k_step_var},
235235
outputs={'Out': step_var},
236-
attrs={'axis': -1, 'use_mkldnn': False},
236+
attrs={'axis': -1},
237237
)
238238

239239
# cond_var = (step_var == 0)
@@ -302,7 +302,7 @@ def apply_gradients(self, params_grads):
302302
type="elementwise_add",
303303
inputs={'X': grad, 'Y': gradient_merge_var},
304304
outputs={'Out': gradient_merge_var},
305-
attrs={'axis': -1, 'use_mkldnn': False},
305+
attrs={'axis': -1},
306306
)
307307
self._add_gm_op_role_var(
308308
new_grad_op, param, gradient_merge_var, cond

python/paddle/nn/functional/conv.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ def _conv_nd(
120120
channel_dim=1,
121121
op_type="conv2d",
122122
use_cudnn=True,
123-
use_mkldnn=False,
124123
name=None,
125124
):
126125
# Due to the poor performance of NHWC, we transpose the input to NCHW.
@@ -203,8 +202,6 @@ def _conv_nd(
203202
groups,
204203
'use_cudnn',
205204
use_cudnn,
206-
'use_mkldnn',
207-
use_mkldnn,
208205
'fuse_relu_before_depthwise_conv',
209206
False,
210207
"padding_algorithm",
@@ -225,7 +222,6 @@ def _conv_nd(
225222
'dilations': dilation,
226223
'groups': groups,
227224
'use_cudnn': use_cudnn,
228-
'use_mkldnn': use_mkldnn,
229225
'fuse_relu_before_depthwise_conv': False,
230226
"padding_algorithm": padding_algorithm,
231227
"data_format": data_format,
@@ -249,7 +245,7 @@ def _conv_nd(
249245
type='elementwise_add',
250246
inputs={'X': [pre_bias], 'Y': [bias]},
251247
outputs={'Out': [out]},
252-
attrs={'axis': -1, 'use_mkldnn': use_mkldnn},
248+
attrs={'axis': -1},
253249
)
254250
else:
255251
assert len(x_shape) > len(
@@ -264,7 +260,7 @@ def _conv_nd(
264260
type='elementwise_add',
265261
inputs={'X': [pre_bias], 'Y': [bias]},
266262
outputs={'Out': [out]},
267-
attrs={'axis': -1, 'use_mkldnn': use_mkldnn},
263+
attrs={'axis': -1},
268264
)
269265
else:
270266
out = pre_bias
@@ -496,7 +492,6 @@ def conv1d(
496492
'dilations': dilation,
497493
'groups': groups,
498494
'use_cudnn': use_cudnn,
499-
'use_mkldnn': False,
500495
'fuse_relu_before_depthwise_conv': False,
501496
"padding_algorithm": padding_algorithm,
502497
"data_format": conv2d_data_format,
@@ -733,8 +728,6 @@ def conv2d(
733728
else:
734729
return pre_bias
735730

736-
use_mkldnn = _global_flags()["FLAGS_use_mkldnn"]
737-
738731
if (
739732
is_compiled_with_cuda()
740733
and get_flags("FLAGS_conv2d_disable_cudnn")[
@@ -756,7 +749,6 @@ def conv2d(
756749
channel_dim,
757750
l_type,
758751
use_cudnn,
759-
use_mkldnn,
760752
name,
761753
)
762754

@@ -1322,7 +1314,7 @@ def conv2d_transpose(
13221314
type='elementwise_add',
13231315
inputs={'X': [pre_bias], 'Y': [bias]},
13241316
outputs={'Out': [out]},
1325-
attrs={'axis': -1, 'use_mkldnn': False},
1317+
attrs={'axis': -1},
13261318
)
13271319
else:
13281320
assert len(x_shape) > len(
@@ -1336,7 +1328,7 @@ def conv2d_transpose(
13361328
type='elementwise_add',
13371329
inputs={'X': [pre_bias], 'Y': [bias]},
13381330
outputs={'Out': [out]},
1339-
attrs={'axis': -1, 'use_mkldnn': False},
1331+
attrs={'axis': -1},
13401332
)
13411333
else:
13421334
out = pre_bias
@@ -1517,7 +1509,6 @@ def conv3d(
15171509
channel_dim,
15181510
op_type,
15191511
use_cudnn,
1520-
False,
15211512
name,
15221513
)
15231514

python/paddle/nn/functional/norm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ def batch_norm(
239239
"epsilon": epsilon,
240240
"is_test": not training,
241241
"data_layout": data_format,
242-
"use_mkldnn": False,
243242
"fuse_with_relu": False,
244243
"use_global_stats": use_global_stats,
245244
"trainable_statistics": trainable_statistics,

python/paddle/nn/functional/pooling.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ def avg_pool1d(
288288
"padding_algorithm": padding_algorithm,
289289
"use_cudnn": True,
290290
"ceil_mode": ceil_mode,
291-
"use_mkldnn": False,
292291
"exclusive": exclusive,
293292
"data_format": data_format,
294293
},
@@ -415,7 +414,6 @@ def avg_pool2d(
415414
"padding_algorithm": padding_algorithm,
416415
"use_cudnn": True,
417416
"ceil_mode": ceil_mode,
418-
"use_mkldnn": False,
419417
"exclusive": exclusive,
420418
"data_format": data_format,
421419
},
@@ -542,7 +540,6 @@ def avg_pool3d(
542540
"padding_algorithm": padding_algorithm,
543541
"use_cudnn": True,
544542
"ceil_mode": ceil_mode,
545-
"use_mkldnn": False,
546543
"exclusive": exclusive,
547544
"data_format": data_format,
548545
},
@@ -677,7 +674,6 @@ def max_pool1d(
677674
"padding_algorithm": padding_algorithm,
678675
"use_cudnn": True,
679676
"ceil_mode": ceil_mode,
680-
"use_mkldnn": False,
681677
"exclusive": True,
682678
"data_format": data_format,
683679
},
@@ -1303,7 +1299,6 @@ def max_pool2d(
13031299
"padding_algorithm": padding_algorithm,
13041300
"use_cudnn": True,
13051301
"ceil_mode": ceil_mode,
1306-
"use_mkldnn": False,
13071302
"exclusive": True,
13081303
"data_format": data_format,
13091304
},
@@ -1326,7 +1321,6 @@ def max_pool2d(
13261321
"padding_algorithm": padding_algorithm,
13271322
"use_cudnn": True,
13281323
"ceil_mode": ceil_mode,
1329-
"use_mkldnn": False,
13301324
"exclusive": True,
13311325
"data_format": data_format,
13321326
},
@@ -1468,7 +1462,6 @@ def max_pool3d(
14681462
"padding_algorithm": padding_algorithm,
14691463
"use_cudnn": True,
14701464
"ceil_mode": ceil_mode,
1471-
"use_mkldnn": False,
14721465
"exclusive": False,
14731466
"data_format": data_format,
14741467
},

python/paddle/nn/initializer/normal.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def forward(self, var, block=None):
103103
"mean": self._mean,
104104
"std": self._std_dev,
105105
"seed": self._seed,
106-
"use_mkldnn": False,
107106
},
108107
stop_gradient=True,
109108
)

python/paddle/nn/layer/layers.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
Parameter,
3939
Program,
4040
_current_expected_place as _get_device,
41-
_global_flags,
4241
convert_np_dtype_to_dtype_,
4342
default_main_program,
4443
in_dygraph_mode,
@@ -266,14 +265,9 @@ def append_activation(self, input_var, act=None, use_cudnn=None):
266265

267266
if (use_cudnn is not None) and use_cudnn:
268267
act['use_cudnn'] = use_cudnn
269-
use_mkldnn = _global_flags()["FLAGS_use_mkldnn"]
270-
if (use_mkldnn is not None) and use_mkldnn:
271-
act['use_mkldnn'] = use_mkldnn
272268
act_type = act.pop('type')
273269
if in_dygraph_mode():
274-
res = _append_activation_in_dygraph(
275-
input_var, act_type, use_cudnn, use_mkldnn
276-
)
270+
res = _append_activation_in_dygraph(input_var, act_type, use_cudnn)
277271
return res
278272
else:
279273
tmp = self.create_variable_for_type_inference(dtype=input_var.dtype)

python/paddle/nn/layer/norm.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,6 @@ def __init__(
970970
self._param_attr = param_attr
971971
self._bias_attr = bias_attr
972972
self._act = act
973-
self._use_mkldnn = _global_flags()["FLAGS_use_mkldnn"]
974973

975974
if dtype == "float16":
976975
self._dtype = "float32"
@@ -1073,9 +1072,8 @@ def forward(self, input):
10731072
)
10741073
if self._act is None:
10751074
return batch_norm_out
1076-
10771075
return dygraph_utils._append_activation_in_dygraph(
1078-
batch_norm_out, act=self._act, use_mkldnn=self._use_mkldnn
1076+
batch_norm_out, act=self._act
10791077
)
10801078
elif in_pir_mode():
10811079
batch_norm_out, t1, t2, t3, t4, _ = _C_ops.batch_norm_(
@@ -1111,7 +1109,6 @@ def forward(self, input):
11111109
"epsilon": self._epsilon,
11121110
"is_test": self._is_test,
11131111
"data_layout": self._data_layout,
1114-
"use_mkldnn": False,
11151112
"fuse_with_relu": self._fuse_with_relu,
11161113
"use_global_stats": self._use_global_stats,
11171114
"trainable_statistics": self._trainable_statistics,
@@ -1668,7 +1665,6 @@ def forward(self, x):
16681665
"epsilon": self._epsilon,
16691666
"is_test": not self.training,
16701667
"data_layout": self._data_format,
1671-
"use_mkldnn": False,
16721668
"fuse_with_relu": False,
16731669
"use_global_stats": False,
16741670
"trainable_statistics": False,

0 commit comments

Comments
 (0)