Skip to content

Commit

Permalink
Make ndarray tensor public (tracel-ai#920)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielsimard authored Nov 1, 2023
1 parent 8742d31 commit 64e58b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion burn-ndarray/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod tensor;
pub use backend::*;
pub use element::FloatNdArrayElement;
pub(crate) use sharing::*;
pub(crate) use tensor::*;
pub use tensor::*;

extern crate alloc;

Expand Down
3 changes: 3 additions & 0 deletions burn-ndarray/src/tensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use burn_tensor::{Data, Shape};

use ndarray::{ArcArray, Array, Dim, IxDyn};

/// Tensor primitive used by the [ndarray backend](crate::NdArray).
#[derive(new, Debug, Clone)]
pub struct NdArrayTensor<E, const D: usize> {
/// Dynamic array that contains the data of type E.
pub array: ArcArray<E, IxDyn>,
}

Expand Down Expand Up @@ -101,6 +103,7 @@ impl<E, const D: usize> NdArrayTensor<E, D>
where
E: Default + Clone,
{
/// Create a new [ndarray tensor](NdArrayTensor) from [data](Data).
pub fn from_data(data: Data<E, D>) -> NdArrayTensor<E, D> {
let shape = data.shape.clone();
let to_array = |data: Data<E, D>| Array::from_iter(data.value).into_shared();
Expand Down

0 comments on commit 64e58b4

Please sign in to comment.