pub struct WithCpuCopy<T: AsModule> { /* private fields */ }
Expand description
Wraps a module to have a lazily-initialized CPU copy if not already in CPU memory.
This is useful for models used both in training and in simulation because large batch size training is most efficient on the GPU while batch-size-1 simulation is most efficient on the CPU.
Implementations
sourceimpl<T: AsModule> WithCpuCopy<T>
impl<T: AsModule> WithCpuCopy<T>
sourcepub fn as_inner_mut(&mut self) -> &mut T
pub fn as_inner_mut(&mut self) -> &mut T
Get a mutable reference to the inner struct. Invalidates the cached CPU copy if any.
sourcepub fn shallow_clone_module_cpu(&self) -> T::Module
pub fn shallow_clone_module_cpu(&self) -> T::Module
Create a shallow clone of the module on CPU memory.
If the module is not already on the CPU device then a cached deep copy is created on the CPU first. This cached copy is reused on future calls.
Trait Implementations
sourceimpl<T: AsModule> AsModule for WithCpuCopy<T>
impl<T: AsModule> AsModule for WithCpuCopy<T>
sourceimpl<T: AsModule + Clone> Clone for WithCpuCopy<T>
impl<T: AsModule + Clone> Clone for WithCpuCopy<T>
sourceimpl<T: AsModule + Debug> Debug for WithCpuCopy<T>
impl<T: AsModule + Debug> Debug for WithCpuCopy<T>
sourceimpl<'de, T: AsModule> Deserialize<'de> for WithCpuCopy<T> where
T: Deserialize<'de>,
impl<'de, T: AsModule> Deserialize<'de> for WithCpuCopy<T> where
T: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T: AsModule + PartialEq> PartialEq<WithCpuCopy<T>> for WithCpuCopy<T>
impl<T: AsModule + PartialEq> PartialEq<WithCpuCopy<T>> for WithCpuCopy<T>
sourceimpl<P: Policy> Policy for WithCpuCopy<P>
impl<P: Policy> Policy for WithCpuCopy<P>
type PolicyModule = <P as Policy>::PolicyModule
sourcefn update<AS: ParameterizedDistributionSpace<Tensor> + ?Sized>(
&mut self,
features: &dyn HistoryFeatures,
advantages: PackedTensor,
action_space: &AS,
logger: &mut dyn StatsLogger
)
fn update<AS: ParameterizedDistributionSpace<Tensor> + ?Sized>(
&mut self,
features: &dyn HistoryFeatures,
advantages: PackedTensor,
action_space: &AS,
logger: &mut dyn StatsLogger
)
Update the policy module. Read more
sourcefn actor<OS, AS>(
&self,
observation_space: NonEmptyFeatures<OS>,
action_space: AS
) -> PolicyActor<OS, AS, Self::Module>
fn actor<OS, AS>(
&self,
observation_space: NonEmptyFeatures<OS>,
action_space: AS
) -> PolicyActor<OS, AS, Self::Module>
Create an actor for the policy module.
Auto Trait Implementations
impl<T> !RefUnwindSafe for WithCpuCopy<T>
impl<T> Send for WithCpuCopy<T> where
T: Send,
<T as AsModule>::Module: Send,
impl<T> !Sync for WithCpuCopy<T>
impl<T> Unpin for WithCpuCopy<T> where
T: Unpin,
<T as AsModule>::Module: Unpin,
impl<T> UnwindSafe for WithCpuCopy<T> where
T: UnwindSafe,
<T as AsModule>::Module: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more