|
37 | 37 |
|
38 | 38 | import pyopencl as cl |
39 | 39 | from pyopencl.tools import ( |
| 40 | + Argument, |
40 | 41 | DtypedArgument, |
41 | 42 | KernelTemplateBase, |
42 | 43 | ScalarArg, |
|
55 | 56 |
|
56 | 57 | def get_elwise_program( |
57 | 58 | context: cl.Context, |
58 | | - arguments: list[DtypedArgument], |
| 59 | + arguments: Sequence[Argument], |
59 | 60 | operation: str, *, |
60 | 61 | name: str = "elwise_kernel", |
61 | 62 | options: Any = None, |
@@ -123,27 +124,27 @@ def get_elwise_program( |
123 | 124 |
|
124 | 125 | def get_elwise_kernel_and_types( |
125 | 126 | context: cl.Context, |
126 | | - arguments: str | Sequence[DtypedArgument], |
| 127 | + arguments: str | Sequence[Argument], |
127 | 128 | operation: str, *, |
128 | 129 | name: str = "elwise_kernel", |
129 | 130 | options: Any = None, |
130 | 131 | preamble: str = "", |
131 | 132 | use_range: bool = False, |
132 | | - **kwargs: Any) -> tuple[cl.Kernel, list[DtypedArgument]]: |
| 133 | + **kwargs: Any) -> tuple[cl.Kernel, Sequence[Argument]]: |
133 | 134 |
|
134 | 135 | from pyopencl.tools import get_arg_offset_adjuster_code, parse_arg_list |
135 | 136 | parsed_args = parse_arg_list(arguments, with_offset=True) |
136 | 137 |
|
137 | 138 | auto_preamble = kwargs.pop("auto_preamble", True) |
138 | 139 |
|
139 | | - pragmas = [] |
140 | | - includes = [] |
| 140 | + pragmas: list[str] = [] |
| 141 | + includes: list[str] = [] |
141 | 142 | have_double_pragma = False |
142 | 143 | have_complex_include = False |
143 | 144 |
|
144 | 145 | if auto_preamble: |
145 | 146 | for arg in parsed_args: |
146 | | - if arg.dtype in [np.float64, np.complex128]: |
| 147 | + if arg.dtype.type in [np.float64, np.complex128]: |
147 | 148 | if not have_double_pragma: |
148 | 149 | pragmas.append(""" |
149 | 150 | #if __OPENCL_C_VERSION__ < 120 |
@@ -186,14 +187,14 @@ def get_elwise_kernel_and_types( |
186 | 187 |
|
187 | 188 | def get_elwise_kernel( |
188 | 189 | context: cl.Context, |
189 | | - arguments: str | list[DtypedArgument], |
| 190 | + arguments: str | Sequence[Argument], |
190 | 191 | operation: str, *, |
191 | 192 | name: str = "elwise_kernel", |
192 | 193 | options: Any = None, **kwargs: Any) -> cl.Kernel: |
193 | 194 | """Return a L{pyopencl.Kernel} that performs the same scalar operation |
194 | 195 | on one or several vectors. |
195 | 196 | """ |
196 | | - func, arguments = get_elwise_kernel_and_types( |
| 197 | + func, _arguments = get_elwise_kernel_and_types( |
197 | 198 | context, arguments, operation, |
198 | 199 | name=name, options=options, **kwargs) |
199 | 200 |
|
@@ -233,7 +234,7 @@ class ElementwiseKernel: |
233 | 234 | def __init__( |
234 | 235 | self, |
235 | 236 | context: cl.Context, |
236 | | - arguments: str | Sequence[DtypedArgument], |
| 237 | + arguments: str | Sequence[Argument], |
237 | 238 | operation: str, |
238 | 239 | name: str = "elwise_kernel", |
239 | 240 | options: Any = None, **kwargs: Any) -> None: |
|
0 commit comments