Skip to content

Commit

Permalink
Expose TensorLike and Gradients::get_ref_checked (#845)
Browse files Browse the repository at this point in the history
* Expose TensorLike and Gradients::get_ref_checked

* Fixing clippy warning
  • Loading branch information
coreylowman committed Aug 10, 2023
1 parent 5d7d487 commit bd6b368
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/tensor/gradients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<E, D: Storage<E>> Gradients<E, D> {
}

/// Returns a reference to the underlying gradient if found.
pub(crate) fn get_ref_checked<S: Shape, T>(&self, t: &Tensor<S, E, D, T>) -> Option<&D::Vec> {
pub fn get_ref_checked<S: Shape, T>(&self, t: &Tensor<S, E, D, T>) -> Option<&D::Vec> {
self.gradient_by_id.get(&t.id)
}

Expand Down
2 changes: 1 addition & 1 deletion src/tensor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ mod tensor_impls;

pub(crate) use ghost::GhostTensor;
pub(crate) use storage_traits::{OneFillStorage, ZeroFillStorage};
pub(crate) use tensorlike::Tensorlike;
pub use tensorlike::Tensorlike;

pub use cpu::{Cpu, CpuError};
#[cfg(not(feature = "cuda"))]
Expand Down
1 change: 1 addition & 0 deletions src/tensor/tensorlike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use super::{storage_traits::AllocGrad, GhostTensor, Tensor, UniqueId};
/// exists to unify handling of [Tensor] and [GhostTensor].

Check warning on line 10 in src/tensor/tensorlike.rs

View workflow job for this annotation

GitHub Actions / cargo-check

public documentation for `Tensorlike` links to private item `GhostTensor`
///
/// *If it looks like a tensor and barks like a tensor, then pet it like a tensor.*
#[allow(clippy::len_without_is_empty)]
pub trait Tensorlike<S: Shape, E, D: Storage<E>>:
AllocGrad<Gradient = D::Vec> + HasErr<Err = D::Err> + HasShape<Shape = S>
{
Expand Down

0 comments on commit bd6b368

Please sign in to comment.