Python wrappers
Public Python APIs implemented by this engine symbol.Autograd node for affine grid generation.
Builds an (N, H, W, 2) sampling grid by applying the per-sample affine
matrix to a regular
output lattice:
where are the normalised output coordinates in and
are the corresponding source coordinates that will be passed
to grid_sample. The backward propagates grad_out (shape
(N, H, W, 2)) back into theta by summing the outer products with
the homogeneous lattice coordinates.
Math
Lattice generation depends on align_corners_:
Attributes
schema_v1OpSchema"affine_grid", AmpPolicy::Promote.align_corners_boolWhen
true, the four corners of the output lattice map exactly to [-1, +1] on each axis; when false, the lattice is placed on pixel centres.N_, H_, W_intBatch size and output spatial dimensions.
orig_theta_shape_ShapeOriginal
(N, 2, 3) shape used to materialise the gradient.Static methods
1static
forward
→TensorImplPtrint forward(const int & theta, int N, int H, int W, bool align_corners)Generate the sampling grid with autograd wiring.
Parameters
thetaTensorImplPtrAffine matrices of shape
(N, 2, 3).NintBatch size (must equal
theta.shape()[0]).HintOutput grid height.
WintOutput grid width.
align_cornersboolLattice placement mode.
Returns
TensorImplPtrSampling grid of shape (N, H, W, 2) with last-axis ordering (x, y) (i.e. [..., 0] is the x-coordinate).