Skip to content

Commit

Permalink
feat: accept creating TensorRef from Arc<[T]>
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Dec 26, 2024
1 parent 7a95f98 commit 7f626ae
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/value/impl_tensor/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,14 @@ impl<T: Clone + 'static, D: ToDimensions> OwnedTensorArrayData<T> for (D, Box<[T
}
}

impl<T: Clone + 'static, D: ToDimensions> TensorArrayData<T> for (D, Arc<[T]>) {
fn ref_parts(&self) -> Result<(Vec<i64>, &[T], Option<Box<dyn Any>>)> {
let shape = self.0.to_dimensions(Some(self.1.len()))?;
let data = &*self.1;
Ok((shape, data, Some(Box::new(self.1.clone()))))
}
}

impl<T: Clone + 'static, D: ToDimensions> TensorArrayData<T> for (D, Arc<Box<[T]>>) {
fn ref_parts(&self) -> Result<(Vec<i64>, &[T], Option<Box<dyn Any>>)> {
let shape = self.0.to_dimensions(Some(self.1.len()))?;
Expand Down

0 comments on commit 7f626ae

Please sign in to comment.