From 88958b14a5eb0a161a2774bbcc9ed10d4d544841 Mon Sep 17 00:00:00 2001 From: Mingyi Jin Date: Thu, 24 Aug 2023 18:27:07 +0800 Subject: [PATCH] feat: update version update docstring --- oclk/__init__.py | 2 +- oclk/benchmark.py | 6 ++++-- oclk/functions.py | 10 +++++----- oclk/oclk_runner.py | 8 ++++---- oclk/oclk_runner.pyi | 25 +++++++++++++++---------- oclk/tuner.py | 4 ++-- oclk/version.py | 2 +- setup.py | 3 +-- 8 files changed, 33 insertions(+), 27 deletions(-) diff --git a/oclk/__init__.py b/oclk/__init__.py index 345952c..8b9b4e0 100644 --- a/oclk/__init__.py +++ b/oclk/__init__.py @@ -1,5 +1,5 @@ import oclk.benchmark import oclk.benchmark_config from oclk.functions import init, load_kernel, run -from oclk.oclk_runner import Runner, TimerArgs +from oclk.oclk_runner import Runner, TimerArgs, RunnerCtx from oclk.utils import input_maker diff --git a/oclk/benchmark.py b/oclk/benchmark.py index 3af667e..79667e2 100644 --- a/oclk/benchmark.py +++ b/oclk/benchmark.py @@ -13,7 +13,7 @@ arg_support_type, dict_to_Suite, ) -from oclk.oclk_runner import CtxRunner, TimerArgs +from oclk.oclk_runner import RunnerCtx, TimerArgs app = typer.Typer() @@ -58,7 +58,7 @@ def parse_args(args: List[KernelArg]): def run_suite(suite: Suite): for k in suite.kernels: - with CtxRunner(suite.kernel_file, k.name, k.definition) as r: + with RunnerCtx(suite.kernel_file, k.name, k.definition) as r: assert r is not None input = parse_args(k.args) timer = TimerArgs( @@ -82,6 +82,8 @@ def run_suite(suite: Suite): def benchmark(config_file: str): with open(config_file, "r") as f_cfg: cfg: List = yaml.safe_load(f_cfg.read()) + for suite_cfg in cfg: suite: Suite = dict_to_Suite(suite_cfg) + print(suite) run_suite(suite) diff --git a/oclk/functions.py b/oclk/functions.py index fdd7556..beaa902 100644 --- a/oclk/functions.py +++ b/oclk/functions.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, Union, Tuple import numpy as np @@ -64,16 +64,16 @@ def run( *, kernel_name: str, input: List[Dict[str, Union[str, int, float, List[Dict], np.array]]], - local_work_size: List[int], - global_work_size: List[int], + local_work_size: Union[List[int],Tuple[int]], + global_work_size: Union[List[int],Tuple[int]], output: Optional[List[str]] = None, wait: bool = True, timer: Dict = None, ) -> _C.RunnerReturn: - if not (isinstance(local_work_size, list) and isinstance(local_work_size[0], int)): + if not (isinstance(local_work_size, (list,tuple)) and isinstance(local_work_size[0], int)): raise TypeError("local_work_size type must be List[int]") if not ( - isinstance(global_work_size, list) and isinstance(global_work_size[0], int) + isinstance(global_work_size, (list,tuple)) and isinstance(global_work_size[0], int) ): raise TypeError("global_work_size type must be List[int]") if len(local_work_size) != len(global_work_size): diff --git a/oclk/oclk_runner.py b/oclk/oclk_runner.py index 38dfd90..382b63b 100644 --- a/oclk/oclk_runner.py +++ b/oclk/oclk_runner.py @@ -1,6 +1,6 @@ from contextlib import contextmanager from functools import wraps -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, Union, Tuple import numpy as np @@ -167,8 +167,8 @@ def run( Union[int, float, np.array, List[Dict[str, Union[int, float, str]]]], ] ], - local_work_size: List[int], - global_work_size: List[int], + local_work_size: Union[List[int],Tuple[int]], + global_work_size: Union[List[int],Tuple[int]], output: Optional[List[str]] = None, wait: Optional[bool] = True, timer: Optional[Union[Dict, TimerArgs]] = TimerArgsDisabled, @@ -238,7 +238,7 @@ def run( @contextmanager -def CtxRunner(filename, kernel_name, compile_option=""): +def RunnerCtx(filename, kernel_name, compile_option=""): r: Runner = Runner() r.load_kernel(filename, kernel_name, compile_option) try: diff --git a/oclk/oclk_runner.pyi b/oclk/oclk_runner.pyi index 9a1f0a9..8ad704d 100644 --- a/oclk/oclk_runner.pyi +++ b/oclk/oclk_runner.pyi @@ -36,15 +36,20 @@ class Runner: ): ... def release_kernel(self, kernel_name: Union[str, List[str]]) -> int: ... def run( - self, - *, - kernel_name: str, - input: List[Dict[str, Union[int, float, np.array]]], - output: List[str], - local_work_size: List[int], - global_work_size: List[int], - wait: bool = True, - timer: Union[Dict, TimerArgs] = TimerArgsDisabled, + self, + *, + kernel_name: str, + input: List[ + Dict[ + str, + Union[int, float, np.array, List[Dict[str, Union[int, float, str]]]], + ] + ], + local_work_size: Union[List[int],Tuple[int]], + global_work_size: Union[List[int],Tuple[int]], + output: Optional[List[str]] = None, + wait: Optional[bool] = True, + timer: Optional[Union[Dict, TimerArgs]] = TimerArgsDisabled, ) -> RunnerReturn: ... -def CtxRunner(filename, kernel_name, compile_option=""): ... +def RunnerCtx(filename, kernel_name, compile_option=""): ... diff --git a/oclk/tuner.py b/oclk/tuner.py index 093a4e6..5b9753a 100644 --- a/oclk/tuner.py +++ b/oclk/tuner.py @@ -9,7 +9,7 @@ from tqdm import tqdm import oclk.functions as F -from oclk.oclk_runner import CtxRunner, Runner, RunnerReturn, TimerArgs +from oclk.oclk_runner import RunnerCtx, Runner, RunnerReturn, TimerArgs class TuneArgGenerator: @@ -80,7 +80,7 @@ def run( """ if timer is None: timer = self.timer - with CtxRunner(kernel_file, kernel_name, compile_option) as r: + with RunnerCtx(kernel_file, kernel_name, compile_option) as r: F.clear_timer() return r.run( kernel_name=kernel_name, diff --git a/oclk/version.py b/oclk/version.py index a955fda..bc86c94 100644 --- a/oclk/version.py +++ b/oclk/version.py @@ -1 +1 @@ -__version__ = "1.2.1" +__version__ = "1.2.2" diff --git a/setup.py b/setup.py index bfd2a1d..7dff6e8 100644 --- a/setup.py +++ b/setup.py @@ -144,6 +144,5 @@ def build_extension(self, ext: CMakeExtension) -> None: "Topic :: Utilities", "Typing :: Typed", "Intended Audience :: Developers", - ], - platforms=["manylinux1_x86_64"], + ] )