Skip to content

create_inference_config modify use_mkldnn [fluid_ops] #74516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions test/ir/inference/inference_pass_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, methodName='runTest'):
self.feeds = None
self.fetch_list = None

self.enable_mkldnn = False
self.enable_onednn = False
self.enable_onednn_bfloat16 = False
self.enable_trt = False
self.enable_tensorrt_varseqlen = False
Expand Down Expand Up @@ -130,7 +130,7 @@ def _get_inference_outs(self, config):
return outs

def _get_analysis_config(
self, use_gpu=False, use_trt=False, use_mkldnn=False
self, use_gpu=False, use_trt=False, use_onednn=False
):
'''
Return a new object of AnalysisConfig.
Expand Down Expand Up @@ -178,7 +178,7 @@ def _get_analysis_config(
if self.enable_tensorrt_varseqlen:
config.enable_tensorrt_varseqlen()

elif use_mkldnn:
elif use_onednn:
config.enable_onednn()
if self.enable_onednn_bfloat16:
config.enable_onednn_bfloat16()
Expand Down Expand Up @@ -286,10 +286,10 @@ def check_output_with_option(
)

# Check whether the onednn results and the CPU results are the same.
if (not use_gpu) and self.enable_mkldnn:
if (not use_gpu) and self.enable_onednn:
onednn_outputs = self._get_inference_outs(
self._get_analysis_config(
use_gpu=use_gpu, use_mkldnn=self.enable_mkldnn
use_gpu=use_gpu, use_onednn=self.enable_onednn
)
)

Expand Down
10 changes: 5 additions & 5 deletions test/ir/inference/quant_dequant_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, methodName='runTest'):
self.test_startup_program = paddle.static.Program()
self.feeds = None
self.fetch_list = None
self.enable_mkldnn = False
self.enable_onednn = False
self.enable_onednn_bfloat16 = False
self.enable_trt = False
self.enable_tensorrt_varseqlen = True
Expand Down Expand Up @@ -190,7 +190,7 @@ def _get_inference_outs(self, config):
return outs

def _get_analysis_config(
self, use_gpu=False, use_trt=False, use_mkldnn=False
self, use_gpu=False, use_trt=False, use_onednn=False
):
'''
Return a new object of AnalysisConfig.
Expand Down Expand Up @@ -230,7 +230,7 @@ def _get_analysis_config(
if self.enable_tensorrt_varseqlen:
config.enable_tensorrt_varseqlen()

elif use_mkldnn:
elif use_onednn:
config.enable_onednn()
if self.enable_onednn_bfloat16:
config.enable_onednn_bfloat16()
Expand Down Expand Up @@ -388,10 +388,10 @@ def check_output_with_option(
)

# Check whether the onednn results and the CPU results are the same.
if (not use_gpu) and self.enable_mkldnn:
if (not use_gpu) and self.enable_onednn:
onednn_outputs = self._get_inference_outs(
self._get_analysis_config(
use_gpu=use_gpu, use_mkldnn=self.enable_mkldnn
use_gpu=use_gpu, use_onednn=self.enable_onednn
)
)

Expand Down
2 changes: 1 addition & 1 deletion test/ir/inference/test_conv_act_onednn_fuse_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def sample_program_config(self, draw):
groups=groups,
dilations=dilations,
data_format=data_format,
use_mkldnn=True,
use_onednn=True,
)

ops = [conv2d_op, act_op]
Expand Down
4 changes: 2 additions & 2 deletions test/ir/inference/test_conv_bn_fuse_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def generate_bn_Var():
groups=groups,
paddings=paddings,
strides=strides,
use_mkldnn=use_onednn,
use_onednn=use_onednn,
has_bias=False,
is_test=True,
)
Expand Down Expand Up @@ -158,7 +158,7 @@ def generate_bn_Var():

def sample_predictor_configs(self, program_config):
# for onednn
if program_config.ops[0].attrs['use_mkldnn']:
if program_config.ops[0].attrs['use_onednn']:
config = self.create_inference_config(use_onednn=True)
yield config, ['fused_conv2d'], (1e-5, 1e-5)
else:
Expand Down
6 changes: 3 additions & 3 deletions test/ir/inference/test_conv_transpose_bn_fuse_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def sample_program_config(self, draw):
st.sampled_from(["EXPLICIT", "SAME", "VALID"])
)
random_data_layout = draw(st.sampled_from(["NCHW", "NHWC"]))
random_use_mkldnn = draw(st.booleans())
random_use_onednn = draw(st.booleans())
random_output_size = []
random_filter = draw(
st.lists(
Expand Down Expand Up @@ -133,7 +133,7 @@ def generate_batch_norm_Variance():
'data_format': random_data_layout,
'output_size': random_output_size,
'output_padding': random_output_size,
'use_mkldnn': random_use_mkldnn,
'use_mkldnn': random_use_onednn,
'is_test': True,
},
)
Expand All @@ -160,7 +160,7 @@ def generate_batch_norm_Variance():
'is_test': True,
'trainable_statistics': False,
'data_layout': random_data_layout,
'use_mkldnn': random_use_mkldnn,
'use_mkldnn': random_use_onednn,
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def sample_program_config(self, draw):
st.sampled_from(["EXPLICIT", "SAME", "VALID"])
)
random_data_layout = draw(st.sampled_from(["NCHW", "NHWC"]))
random_use_mkldnn = draw(st.booleans())
random_use_onednn = draw(st.booleans())
random_output_size = []
random_filter = draw(
st.lists(
Expand Down Expand Up @@ -141,7 +141,7 @@ def generate_batch_norm_Variance():
'data_format': random_data_layout,
'output_size': random_output_size,
'output_padding': random_output_size,
'use_mkldnn': random_use_mkldnn,
'use_mkldnn': random_use_onednn,
'is_test': True,
},
)
Expand Down Expand Up @@ -182,7 +182,7 @@ def generate_batch_norm_Variance():
'is_test': True,
'trainable_statistics': False,
'data_layout': random_data_layout,
'use_mkldnn': random_use_mkldnn,
'use_mkldnn': random_use_onednn,
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def sample_program_config(self, draw):
padding_weights=False,
activation_type="",
use_quantizer=False,
use_mkldnn=False,
use_onednn=False,
)
add_op = OpConfig(
"elementwise_add",
Expand Down
4 changes: 2 additions & 2 deletions test/ir/inference/test_mkldnn_int8_scale_calculation_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def sample_program_config(self, draw):
bias_shape = [f_shape[0]]
inputs = {}
weights = {}
use_mkldnn = True
use_onednn = True

has_bias = draw(st.booleans())
if has_bias:
Expand Down Expand Up @@ -154,7 +154,7 @@ def sample_program_config(self, draw):
groups=groups,
dilations=dilations,
data_format=data_format,
use_mkldnn=use_mkldnn,
use_onednn=use_onednn,
mkldnn_data_type="int8",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def generate_input(type):

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True,
use_onednn=True,
passes=[
'matmul_activation_onednn_fuse_pass',
'operator_scale_onednn_fuse_pass',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def generate_input():

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True,
use_onednn=True,
passes=[
'matmul_elementwise_add_onednn_fuse_pass',
'matmul_activation_onednn_fuse_pass',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def generate_input():

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True, passes=['matmul_elementwise_add_onednn_fuse_pass']
use_onednn=True, passes=['matmul_elementwise_add_onednn_fuse_pass']
)
yield config, ['fused_matmul'], (1e-5, 1e-5)

Expand Down Expand Up @@ -137,7 +137,7 @@ def generate_input():

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True, passes=['matmul_elementwise_add_onednn_fuse_pass']
use_onednn=True, passes=['matmul_elementwise_add_onednn_fuse_pass']
)
yield config, ['fused_matmul'], (1e-5, 1e-5)

Expand Down Expand Up @@ -203,7 +203,7 @@ def generate_input_redisual():

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True, passes=['matmul_elementwise_add_onednn_fuse_pass']
use_onednn=True, passes=['matmul_elementwise_add_onednn_fuse_pass']
)
yield config, ['fused_matmul'], (1e-5, 1e-5)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def generate_input(type):

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True,
use_onednn=True,
passes=[
'matmul_activation_onednn_fuse_pass',
'operator_scale_onednn_fuse_pass',
Expand Down
2 changes: 1 addition & 1 deletion test/ir/inference/test_mkldnn_scale_matmul_fuse_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def generate_input(attrs, type):

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True, passes=['scale_matmul_fuse_pass']
use_onednn=True, passes=['scale_matmul_fuse_pass']
)
yield config, ['matmul'], (1e-5, 1e-5)

Expand Down
8 changes: 4 additions & 4 deletions test/ir/inference/test_onednn_conv_bias_fuse_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def sample_program_config(self, draw):
conv_bias_shape = []
inputs = {}
weights = {}
use_mkldnn = None
use_onednn = None
conv_type = 'conv2d'
if draw(st.booleans()):
conv_bias_shape = [f_shape[0]]
Expand All @@ -145,7 +145,7 @@ def sample_program_config(self, draw):
'bias': TensorConfig(shape=bias_shape),
'conv_bias': TensorConfig(shape=conv_bias_shape),
}
use_mkldnn = True
use_onednn = True
else:
inputs = {
'Input': ['input_x'],
Expand All @@ -155,7 +155,7 @@ def sample_program_config(self, draw):
'filter': TensorConfig(shape=f_shape),
'bias': TensorConfig(shape=bias_shape),
}
use_mkldnn = False
use_onednn = False

conv2d_op = OpConfig(
conv_type,
Expand All @@ -167,7 +167,7 @@ def sample_program_config(self, draw):
groups=groups,
dilations=dilations,
data_format=data_format,
use_mkldnn=use_mkldnn,
use_onednn=use_onednn,
)

add_op = OpConfig(
Expand Down
4 changes: 2 additions & 2 deletions test/ir/inference/test_onednn_conv_bn_fuse_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class TestOneDNNConvBnFusePass(PassAutoScanTest):
def sample_program_config(self, draw):
use_mkldnn = True
use_onednn = True
padding_algorithm = draw(st.sampled_from(["EXPLICIT", "SAME", "VALID"]))
groups = draw(st.integers(min_value=1, max_value=3))
data_format = draw(st.sampled_from(["NCHW", "NHWC"]))
Expand Down Expand Up @@ -78,7 +78,7 @@ def generate_data(shape):
groups=groups,
paddings=paddings,
strides=strides,
use_mkldnn=use_mkldnn,
use_onednn=use_onednn,
has_bias=False,
is_test=True,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def generate_input():

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True,
use_onednn=True,
passes=[
'elementwise_act_onednn_fuse_pass',
'operator_scale_onednn_fuse_pass',
Expand Down
2 changes: 1 addition & 1 deletion test/ir/inference/test_onednn_fc_activation_fuse_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def generate_input(shape):

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True,
use_onednn=True,
passes=[
"fc_act_onednn_fuse_pass",
"operator_scale_onednn_fuse_pass",
Expand Down
2 changes: 1 addition & 1 deletion test/ir/inference/test_onednn_fc_gru_fuse_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def generate_input(shape):

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True,
use_onednn=True,
passes=[
'onednn_placement_pass',
'fc_gru_fuse_pass',
Expand Down
2 changes: 1 addition & 1 deletion test/ir/inference/test_onednn_fc_lstm_fuse_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def generate_data(shape):

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True,
use_onednn=True,
passes=[
'onednn_placement_pass',
'fc_lstm_fuse_pass',
Expand Down
2 changes: 1 addition & 1 deletion test/ir/inference/test_onednn_multi_gru_fuse_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def generate_bias(shape):

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True,
use_onednn=True,
passes=['multi_gru_fuse_pass'],
)
yield config, ['multi_gru'], (1e-5, 1e-5)
Expand Down
2 changes: 1 addition & 1 deletion test/ir/inference/test_onednn_multi_gru_seq_fuse_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def generate_bias(shape):

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True,
use_onednn=True,
passes=['multi_gru_fuse_pass', 'multi_gru_seq_fuse_pass'],
)
yield config, ['multi_gru'], (1e-5, 1e-5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def generate_input(shape):

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True,
use_onednn=True,
passes=[
"operator_reshape2_onednn_fuse_pass",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def generate_input(shape):

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True,
use_onednn=True,
passes=[
"operator_unsqueeze2_onednn_fuse_pass",
],
Expand Down Expand Up @@ -138,7 +138,7 @@ def generate_input(shape):

def sample_predictor_configs(self, program_config):
config = self.create_inference_config(
use_mkldnn=True,
use_onednn=True,
passes=[
"operator_unsqueeze2_onednn_fuse_pass",
],
Expand Down
Loading