From 94d1796a25d81141d2fedc50f55f2a123a8f941f Mon Sep 17 00:00:00 2001 From: Tianqi Chen Date: Sat, 22 Aug 2020 08:30:48 -0700 Subject: [PATCH] [RUNTIME][FFI] Fix cython FFI compact with np.int64 (#6321) --- python/tvm/_ffi/_cython/packed_func.pxi | 2 +- tests/python/unittest/test_runtime_packed_func.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/python/tvm/_ffi/_cython/packed_func.pxi b/python/tvm/_ffi/_cython/packed_func.pxi index 45bcf64a616d..9f003a6c0167 100644 --- a/python/tvm/_ffi/_cython/packed_func.pxi +++ b/python/tvm/_ffi/_cython/packed_func.pxi @@ -116,7 +116,7 @@ cdef inline int make_arg(object arg, ptr = arg._tvm_handle value[0].v_handle = (ptr) tcode[0] = arg.__class__._tvm_tcode - elif isinstance(arg, (int, long)): + elif isinstance(arg, Integral): value[0].v_int64 = arg tcode[0] = kInt elif isinstance(arg, float): diff --git a/tests/python/unittest/test_runtime_packed_func.py b/tests/python/unittest/test_runtime_packed_func.py index fcaceb3dcaeb..aab84a11a29c 100644 --- a/tests/python/unittest/test_runtime_packed_func.py +++ b/tests/python/unittest/test_runtime_packed_func.py @@ -296,11 +296,14 @@ def check_assign(dtype): for t in ["float64", "float32"]: check_assign(t) +def test_numpy_scalar(): + maxint = (1<<63) - 1 + assert tvm.testing.echo(np.int64(maxint)) == maxint if __name__ == "__main__": + test_numpy_scalar() test_rvalue_ref() - exit(0) test_empty_array() test_get_global() test_get_callback_with_node()