Closed songtaoshi closed 4 years ago
Kaldi matrix file(=.mat file in Kaldi) is always c-contiguous. How do you use kaldiio?
Hi, The numpy array loaded by the kaldiio.load_mat is Fortran contiguous arrays rather than C contiguous array. While lots of library used in deep learning are compiled from C++/C.
Are there any solutions? I have read the source seems to be in kaldiio.utils open_like_kaldi function. But I am not that familiar with the area.
Thanks for your reply!
Oh, I forgot that there are 4 types of Matrix format in Kaldi, not compressed matrix, CM, CM2, and CM3. CM2 and CM3 have f-contiguous format.
>>> kaldiio.save_mat("a.mat", np.ones((3,3)), compression_method=2)
>>> kaldiio.load_mat("a.mat").flags
C_CONTIGUOUS : False
F_CONTIGUOUS : True
OWNDATA : False
WRITEABLE : True
ALIGNED : True
WRITEBACKIFCOPY : False
UPDATEIFCOPY : False
F-fortran binary format can't be loaded as c-contiguous. You can reorder it by normal numpy way. Of course, it takes reordering costs.
np.asarray(array, order='C')
Thanks for your reply, so it depends the format of the loaded mat, or, We have to reorder it.
Hi, I am encountering a problem about the numpy array loaded by the kaldiio.load_mat function.
The loaded numpy array is not contiguous. Are there any option parameters to load to be contiguous array.