34
34
try :
35
35
from hip ._util .types import DeviceArray
36
36
except ImportError :
37
- Pointer = Exception # using Exception here as a type that will never be among kernel arguments
37
+ Pointer = Exception # using Exception here as a type that will never be among kernel arguments
38
38
DeviceArray = Exception
39
39
40
40
@@ -160,22 +160,21 @@ def ready_argument_list(self, arguments):
160
160
161
161
for i , arg in enumerate (arguments ):
162
162
if not (isinstance (arg , (np .ndarray , np .number , DeviceArray )) or is_cupy_array (arg )):
163
- raise TypeError (f"Argument is not numpy or cupy ndarray or numpy scalar or HIP Python DeviceArray but a { type (arg )} " )
163
+ raise TypeError (
164
+ f"Argument is not numpy or cupy ndarray or numpy scalar or HIP Python DeviceArray but a { type (arg )} "
165
+ )
164
166
dtype_str = arg .typestr if isinstance (arg , DeviceArray ) else str (arg .dtype )
165
167
if isinstance (arg , np .ndarray ):
166
168
if dtype_str in dtype_map .keys ():
167
169
data_ctypes = arg .ctypes .data_as (C .POINTER (dtype_map [dtype_str ]))
168
- numpy_arg = arg
169
170
else :
170
171
raise TypeError ("unknown dtype for ndarray" )
171
172
elif isinstance (arg , np .generic ):
172
173
data_ctypes = dtype_map [dtype_str ](arg )
173
- numpy_arg = arg
174
174
elif is_cupy_array (arg ):
175
175
data_ctypes = C .c_void_p (arg .data .ptr )
176
176
elif isinstance (arg , DeviceArray ):
177
177
data_ctypes = arg .as_c_void_p ()
178
- numpy_arg = None
179
178
180
179
ctype_args [i ] = Argument (numpy = arg , ctypes = data_ctypes )
181
180
self .allocations .append (Argument (numpy = arg .copy (), ctypes = data_ctypes ))
@@ -283,7 +282,7 @@ def compile(self, kernel_instance):
283
282
stdout = subprocess .PIPE ,
284
283
stderr = subprocess .PIPE ,
285
284
text = True ,
286
- check = True
285
+ check = True ,
287
286
)
288
287
289
288
subprocess .run (
@@ -294,7 +293,7 @@ def compile(self, kernel_instance):
294
293
stdout = subprocess .PIPE ,
295
294
stderr = subprocess .PIPE ,
296
295
text = True ,
297
- check = True
296
+ check = True ,
298
297
)
299
298
300
299
self .lib = np .ctypeslib .load_library (filename , "." )
0 commit comments