Skip to content

Commit

Permalink
Fixing docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
coreylowman committed Sep 26, 2022
1 parent 4069d59 commit c3009a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/tensor_ops/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::arrays::{Axes2, Axes3, Axes4, Axis};
use crate::devices::broadcast_reduce::{AddAccum, CopyAccum, DeviceReduce};
use crate::prelude::*;

/// Broadcasts the `I`th dimension. Increases number dimensions by 1. Results in `T`. Opposite of [Reduce1].
/// Broadcasts the `I`th dimension. Increases number dimensions by 1. Results in `T`. Opposite of [Reduce].
pub trait Broadcast<T, Axes> {
/// Broadcast `self` into `T`, increasing number dimensions by 1.
///
Expand Down
14 changes: 4 additions & 10 deletions src/tensor_ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,25 @@
//! For example calling `sum_axis::<-1>()` on a `Tensor2D<2, 5>` would result in a `Tensor1D<2>`.
//! Calling [sum_axis::<0>()] on a `Tensor2D<5>` would result in a `Tensor1D<5>`.
//!
//! See [Reduce1] implementations for a complete list of reductions.
//! See [Reduce] implementations for a complete list of reductions.
//!
//! See relevant functions for more examples.
//!
//! # Broadcasts
//!
//! Broadcasting tensors is provided through the following traits:
//! 1. [Broadcast1::broadcast1()], which broadcasts a single axis
//! 2. [Broadcast2::broadcast2()], which broadcasts 2 axes
//! 3. [Broadcast3::broadcast3()], which broadcasts 3 axes
//! 4. [Broadcast4::broadcast4()], which broadcasts 4 axes
//!
//! See the implementations of each trait for a complete list of possible broadcasts.
//! Broadcasting tensors is provided through the [Broadcast] trait.
//!
//! To broadcast a tensor to be the same size as another tensor you can use like so:
//! ```rust
//! # use dfdx::prelude::*;
//! let big: Tensor2D<2, 5> = TensorCreator::zeros();
//!
//! // broadcast the 1nd axis
//! let a: Tensor2D<2, 5> = Tensor1D::<5>::zeros().broadcast1();
//! let a: Tensor2D<2, 5> = Tensor1D::<5>::zeros().broadcast();
//! add(a, &big);
//!
//!// broadcast the 2nd axis
//! let a: Tensor2D<2, 5> = Tensor1D::<2>::zeros().broadcast1();
//! let a: Tensor2D<2, 5> = Tensor1D::<2>::zeros().broadcast();
//! add(a, &big);
//! ```
//!
Expand Down

0 comments on commit c3009a3

Please sign in to comment.