mirror of
https://github.com/huggingface/candle.git
synced 2025-06-19 11:56:45 +00:00
Add two methods.
This commit is contained in:
@ -25,9 +25,23 @@ impl PyTensor {
|
||||
Ok(Self(Tensor::new(f, &Cpu).map_err(wrap_err)?))
|
||||
}
|
||||
|
||||
#[getter]
|
||||
fn shape(&self) -> Vec<usize> {
|
||||
self.0.dims().to_vec()
|
||||
}
|
||||
|
||||
#[getter]
|
||||
fn rank(&self) -> usize {
|
||||
self.0.rank()
|
||||
}
|
||||
|
||||
fn __repr__(&self) -> String {
|
||||
format!("{}", self.0)
|
||||
}
|
||||
|
||||
fn __str__(&self) -> String {
|
||||
self.__repr__()
|
||||
}
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
|
Reference in New Issue
Block a user