Add two methods.

This commit is contained in:
laurent
2023-07-01 20:55:15 +01:00
parent 52db2a6849
commit 42d1a52d01
2 changed files with 15 additions and 0 deletions

View File

@ -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]