Skip to content

Commit

Permalink
Fixing docstrings in tensor_ops
Browse files Browse the repository at this point in the history
  • Loading branch information
coreylowman committed Oct 3, 2022
1 parent f7bf255 commit c94f425
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tensor_ops/impl_div.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::prelude::*;
/// let b = tensor([[1.0, 0.5, 1.0], [0.5, 1.0, 3.0]]);
/// let r = div(a, &b); // or `a / &b`
/// assert_eq!(r.data(), &[[1.0, 4.0, 3.0], [-2.0, -2.0, -1.0]]);
/// ```
pub fn div<T: Tensor<Dtype = f32>>(lhs: T, rhs: &T::NoTape) -> T {
fn dfdy(x: &f32, y: &f32) -> f32 {
(-x) * y.powi(2).recip()
Expand Down
1 change: 1 addition & 0 deletions src/tensor_ops/impl_mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::prelude::*;
/// let b = Tensor2D::ones();
/// let r = mul(a, &b); // or `a * &b`
/// assert_eq!(r.data(), &[[1.0, 2.0, 3.0], [-1.0, -2.0, -3.0]]);
/// ```
pub fn mul<T: Tensor<Dtype = f32>>(lhs: T, rhs: &T::NoTape) -> T {
binary_map(lhs, rhs, |x, y| x * y, |_, y| *y, |x, _| *x)
}
Expand Down
1 change: 1 addition & 0 deletions src/tensor_ops/impl_sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::prelude::*;
/// let b = Tensor2D::ones();
/// let r = sub(a, &b); // or `a - &b`
/// assert_eq!(r.data(), &[[0.0, 1.0, 2.0], [-2.0, -3.0, -4.0]]);
/// ```
pub fn sub<T: Tensor<Dtype = f32>>(lhs: T, rhs: &T::NoTape) -> T {
binary_map(lhs, rhs, |x, y| x - y, |_, _| 1.0, |_, _| -1.0)
}
Expand Down

0 comments on commit c94f425

Please sign in to comment.