arrayfire / arrayfire-python

Python bindings for ArrayFire: A general purpose GPU library.

Home Page:https://arrayfire.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't use af.create_sparse_from_host()

LMikeH opened this issue · comments

When I am trying do the following:

rows = [1,2,3,4,5]
cols = [1,2,3,4,5]
vals = [1.0,1.0,1.0,1.0,1.0]

spA = af.create_sparse_from_host(vals,rows,cols,5,5,storage=af.STORAGE.COO)

I get the following error:

Traceback (most recent call last):
File "C:/Users/User/UsrApps/FireTest/tinytest.py", line 8, in
spA = af.create_sparse_from_host(vals,rows,cols,5,5,storage=af.STORAGE.COO)
File "C:\Users\User\Dev\Python\Python35\lib\site-packages\arrayfire\sparse.py", line 93, in create_sparse_from_host
return create_sparse(to_array(values), to_array(row_idx), to_array(col_idx), nrows, ncols, storage)
File "C:\Users\User\Dev\Python\Python35\lib\site-packages\arrayfire\sparse.py", line 60, in create_sparse
values.arr, row_idx.arr, col_idx.arr, storage.value))
File "C:\Users\User\Dev\Python\Python35\lib\site-packages\arrayfire\util.py", line 79, in safe_call
raise RuntimeError(to_str(err_str))
RuntimeError: In function af_err __cdecl af_create_sparse_array(void **,const __int64,const __int64,void *const ,void *const ,void *const ,const af_storage)
In file src\api\c\sparse.cpp:85
Invalid argument at index 4
Expected: rInfo.getType() == s32

As I replied on the google groups, either use array.array or numpy.array of the right type instead of plain lists.