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
9ed0b0b
commit 2c4288d
Showing
16 changed files
with
131 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use super::Tensor; | ||
use crate::tensor::backend::Backend; | ||
use crate::tensor::ops::*; | ||
use crate::tensor::{Data, Shape}; | ||
|
||
pub struct BoolTensor<B: Backend, const D: usize> { | ||
pub(crate) value: B::BoolTensorPrimitive<D>, | ||
} | ||
|
||
impl<B, const D: usize> BoolTensor<B, D> | ||
where | ||
B: Backend, | ||
{ | ||
pub fn new(tensor: B::BoolTensorPrimitive<D>) -> Self { | ||
Self { value: tensor } | ||
} | ||
|
||
pub fn shape(&self) -> &Shape<D> { | ||
self.value.shape() | ||
} | ||
|
||
pub fn into_data(self) -> Data<bool, D> { | ||
self.value.into_data() | ||
} | ||
|
||
pub fn to_data(&self) -> Data<bool, D> { | ||
self.value.to_data() | ||
} | ||
|
||
pub fn from_data(data: Data<bool, D>) -> Self { | ||
let value = B::from_data_bool(data, B::Device::default()); | ||
Self::new(value) | ||
} | ||
|
||
pub fn to_int(&self) -> Tensor<B::IntegerBackend, D> { | ||
Tensor::from_data(self.value.to_data().convert()) | ||
} | ||
} |
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
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,13 @@ | ||
use super::super::TestBackend; | ||
use burn_tensor::{Data, Tensor}; | ||
|
||
#[test] | ||
fn test_argmax_2d() { | ||
let data = Data::from([[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]]); | ||
let tensor = Tensor::<TestBackend, 2>::from_data(data); | ||
|
||
let data_actual = tensor.argmax(1); | ||
|
||
let data_expected = Data::from([[2], [2]]); | ||
assert_eq!(data_expected, data_actual.to_data()); | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
mod add; | ||
mod aggregation; | ||
mod arg; | ||
mod div; | ||
mod exp; | ||
mod index; | ||
|
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
Oops, something went wrong.