25
25
26
26
27
27
cimport _mkl_service as mkl
28
+ import six
28
29
29
30
30
31
# Version Information
@@ -311,19 +312,14 @@ cpdef vml_clear_err_status():
311
312
cdef inline __mkl_str_to_int(variable, possible_variables_dict):
312
313
assert (variable is not None )
313
314
assert (possible_variables_dict is not None )
315
+ assert (variable in possible_variables_dict.keys()), ' Variable: <' + str (variable) + ' > not in ' + str (possible_variables_dict)
314
316
315
- variable_type = type (variable)
316
-
317
- if variable_type is str :
318
- assert (variable in possible_variables_dict.keys()), ' Variable: <' + str (variable) + ' > not in ' + str (possible_variables_dict)
319
- mkl_variable = possible_variables_dict[variable]
320
-
321
- return mkl_variable
317
+ return possible_variables_dict[variable]
322
318
323
319
324
320
cdef inline __mkl_int_to_str(mkl_int_variable, possible_variables_dict):
325
321
assert (mkl_int_variable is not None )
326
- assert (type (mkl_int_variable) is int )
322
+ assert (isinstance (mkl_int_variable, six.integer_types) )
327
323
assert (possible_variables_dict is not None )
328
324
assert (mkl_int_variable in possible_variables_dict.keys()), ' Variable: <' + str (mkl_int_variable) + ' > not in ' + str (possible_variables_dict)
329
325
@@ -358,11 +354,11 @@ cdef inline __set_num_threads(num_threads):
358
354
Specifies the number of OpenMP* threads to use.
359
355
https://software.intel.com/en-us/mkl-developer-reference-c-mkl-set-num-threads
360
356
"""
361
- assert (type (num_threads) is int )
357
+ assert (isinstance (num_threads, six.integer_types) )
362
358
assert (num_threads > 0 )
363
359
364
360
prev_num_threads = __get_max_threads()
365
- assert (type (prev_num_threads) is int )
361
+ assert (isinstance (prev_num_threads, six.integer_types) )
366
362
assert (prev_num_threads > 0 )
367
363
368
364
mkl.mkl_set_num_threads(num_threads)
@@ -388,7 +384,7 @@ cdef inline __domain_set_num_threads(num_threads, domain):
388
384
1 : ' success' ,
389
385
},
390
386
}
391
- assert (type (num_threads) is int )
387
+ assert (isinstance (num_threads, six.integer_types) )
392
388
assert (num_threads >= 0 )
393
389
mkl_domain = __mkl_str_to_int(domain, __variables[' input' ])
394
390
@@ -403,7 +399,7 @@ cdef inline __set_num_threads_local(num_threads):
403
399
Specifies the number of OpenMP* threads for all Intel MKL functions on the current execution thread.
404
400
https://software.intel.com/en-us/mkl-developer-reference-c-mkl-set-num-threads-local
405
401
"""
406
- assert (type (num_threads) is int )
402
+ assert (isinstance (num_threads, six.integer_types) )
407
403
assert (num_threads >= 0 )
408
404
409
405
status = mkl.mkl_set_num_threads_local(num_threads)
@@ -437,7 +433,7 @@ cdef inline __get_max_threads():
437
433
"""
438
434
num_threads = mkl.mkl_get_max_threads()
439
435
440
- assert (type (num_threads) is int )
436
+ assert (isinstance (num_threads, six.integer_types) )
441
437
assert (num_threads >= 1 )
442
438
return num_threads
443
439
@@ -461,7 +457,7 @@ cdef inline __domain_get_max_threads(domain='all'):
461
457
462
458
num_threads = mkl.mkl_domain_get_max_threads(mkl_domain)
463
459
464
- assert (type (num_threads) is int )
460
+ assert (isinstance (num_threads, six.integer_types) )
465
461
assert (num_threads >= 1 )
466
462
return num_threads
467
463
@@ -586,7 +582,7 @@ cdef inline __peak_mem_usage(mem_const):
586
582
587
583
memory_allocator = mkl.mkl_peak_mem_usage(mkl_mem_const)
588
584
589
- assert (type (memory_allocator) is int )
585
+ assert (isinstance (memory_allocator, six.integer_types) )
590
586
assert (memory_allocator >= - 1 )
591
587
if memory_allocator == - 1 :
592
588
memory_allocator = ' error'
0 commit comments