forked from tracel-ai/burn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72e4433
commit 0e1b0ac
Showing
23 changed files
with
232 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ mod activation; | |
mod backend; | ||
mod ops; | ||
mod tensor; | ||
mod tensor_ops; | ||
|
||
pub use backend::*; | ||
pub use ops::*; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use super::ADBackendDecorator; | ||
use crate::{backend::Backend, ops::TensorOps, Data, Shape}; | ||
|
||
impl<B: Backend> TensorOps<ADBackendDecorator<B>> for ADBackendDecorator<B> { | ||
fn shape<const D: usize>( | ||
tensor: &<ADBackendDecorator<B> as Backend>::TensorPrimitive<D>, | ||
) -> &Shape<D> { | ||
B::shape(tensor.tensor_ref()) | ||
} | ||
|
||
fn to_data<const D: usize>( | ||
tensor: &<ADBackendDecorator<B> as Backend>::TensorPrimitive<D>, | ||
) -> Data<<ADBackendDecorator<B> as Backend>::Elem, D> { | ||
B::to_data(tensor.tensor_ref()) | ||
} | ||
|
||
fn into_data<const D: usize>( | ||
tensor: <ADBackendDecorator<B> as Backend>::TensorPrimitive<D>, | ||
) -> Data<<ADBackendDecorator<B> as Backend>::Elem, D> { | ||
B::into_data(tensor.tensor()) | ||
} | ||
|
||
fn bool_shape<const D: usize>( | ||
tensor: &<ADBackendDecorator<B> as Backend>::BoolTensorPrimitive<D>, | ||
) -> &Shape<D> { | ||
B::bool_shape(tensor) | ||
} | ||
|
||
fn bool_to_data<const D: usize>( | ||
tensor: &<ADBackendDecorator<B> as Backend>::BoolTensorPrimitive<D>, | ||
) -> Data<bool, D> { | ||
B::bool_to_data(tensor) | ||
} | ||
|
||
fn bool_into_data<const D: usize>( | ||
tensor: <ADBackendDecorator<B> as Backend>::BoolTensorPrimitive<D>, | ||
) -> Data<bool, D> { | ||
B::bool_into_data(tensor) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ mod backend; | |
mod ops; | ||
mod shape; | ||
mod tensor; | ||
mod tensor_ops; | ||
|
||
pub use backend::*; | ||
pub use shape::*; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use super::NdArrayBackend; | ||
use crate::{backend::Backend, ops::TensorOps, Data, NdArrayElement, Shape}; | ||
|
||
impl<E: NdArrayElement> TensorOps<NdArrayBackend<E>> for NdArrayBackend<E> { | ||
fn shape<const D: usize>( | ||
tensor: &<NdArrayBackend<E> as Backend>::TensorPrimitive<D>, | ||
) -> &Shape<D> { | ||
&tensor.shape | ||
} | ||
|
||
fn to_data<const D: usize>( | ||
tensor: &<NdArrayBackend<E> as Backend>::TensorPrimitive<D>, | ||
) -> Data<<NdArrayBackend<E> as Backend>::Elem, D> { | ||
let values = tensor.array.iter().map(Clone::clone).collect(); | ||
Data::new(values, tensor.shape) | ||
} | ||
|
||
fn into_data<const D: usize>( | ||
tensor: <NdArrayBackend<E> as Backend>::TensorPrimitive<D>, | ||
) -> Data<<NdArrayBackend<E> as Backend>::Elem, D> { | ||
let values = tensor.array.into_iter().collect(); | ||
Data::new(values, tensor.shape) | ||
} | ||
|
||
fn bool_shape<const D: usize>( | ||
tensor: &<NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D>, | ||
) -> &Shape<D> { | ||
&tensor.shape | ||
} | ||
|
||
fn bool_to_data<const D: usize>( | ||
tensor: &<NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D>, | ||
) -> Data<bool, D> { | ||
let values = tensor.array.iter().map(Clone::clone).collect(); | ||
Data::new(values, tensor.shape) | ||
} | ||
|
||
fn bool_into_data<const D: usize>( | ||
tensor: <NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D>, | ||
) -> Data<bool, D> { | ||
let values = tensor.array.into_iter().collect(); | ||
Data::new(values, tensor.shape) | ||
} | ||
} |
Oops, something went wrong.