Skip to content

Commit 111208d

Browse files
authored
[Refactor] Set MKL by default. (#2714)
1 parent 0b3637c commit 111208d

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

.bazelrc

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ build:gpu --define=build_with_onednn_graph=true
2121
build:gpu --define=device=gpu
2222
build:gpu --define=tensorflow_mkldnn_contraction_kernel=0
2323
build:gpu --repo_env TF_NEED_SYCL=1
24+
build:gpu --repo_env TF_NEED_MKL=1
2425

2526
# This config option is used for GPU backend.
2627
# xpu will replace gpu as default config option for GPU only backend.
@@ -29,7 +30,8 @@ build:xpu --define=using_sycl=true --define=build_with_sycl=true --define=using_
2930
build:xpu --define=build_with_onednn_graph=true
3031
build:xpu --define=device=gpu
3132
build:xpu --define=tensorflow_mkldnn_contraction_kernel=0
32-
build:gpu --repo_env TF_NEED_SYCL=1
33+
build:xpu --repo_env TF_NEED_SYCL=1
34+
build:xpu --repo_env TF_NEED_MKL=1
3335

3436
# This config option is used for XPU backend (CPU + GPU). (Disabled)
3537
# build:xpu --crosstool_top=@itex_local_config_sycl//crosstool_sycl:toolchain

configure.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ def prompt_loop_or_load_from_env(environ_cp,
675675
break
676676
if not suppress_default_error:
677677
print(error_msg % val)
678-
environ_cp[var_name] = ''
678+
environ_cp[var_name] = None
679679
else:
680680
raise UserInputError('Invalid %s setting was provided %d times in a row. '
681681
'Assuming to be a scripting mistake.' %
@@ -751,9 +751,16 @@ def toolkit_exists(toolkit_path):
751751
lib_path += ':' + library_path
752752

753753
mkl_path = os.getenv('ONEAPI_MKL_PATH')
754-
if mkl_path is not None and len(mkl_path) > 0:
755-
mkl_lib = '%s/lib/intel64' % (mkl_path)
756-
lib_path += ':' + mkl_lib
754+
if mkl_path is None:
755+
"""Try to find mkl path."""
756+
home_path = sycl_toolkit_path.split("compiler")[0]
757+
version = sycl_toolkit_path.split("compiler")[1].split("/")[1]
758+
mkl_path = os.path.join(home_path, 'mkl' + '/' + version + '/')
759+
environ_cp['ONEAPI_MKL_PATH'] = mkl_path
760+
set_mkl_path(environ_cp)
761+
lib_path += ':' + '%slib/intel64' % (mkl_path)
762+
print('Configured oneMKL Toolkit path: %s\n' % (mkl_path))
763+
757764
write_action_env_to_bazelrc('LD_LIBRARY_PATH',
758765
ld_lib_path)
759766
write_action_env_to_bazelrc('LIBRARY_PATH',
@@ -769,7 +776,7 @@ def valid_mkl_path(mkl_home):
769776
print(
770777
'Invalid path to the MKL Toolkit. %s or %s cannot be found'
771778
% (os.path.join(mkl_home, 'include'),
772-
os.path.exists(os.path.join(mkl_home, 'lib'))))
779+
os.path.join(mkl_home, 'lib')))
773780
return exists
774781
mkl_path = prompt_loop_or_load_from_env(
775782
environ_cp,
@@ -1005,9 +1012,6 @@ def main():
10051012
if environ_cp.get('TF_NEED_SYCL') == '1':
10061013
set_sycl_toolkit_path(environ_cp)
10071014
set_aot_config(environ_cp)
1008-
set_action_env_var(environ_cp, 'TF_NEED_MKL', 'MKL', False)
1009-
if environ_cp.get('TF_NEED_MKL') == '1':
1010-
set_mkl_path(environ_cp)
10111015
else:
10121016
print('Only CPU support is available for '
10131017
'Intel® Extension for TensorFlow*.')

0 commit comments

Comments
 (0)