pythonanacondaaccelerate

KeyError: dtype('int32') for Anaconda Accelerate library


I'm trying to learn how to use anaconda's accelerate library. As per https://docs.anaconda.com/accelerate/cublas.html, the amin() method "finds the index of the first largest element in array x. Same as np.argmax(x)".

Here is my code:

import accelerate.cuda.blas as blas
import numpy as np

self = blas.Blas()
a = np.array([1, 2, 3, 4])
print(self.amin(a))

and here is what it returns

Traceback (most recent call last):
File "/opt/anaconda1anaconda2anaconda3\api.py", line 147, in _dispatch
KeyError: dtype('int32')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Boo\Desktop\clarify.py", 
line 11, in <module>
print(self.amin(a))
File "/opt/anaconda1anaconda2anaconda3\api.py", line 238, in amin
File "/opt/anaconda1anaconda2anaconda3\api.py", line 149, in _dispatch
TypeError: int32

Solution

  • The np.array needs to be a float32 array instead of a default int32

    import accelerate.cuda.blas as blas
    import numpy as np
    
    self = blas.Blas()
    a = np.array([1, 2, 3, 4], dtype='float32')
    print(self.amin(a))