pub struct MaxPool1d { /* private fields */ }Expand description
1D max pooling layer.
Applies max pooling over a 3D input tensor, selecting the maximum value
in each sliding window along the temporal/sequence dimension.
Equivalent to PyTorch’s nn.MaxPool1d.
- Input shape:
[N, C, L_in] - Output shape:
[N, C, L_out]
Output size formula:
L_out = floor((L_in + 2*padding - dilation*(kernel_size-1) - 1) / stride + 1)§Example
ⓘ
let pool = MaxPool1d::new(2); // kernel_size=2, stride=2
let pool = MaxPool1d::with_stride(3, 1) // kernel_size=3, stride=1
.padding(1);
let y = pool.forward(&x)?;Implementations§
Source§impl MaxPool1d
impl MaxPool1d
Trait Implementations§
Source§impl Module for MaxPool1d
impl Module for MaxPool1d
Source§fn name(&self) -> &str
fn name(&self) -> &str
Human-readable type name used as node ID prefix in graph visualization.
Override to return a lowercase identifier (e.g., “linear”, “gelu”).
Source§fn forward(&self, input: &Variable) -> Result<Variable>
fn forward(&self, input: &Variable) -> Result<Variable>
Run the forward pass on
input and return the result.Source§fn parameters(&self) -> Vec<Parameter>
fn parameters(&self) -> Vec<Parameter>
Return this module’s learnable parameters.
Default: recursively collects from
sub_modules() with pointer dedup. Read moreSource§fn buffers(&self) -> Vec<Buffer>
fn buffers(&self) -> Vec<Buffer>
Return this module’s non-learnable persistent buffers (e.g., running stats).
Default: recursively collects from
sub_modules() with pointer dedup.
Leaf modules should override to return their own buffers.Source§fn sub_modules(&self) -> Vec<Rc<dyn Module>>
fn sub_modules(&self) -> Vec<Rc<dyn Module>>
Return direct child modules for recursive tree walks.
Override in composite modules (loops, switches, gates).
Source§fn move_to_device(&self, device: Device)
fn move_to_device(&self, device: Device)
Move all parameters and buffers to the given device. Read more
Source§fn set_training(&self, _training: bool)
fn set_training(&self, _training: bool)
Set training/eval mode. Affects Dropout, BatchNorm, etc.
Override in modules with mode-dependent behavior.
Source§fn trace(&self) -> Option<Variable>
fn trace(&self) -> Option<Variable>
Return per-iteration side output for loop tracing.
Override in loop body modules that capture trajectory data
(e.g., attention fixation points). Returns
None by default.
When Some, the loop executor collects traces accessible via
Graph::traces().Source§fn as_named_input(&self) -> Option<&dyn NamedInputModule>
fn as_named_input(&self) -> Option<&dyn NamedInputModule>
Upcast to
NamedInputModule for multi-input graphs.
Override in types that implement NamedInputModule to enable
receiving additional named inputs via graph using().Source§fn as_loop_body(&self) -> Option<&dyn LoopBody>
fn as_loop_body(&self) -> Option<&dyn LoopBody>
Upcast to
LoopBody for loop bodies that publish named per-iteration traces.
Override in types that implement LoopBody to enable multi-output trace
publishing via TraceEmit::publish. Default returns None, in which
case the loop runner falls back to the legacy Module::trace path.Source§fn structural_hash(&self) -> Option<String>
fn structural_hash(&self) -> Option<String>
SHA-256 hex hash of module architecture for checkpoint validation.
Override in composite modules (Graph) that compute a deterministic
hash from their topology and parameter shapes.
Source§fn reset(&self)
fn reset(&self)
Reset internal state (e.g. recurrent hidden state) between sequences.
Called by loops before iterating to clear stale tensors whose
grad_fns may reference freed saved tensors.
Override in stateful modules.
Source§fn detach_state(&self)
fn detach_state(&self)
Detach internal state from the computation graph (for truncated BPTT).
Called between training steps to break gradient chains on state
carried across forward passes (e.g., recurrent hidden state).
Override in stateful modules.
Source§fn aggregated_metrics_slot(&self) -> Option<Arc<Mutex<Option<EpochMetrics>>>>
fn aggregated_metrics_slot(&self) -> Option<Arc<Mutex<Option<EpochMetrics>>>>
Hand the framework the model’s shared slot for coord-broadcast
aggregated
crate::metrics::EpochMetrics. The cluster-
rank worker setup calls this at construction and stores the
returned Arc clone alongside its own — both ends then point
at the same Mutex, so the bridge thread’s writes are visible
to the user’s main-thread reads (Graph::latest_metrics,
Graph::aggregated_gpu_tabs — with Graph = flodl::graph::Graph). Read moreAuto Trait Implementations§
impl Freeze for MaxPool1d
impl RefUnwindSafe for MaxPool1d
impl Send for MaxPool1d
impl Sync for MaxPool1d
impl Unpin for MaxPool1d
impl UnsafeUnpin for MaxPool1d
impl UnwindSafe for MaxPool1d
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