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

Get a reference to the inner struct.

Get a mutable reference to the inner struct. Invalidates the cached CPU copy if any.

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

Get mutable reference to the module. Invalidates the cached CPU copy if any.

Apply a batch-structure-preserving function to the module output.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Update the policy module. Read more

Create an actor for the policy module.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Convert into an Any trait reference.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.