Skip to content

Commit fb75c22

Browse files
Fixed assert issue with int and long types on win py27
1 parent e74369e commit fb75c22

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

mkl-service/_mkl_service.pyx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626

2727
cimport _mkl_service as mkl
28+
import six
2829

2930

3031
# Version Information
@@ -318,7 +319,7 @@ cdef inline __mkl_str_to_int(variable, possible_variables_dict):
318319

319320
cdef inline __mkl_int_to_str(mkl_int_variable, possible_variables_dict):
320321
assert(mkl_int_variable is not None)
321-
assert(type(mkl_int_variable) is int)
322+
assert(isinstance(mkl_int_variable, six.integer_types))
322323
assert(possible_variables_dict is not None)
323324
assert(mkl_int_variable in possible_variables_dict.keys()), 'Variable: <' + str(mkl_int_variable) + '> not in ' + str(possible_variables_dict)
324325

@@ -353,11 +354,11 @@ cdef inline __set_num_threads(num_threads):
353354
Specifies the number of OpenMP* threads to use.
354355
https://software.intel.com/en-us/mkl-developer-reference-c-mkl-set-num-threads
355356
"""
356-
assert(type(num_threads) is int)
357+
assert(isinstance(num_threads, six.integer_types))
357358
assert(num_threads > 0)
358359

359360
prev_num_threads = __get_max_threads()
360-
assert(type(prev_num_threads) is int)
361+
assert(isinstance(prev_num_threads, six.integer_types))
361362
assert(prev_num_threads > 0)
362363

363364
mkl.mkl_set_num_threads(num_threads)
@@ -383,7 +384,7 @@ cdef inline __domain_set_num_threads(num_threads, domain):
383384
1: 'success',
384385
},
385386
}
386-
assert(type(num_threads) is int)
387+
assert(isinstance(num_threads, six.integer_types))
387388
assert(num_threads >= 0)
388389
mkl_domain = __mkl_str_to_int(domain, __variables['input'])
389390

@@ -398,7 +399,7 @@ cdef inline __set_num_threads_local(num_threads):
398399
Specifies the number of OpenMP* threads for all Intel MKL functions on the current execution thread.
399400
https://software.intel.com/en-us/mkl-developer-reference-c-mkl-set-num-threads-local
400401
"""
401-
assert(type(num_threads) is int)
402+
assert(isinstance(num_threads, six.integer_types))
402403
assert(num_threads >= 0)
403404

404405
status = mkl.mkl_set_num_threads_local(num_threads)
@@ -432,7 +433,7 @@ cdef inline __get_max_threads():
432433
"""
433434
num_threads = mkl.mkl_get_max_threads()
434435

435-
assert(type(num_threads) is int)
436+
assert(isinstance(num_threads, six.integer_types))
436437
assert(num_threads >= 1)
437438
return num_threads
438439

@@ -456,7 +457,7 @@ cdef inline __domain_get_max_threads(domain='all'):
456457

457458
num_threads = mkl.mkl_domain_get_max_threads(mkl_domain)
458459

459-
assert(type(num_threads) is int)
460+
assert(isinstance(num_threads, six.integer_types))
460461
assert(num_threads >= 1)
461462
return num_threads
462463

@@ -581,7 +582,7 @@ cdef inline __peak_mem_usage(mem_const):
581582

582583
memory_allocator = mkl.mkl_peak_mem_usage(mkl_mem_const)
583584

584-
assert(type(memory_allocator) is int)
585+
assert(isinstance(memory_allocator, six.integer_types))
585586
assert(memory_allocator >= -1)
586587
if memory_allocator == -1:
587588
memory_allocator = 'error'

0 commit comments

Comments
 (0)