pub struct EagerNoGradGuard { /* private fields */ }Expand description
Scope guard that temporarily disables eager operation recording.
Values computed while this guard is alive are concrete eager tensors, but they do not participate in reverse-mode gradient tracking.
§Examples
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
use tenferro_cpu::CpuBackend;
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new());
let x = EagerTensor::requires_grad_in(
Tensor::from_vec_col_major(vec![1], vec![2.0_f64]).unwrap(),
ctx.clone(),
)?;
let y = {
let _guard = ctx.no_grad();
x.mul(&x)?
};
assert!(!y.tracks_grad());Trait Implementations§
Source§impl Debug for EagerNoGradGuard
impl Debug for EagerNoGradGuard
Source§impl Drop for EagerNoGradGuard
impl Drop for EagerNoGradGuard
Auto Trait Implementations§
impl Freeze for EagerNoGradGuard
impl RefUnwindSafe for EagerNoGradGuard
impl Send for EagerNoGradGuard
impl Sync for EagerNoGradGuard
impl Unpin for EagerNoGradGuard
impl UnsafeUnpin for EagerNoGradGuard
impl UnwindSafe for EagerNoGradGuard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more