mirror of
https://github.com/huggingface/candle.git
synced 2025-06-19 19:58:35 +00:00
Resurrect the llama npy support. (#140)
This commit is contained in:
@ -139,6 +139,9 @@ pub enum Error {
|
||||
rhs_stride: Vec<usize>,
|
||||
mnk: (usize, usize, usize),
|
||||
},
|
||||
|
||||
#[error("cannot find tensor {path}")]
|
||||
CannotFindTensor { path: String },
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
@ -1,10 +1,10 @@
|
||||
//! Numpy support for literals.
|
||||
//! Numpy support for tensors.
|
||||
//!
|
||||
//! The spec for the npy format can be found in
|
||||
//! [npy-format](https://docs.scipy.org/doc/numpy-1.14.2/neps/npy-format.html).
|
||||
//! The functions from this module can be used to read literals from npy/npz files
|
||||
//! or write literals to these files. A npy file contains a single literal (unnamed)
|
||||
//! whereas a npz file can contain multiple named literals. npz files are also compressed.
|
||||
//! The functions from this module can be used to read tensors from npy/npz files
|
||||
//! or write tensors to these files. A npy file contains a single tensor (unnamed)
|
||||
//! whereas a npz file can contain multiple named tensors. npz files are also compressed.
|
||||
//!
|
||||
//! These two formats are easy to use in Python using the numpy library.
|
||||
//!
|
||||
@ -232,7 +232,7 @@ impl Tensor {
|
||||
}
|
||||
}
|
||||
|
||||
/// Reads a npy file and return the stored multi-dimensional array as a literal.
|
||||
/// Reads a npy file and return the stored multi-dimensional array as a tensor.
|
||||
pub fn read_npy<T: AsRef<Path>>(path: T) -> Result<Self> {
|
||||
let mut reader = File::open(path.as_ref())?;
|
||||
let header = read_header(&mut reader)?;
|
||||
|
@ -10,3 +10,10 @@ pub fn get_num_threads() -> usize {
|
||||
Some(_) | None => num_cpus::get(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_mkl() -> bool {
|
||||
#[cfg(feature = "mkl")]
|
||||
return true;
|
||||
#[cfg(not(feature = "mkl"))]
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user