class nbla::WarpByFlow

template<typename T>
class WarpByFlow : public nbla::BaseFunction<>

Transform the image(s) *data* by *flow* field(s) of offset vectors such that each output pixel corresponds to the input image pixel at the offset location given by horizontal and vertical flow values.

Both *data* and flow* are 4-D variables (in “NCHW” layout) with identical shape except the *flow* channel dimension (which is always 2).

.. math:: output_{n,c,y,x} = data_{n,c,y’,x’} \text{ with } y’ = y - flow_{n,1,y,x} \text{ and } x’ = x - flow_{n,0,y,x}

The output pixel values at :math:`y’` and :math:`x’` locations are obtained by bilinear interpolating between the 4 closest pixels of the input image. Pixel values outside of the input image are implicitly padded with the value of the closest boundary pixel.

Inputs:

  • Input image data with shape `(N, Channels, Height, Width)`.

  • Flow field vectors with shape `(N, 2, Height, Width)`.

Outputs:

  • Transformed image data with shape `(N, Channels, Height, Width)`.

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.