Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tri mask ops return docstring #2517

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 48 additions & 6 deletions crates/burn-tensor/src/tensor/api/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,22 @@ where
///
/// # Returns
///
/// Returns a boolean tensor where `true` indicates the elements of the matrix that are part of the
/// upper triangle taking into account the specified `offset`.
/// Returns a boolean tensor where `false` indicates the elements of the matrix that are part of the
/// upper triangle taking into account the specified `offset`. All other elements are `true`.
///
/// # Example
/// ```rust
/// use burn_tensor::backend::Backend;
/// use burn_tensor::{Tensor, Bool};
///
/// fn example<B: Backend>() {
/// let mask = Tensor::<B, 2, Bool>::triu_mask([3, 3], 0, &Default::default());
/// println!("{mask}");
/// // [[false, false, false],
/// // [true, false, false],
/// // [true, true, false]]
/// }
/// ```
pub fn triu_mask<S: Into<Shape>>(shape: S, offset: i64, device: &B::Device) -> Self {
Self::tri_mask(shape, TriPart::Upper, offset, device)
}
Expand All @@ -159,8 +173,22 @@ where
///
/// # Returns
///
/// Returns a boolean tensor where `true` indicates the elements of the matrix that are part of the
/// lower triangle taking into account the specified `offset`.
/// Returns a boolean tensor where `false` indicates the elements of the matrix that are part of the
/// lower triangle taking into account the specified `offset`. All other elements are `true`.
///
/// # Example
/// ```rust
/// use burn_tensor::backend::Backend;
/// use burn_tensor::{Tensor, Bool};
///
/// fn example<B: Backend>() {
/// let mask = Tensor::<B, 2, Bool>::tril_mask([3, 3], 0, &Default::default());
/// println!("{mask}");
/// // [[false, true, true],
/// // [false, false, true],
/// // [false, false, false]]
/// }
/// ```
pub fn tril_mask<S: Into<Shape>>(shape: S, offset: i64, device: &B::Device) -> Self {
Self::tri_mask(shape, TriPart::Lower, offset, device)
}
Expand All @@ -177,8 +205,22 @@ where
///
/// # Returns
///
/// Returns a boolean tensor where `true` indicates the elements of the matrix that are part of the
/// diagonal.
/// Returns a boolean tensor where `false` indicates the elements of the matrix that are part of the
/// diagonal. All other elements are `true`.
///
/// # Example
/// ```rust
/// use burn_tensor::backend::Backend;
/// use burn_tensor::{Tensor, Bool};
///
/// fn example<B: Backend>() {
/// let mask = Tensor::<B, 2, Bool>::diag_mask([3, 3], 0, &Default::default());
/// println!("{mask}");
/// // [[false, true, true],
/// // [true, false, true],
/// // [true, true, false]]
/// }
/// ```
pub fn diag_mask<S: Into<Shape>>(shape: S, offset: i64, device: &B::Device) -> Self {
Self::tri_mask(shape, TriPart::Diagonal, offset, device)
}
Expand Down