Skip to content
class

FoldBackward

FoldBackward

Python wrappers

Public Python APIs implemented by this engine symbols.

Autograd node for Fold (col2im), the adjoint of Unfold.

fold scatter-adds patches back into an image, so its transpose is exactly the unfold gather — the backward runs unfold_forward with the same hyper-parameters.

Members

output_size_ : vector<int> Spatial extent of the folded output, per axis. kernel_, stride_, pad_, dilation_ : vector<int> Per-axis hyper-parameters, as for UnfoldBackward.

Instance methods

2
fn

apply

→vector<Storage>
int apply(int grad_out)

Backward — the im2col gather that recovers the column-matrix gradient.

Parameters

grad_outStorage
Upstream gradient shaped like the folded image.

Returns

vector<Storage>

Single-element vector containing dx shaped (B, C * prod(K), prod(O)).

fn

apply_for_graph

int apply_for_graph(const int & grad_out)

Graph-mode backward: the adjoint is the other op of the pair (fold for unfold, unfold for fold), recorded so it can be differentiated again.