class nbla::WarpByGrid

template<typename T>
class WarpByGrid : public nbla::BaseFunction<const string&, const string&, bool, bool>

Inputs:

  • x: Input data to be warped with the shape ( \(B \times C \times H_{in} \times W_{in}\)) for 2D and ( \(B \times C \times D_{in} \times H_{in} \times W_{in}\)) for 3D.

  • grid: Grid warping the input data with the shape ( \(B \times H_{out} \times W_{out} \times 2\)) for 2D and ( \(B \times D_{out} \times H_{out} \times W_{out} \times 3\)) for 3D. The last dimension of 2 is for (x, y) or (x, y, z).

Outputs:

  • y: Output data warped by the grid.

Template Parameters:

T – Data type for computation.

Param mode:

Interpolation mode, linear or nearest.

Param padding_mode:

Padding mode when the grid value is outside [-1, 1]. If this is “zero”, 0 is used for padding. “reflect” uses the values reflected at the ends of the original input data like the mirror. “repeat” used the values at the ends of the original input data.

Param align_corners:

The target grid normalized in [-1, 1] is scaled by `size - 1 / size` according to the respective spatial size (e.g., \(H\) and \(W\)) before the transformation if this is `False`. If this is `True`, the top-left and bottom-right pixcels correspond to (-1, -1) and (1, 1) respectively.

Param channel_last:

If True, the last dimension is considered as channel dimension, a.k.a NHWC order.

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.