def unpackbits(myarray):
 if (myarray.dtype != cupy.uint8):
  raise TypeError('Expected an input array of unsigned byte data type')
 unpacked = cupy.ndarray((myarray.size * 8), dtype=cupy.uint8)
 cupy.ElementwiseKernel('raw uint8 myarray', 'T unpacked', 'unpacked = (myarray[i / 8] >> (7 - i % 8)) & 1;', 'unpackbits_kernel')(myarray, unpacked)
 return unpacked

def unpackbits ( myarray ) : if ( myarray . dtype != cupy . uint8 ) : raise TypeError ( 'Expected an input array of unsigned byte data type' ) unpacked = cupy . ndarray ( ( myarray . size * 8 ) , dtype = cupy . uint8 ) cupy . ElementwiseKernel ( 'raw uint8 myarray' , 'T unpacked' , 'unpacked = (myarray[i / 8] >> (7 - i % 8)) & 1;' , 'unpackbits_kernel' ) ( myarray , unpacked ) return unpacked
unpacks elements of a uint8 array into a binary-valued output array .