ARM-software / ComputeLibrary

The Compute Library is a set of computer vision and machine learning functions optimised for both Arm CPUs and GPUs using SIMD technologies.
MIT License
2.75k stars 767 forks source link

example neno_sgemm loading *.npy Error which generated by python code #1064

Closed NNUCJ closed 10 months ago

NNUCJ commented 11 months ago

Hey:   I want to execute example neon_sgemm.cc with the following command "./build/neon_sgemm input_matrix_1.npy input_matrix_2.npy [input_matrix_3.npy] [alpha = 1] [beta = 0]"。 The npy file has been generated using python-numpy(code show as below)

import numpy as np

a = np.random.random((5, 7))
b = np.random.random((3, 5))
a = np.dtype("float32")
b = np.dtype("float32")
c = np.random.random((3,7))
np.save("./a.npy", a)
np.save("./b.npy", b)
np.save("./c.npy", c)

   I've met the following error message

./build/examples/neon_sgemm

!!!!!!!!!!!!!!!!!!!!!!!!!!!

ERROR invalid typestring (length) Invalid argument
!!!!!!!!!!!!!!!!!!!!!!!!!!!

Test FAILED
morgolock commented 11 months ago

Hi @NNUCJ

Are you using the latest release v23.05?

NNUCJ commented 11 months ago

Hi @NNUCJ

Are you using the latest release v23.05? @morgolock v23.05.1

NNUCJ commented 11 months ago

Hi @NNUCJ Are you using the latest release v23.05? @morgolock v23.05.1

  During the debug process, it is found that the descr value parsed from the loaded npy file is "|O". But the length of descr can not less than 3 in include/libnpy/npy.hpp line 166

sleepy-hat commented 11 months ago

Hi @NNUCJ

It appears the bug is in your code example. You are overwriting the numpy arrays a and b with the numpy data type object in the following lines, hence the library cannot parse your arrays as it doesn't understand the object being passed in.

Please try again by setting the data type when creating the array, such as:

a = np.random.random((5, 7)).astype(np.float32)

Thank you

NNUCJ commented 10 months ago

Hi @sleepy-hat   According to your suggestion, the npy file can be loaded normally。I encountered a new problem when I tested neon_sgemm using the following command,./neon_sgemm a.npy b.npy,The error log is as follows:


./build/examples/neon_sgemm

terminate called after throwing an instance of 'std::out_of_range' what(): _Map_base::at qemu: uncaught target signal 6 (Aborted) - core dumped Aborted (core dumped)


  The error occurs in the `save_to_npy` (utils/Utils.h)function, `const npy::dtype_t   dtype = npy::dtype_map.at(-std::type_index(typeid(tmp)));`. Now I don't know if it's something wrong with my generated numpy data or something else
Thank you