Skip to content
class

ConvTransposeNdBackward

ConvTransposeNdBackward

Python wrappers

Public Python APIs implemented by this engine symbols.

Autograd node for the N-dimensional transposed convolution.

Backward of this op is itself a regular convolution against the same weights, so the implementation reuses the ConvNdBackward kernels for dx and the matching im2col path for dW.

Attributes

schema_v1OpSchema
Registered op schema ("conv_transpose1d" / "conv_transpose2d" / "conv_transpose3d") with AmpPolicy::Promote.
stride_int[N]
Per-axis upsampling factor. Stride > 1 interleaves implicit zeros between input elements.
pad_int[N]
Per-axis dilation * (K - 1) - padding zero-padding removed from the output.
opad_int[N]
Per-axis output padding added to one side of the output to disambiguate the inverse-stride shape. Must be less than stride along each axis.
dilation_int[N]
Per-axis spacing between kernel taps.
groups_int
Channel grouping factor. groups_ == C_in is the depthwise case used by efficient decoder heads.

Static methods

1
static

forward

→TensorImplPtr
int forward(const int & x, const int & W, const int & b, const int (&)[N] stride, const int (&)[N] pad, const int (&)[N] opad, const int (&)[N] dilation, int groups)

Run the forward transposed convolution and attach the backward node.

Parameters

xTensorImplPtr
Input batch of shape (B, C_in, S_0, ..., S_{N-1}).
WTensorImplPtr
Filter bank of shape (C_in, C_out / groups, K_0, ..., K_{N-1}). The leading axis is C_in — this is the transposed layout relative to ConvNdBackward.
bTensorImplPtr
Bias of shape (C_out,) or empty for bias-less variants.
stridearray<int, N>
Per-axis upsampling factor.
padarray<int, N>
Per-axis input padding effectively subtracted from each output extent.
opadarray<int, N>
Per-axis output padding added to one side. Must satisfy opad[i] < stride[i].
dilationarray<int, N>
Per-axis spacing between kernel taps.
groupsint
Channel grouping factor. C_in and C_out must both be divisible by it, and W's second axis is C_out / groups.

Returns

TensorImplPtr

Output of shape (B, C_out, O_0, ..., O_{N-1}) where each extent is Oi=(Si−1) si−2pi+di(Ki−1)+1+pioutO_i = (S_i - 1)\, s_i - 2 p_i + d_i (K_i - 1) + 1 + p^\text{out}_i.

Raises

ShapeMismatch
If the input rank disagrees with N + 2, if W's leading axis does not match C_in, if C_in is not divisible by groups, if b is not 1-D of length C_out, or if a computed output extent is non-positive.
DeviceMismatch
If x, W, b do not all live on the same device.

Methods

2
fn

apply

→vector<Storage>
int apply(int grad_out)

Backward — compute [dx, dW, db] for the three saved inputs.

The gradient w.r.t. x is a regular ConvNd against W (the transposed-conv's adjoint is a forward conv). dW is obtained via the matching im2col path against the saved input, and db via a channel-wise reduction.

Parameters

grad_outStorage
Upstream gradient with the forward output shape.

Returns

vector<Storage>

Gradients in declaration order: dx, dW, db.

fn

apply_for_graph

int apply_for_graph(const int & grad_out)

Graph-mode backward (create_graph=True): the same three gradients built from differentiable ops, so they can be differentiated again.