class nbla::AffineGrid

template<typename T>
class AffineGrid : public nbla::BaseFunction<const vector<int>&, bool>

Inputs:

  • theta: N-D array with the shape ( \(B \times 2 \times 3\)), the sample-wise affine transformation matrix.

Outputs:

  • grid: N-D array with the shape ( \(B \times H \times W \times 2\)) for 2D and ( \(B \times D \times H \times W \times 3\)) for 3D. The last dimension of 2 is for (x, y) and of 3 for (x, y, z). The `gird` is used as the source grid for the warping.

Template Parameters:

T – Data type for computation.

Param size:

The grid size of ( \(H \times W\)) for 2D and ( \(D \times H \times W\)) for 3D.

Param align_corners:

If `True`, the top-left and bottom-right pixcels correspond to (-1, -1) and (1, 1) respectively since a pixel is located on the corner of a grid, and the target grid is normalized in [-1, 1]. If `False`, the normalized target grid in [-1, 1] is scaled by `size - 1 / size` according to the respective spatial size (e.g., \(H\) and \(W\)) before the transformation since a pixel is located on a center of a cell in a grid.

Public Functions

inline virtual shared_ptr<Function> copy() const

Copy another instance of Function with the same context.

inline virtual int min_inputs()

Get minimum number of inputs.

This is meant to be used in setup function with in_types which is used to get maximum number of inputs.

inline virtual int min_outputs()

Get minimum number of outputs.

This is meant to be used in setup function with out_types which is used to get max number of outputs.

inline virtual vector<dtypes> in_types()

Get input dtypes.

Last in_type will be used repeatedly if size of in_types is smaller than size of inputs

inline virtual vector<dtypes> out_types()

Get output dtypes.

Last out_type will be used repeatedly if size of out_types is smaller than size of outputs

inline virtual vector<string> allowed_array_classes()

Get array classes that are allowed to be specified by Context.

inline virtual string name()

Get function name in string.

inline virtual bool grad_depends_output_data(int i, int o) const

Dependency flag for checking if in-grad depends on out-data.

Checking if i-th input’ gradient computation requires o-th output’s data or not.

Note

If any of inputs requires an output variable data when computing its gradient, this function must be overridden to return appropriate boolean value. Otherwise, backward computation will be incorrect.

Parameters:
  • i[in] Input variable index.

  • o[in] Output variable index.