mirror of
https://github.com/huggingface/candle.git
synced 2025-06-20 12:06:35 +00:00
Expose candle gather op in pyo3. (#1870)
This commit is contained in:
@ -324,6 +324,12 @@ class Tensor:
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def gather(self, index, dim):
|
||||||
|
"""
|
||||||
|
Gathers values along an axis specified by dim.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def get(self, index: int) -> Tensor:
|
def get(self, index: int) -> Tensor:
|
||||||
"""
|
"""
|
||||||
Gets the value at the specified index.
|
Gets the value at the specified index.
|
||||||
|
@ -448,6 +448,12 @@ impl PyTensor {
|
|||||||
Ok(PyTensor(self.0.index_select(rhs, dim).map_err(wrap_err)?))
|
Ok(PyTensor(self.0.index_select(rhs, dim).map_err(wrap_err)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Gathers values along an axis specified by dim.
|
||||||
|
fn gather(&self, index: &Self, dim: i64) -> PyResult<Self> {
|
||||||
|
let dim = actual_dim(self, dim).map_err(wrap_err)?;
|
||||||
|
Ok(PyTensor(self.0.gather(index, dim).map_err(wrap_err)?))
|
||||||
|
}
|
||||||
|
|
||||||
#[pyo3(text_signature = "(self, rhs:Tensor)")]
|
#[pyo3(text_signature = "(self, rhs:Tensor)")]
|
||||||
/// Performs a matrix multiplication between the two tensors.
|
/// Performs a matrix multiplication between the two tensors.
|
||||||
/// &RETURNS&: Tensor
|
/// &RETURNS&: Tensor
|
||||||
|
Reference in New Issue
Block a user