Skip to content

Commit

Permalink
feat: update version update docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
jinmingyi1998 committed Aug 24, 2023
1 parent 96d3a5b commit 88958b1
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion oclk/__init__.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions oclk/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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(
Expand All @@ -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)
10 changes: 5 additions & 5 deletions oclk/functions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, List, Optional, Union
from typing import Dict, List, Optional, Union, Tuple

import numpy as np

Expand Down Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions oclk/oclk_runner.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
25 changes: 15 additions & 10 deletions oclk/oclk_runner.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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=""): ...
4 changes: 2 additions & 2 deletions oclk/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion oclk/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.1"
__version__ = "1.2.2"
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,5 @@ def build_extension(self, ext: CMakeExtension) -> None:
"Topic :: Utilities",
"Typing :: Typed",
"Intended Audience :: Developers",
],
platforms=["manylinux1_x86_64"],
]
)

0 comments on commit 88958b1

Please sign in to comment.