From 06bd777caade59fd29823911c9a61a3cc75f716d Mon Sep 17 00:00:00 2001 From: dmitrii-kriukov Date: Tue, 21 Dec 2021 16:15:27 +0000 Subject: [PATCH 1/4] devices-dtypes --- runner.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/runner.py b/runner.py index a8ab77e5d..34034d648 100755 --- a/runner.py +++ b/runner.py @@ -44,9 +44,17 @@ def get_configs(path: Path) -> List[str]: default='configs/config_example.json', help='The path to a configuration file or ' 'a directory that contains configuration files') + parser.add_argument('--device', '--devices', default='host cpu gpu None', type=str, nargs='+', + choices=('host', 'cpu', 'gpu', 'None'), + help='Availible execution context devices. ' + 'This parameter only marks devices as available, ' + 'make sure to add the device to the config file to run it on a specific device') parser.add_argument('--dummy-run', default=False, action='store_true', help='Run configuration parser and datasets generation ' 'without benchmarks running') + parser.add_argument('--dtype', '--dtypes', type=str, default="float32 float64", nargs='+', + choices=("float32", "float64"), + help='Available Data types') parser.add_argument('--no-intel-optimized', default=False, action='store_true', help='Use Scikit-learn without Intel optimizations') parser.add_argument('--output-file', default='results.json', @@ -93,6 +101,27 @@ def get_configs(path: Path) -> List[str]: for params_set in config['cases']: params = common_params.copy() params.update(params_set.copy()) + + device = [] + if 'device' not in params: + if 'sklearn' in params['lib']: + logging.info('The device parameter value is not defined in config, None is used') + device = ['None'] + elif not isinstance(params['device'] , list): + device = [params['device']] + else: + device = params['device'] + params["device"] = [dv for dv in device if dv in args.device] + + dtype = [] + if 'dtype' not in params: + dtype = ['float64'] + elif not isinstance(params['dtype'] , list): + dtype = [params['dtype']] + else: + dtype = params['dtype'] + params['dtype'] = [dt for dt in dtype if dt in args.dtype] + algorithm = params['algorithm'] libs = params['lib'] if not isinstance(libs, list): From dad7c772c8e0afbfa6aa3c5a1dd26c12bbb433c3 Mon Sep 17 00:00:00 2001 From: dmitrii-kriukov Date: Tue, 21 Dec 2021 17:03:32 +0000 Subject: [PATCH 2/4] pep8 --- runner.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/runner.py b/runner.py index 34034d648..366f6fb8e 100755 --- a/runner.py +++ b/runner.py @@ -48,7 +48,8 @@ def get_configs(path: Path) -> List[str]: choices=('host', 'cpu', 'gpu', 'None'), help='Availible execution context devices. ' 'This parameter only marks devices as available, ' - 'make sure to add the device to the config file to run it on a specific device') + 'make sure to add the device to the config file ' + 'to run it on a specific device') parser.add_argument('--dummy-run', default=False, action='store_true', help='Run configuration parser and datasets generation ' 'without benchmarks running') @@ -105,9 +106,10 @@ def get_configs(path: Path) -> List[str]: device = [] if 'device' not in params: if 'sklearn' in params['lib']: - logging.info('The device parameter value is not defined in config, None is used') + logging.info('The device parameter value is not defined in config, ' + 'None is used') device = ['None'] - elif not isinstance(params['device'] , list): + elif not isinstance(params['device'], list): device = [params['device']] else: device = params['device'] @@ -116,7 +118,7 @@ def get_configs(path: Path) -> List[str]: dtype = [] if 'dtype' not in params: dtype = ['float64'] - elif not isinstance(params['dtype'] , list): + elif not isinstance(params['dtype'], list): dtype = [params['dtype']] else: dtype = params['dtype'] From ffa78915c499003496f60c13b372d3b8198d6d0d Mon Sep 17 00:00:00 2001 From: dmitrii-kriukov Date: Wed, 22 Dec 2021 10:30:41 +0000 Subject: [PATCH 3/4] Replase None with none --- bench.py | 14 +++++++------- configs/skl_xpu_config.json | 2 +- runner.py | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bench.py b/bench.py index c68e909a5..9c1033271 100644 --- a/bench.py +++ b/bench.py @@ -173,8 +173,8 @@ def parse_args(parser, size=None, loop_types=(), action='store_true', help='Use no intel optimized version. ' 'Now avalible for scikit-learn benchmarks') - parser.add_argument('--device', default='None', type=str, - choices=('host', 'cpu', 'gpu', 'None'), + parser.add_argument('--device', default='none', type=str, + choices=('host', 'cpu', 'gpu', 'none'), help='Execution context device') for data in ['X', 'y']: @@ -198,15 +198,15 @@ def parse_args(parser, size=None, loop_types=(), except ImportError: logging.info('Failed to import sklearnex.patch_sklearn.' 'Use stock version scikit-learn', file=sys.stderr) - params.device = 'None' + params.device = 'none' else: - if params.device != 'None': + if params.device != 'none': logging.info( 'Device context is not supported for stock scikit-learn.' 'Please use --no-intel-optimized=False with' - f'--device={params.device} parameter. Fallback to --device=None.', + f'--device={params.device} parameter. Fallback to --device=none.', file=sys.stderr) - params.device = 'None' + params.device = 'none' # disable finiteness check (default) if not params.check_finiteness: @@ -554,7 +554,7 @@ def print_output(library, algorithm, stages, params, functions, def run_with_context(params, function): - if params.device != 'None': + if params.device != 'none': from daal4py.oneapi import sycl_context with sycl_context(params.device): function() diff --git a/configs/skl_xpu_config.json b/configs/skl_xpu_config.json index 06849287e..1cc591b07 100644 --- a/configs/skl_xpu_config.json +++ b/configs/skl_xpu_config.json @@ -4,7 +4,7 @@ "data-format": "pandas", "data-order": "F", "dtype": "float64", - "device": ["host", "cpu", "gpu", "None"] + "device": ["host", "cpu", "gpu", "none"] }, "cases": [ { diff --git a/runner.py b/runner.py index 366f6fb8e..20ac47da2 100755 --- a/runner.py +++ b/runner.py @@ -44,8 +44,8 @@ def get_configs(path: Path) -> List[str]: default='configs/config_example.json', help='The path to a configuration file or ' 'a directory that contains configuration files') - parser.add_argument('--device', '--devices', default='host cpu gpu None', type=str, nargs='+', - choices=('host', 'cpu', 'gpu', 'None'), + parser.add_argument('--device', '--devices', default='host cpu gpu none', type=str, nargs='+', + choices=('host', 'cpu', 'gpu', 'none'), help='Availible execution context devices. ' 'This parameter only marks devices as available, ' 'make sure to add the device to the config file ' @@ -107,8 +107,8 @@ def get_configs(path: Path) -> List[str]: if 'device' not in params: if 'sklearn' in params['lib']: logging.info('The device parameter value is not defined in config, ' - 'None is used') - device = ['None'] + 'none is used') + device = ['none'] elif not isinstance(params['device'], list): device = [params['device']] else: From f8219eb691e1780cb5edd47dacddbad11248a049 Mon Sep 17 00:00:00 2001 From: dmitrii-kriukov Date: Thu, 23 Dec 2021 17:57:56 +0300 Subject: [PATCH 4/4] update dtypes help --- runner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runner.py b/runner.py index 20ac47da2..980e40b87 100755 --- a/runner.py +++ b/runner.py @@ -55,7 +55,9 @@ def get_configs(path: Path) -> List[str]: 'without benchmarks running') parser.add_argument('--dtype', '--dtypes', type=str, default="float32 float64", nargs='+', choices=("float32", "float64"), - help='Available Data types') + help='Available floating point data types' + 'This parameter only marks dtype as available, ' + 'make sure to add the dtype parameter to the config file ') parser.add_argument('--no-intel-optimized', default=False, action='store_true', help='Use Scikit-learn without Intel optimizations') parser.add_argument('--output-file', default='results.json',