class nbla::Interpolate

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

Resize an ND array with interpolation.

The last output_size.size() dimensions of the input are considered as the spatial dimensions.

Inputs:

  • x: N-D array with an arbitrary number of dimensions.

Outputs:

  • y: N-D array. The shape are the same as the input except that the last dimensions are replaced with the output_size.

Template Parameters:

T – Data type for computation.

Param output_size:

The Spatial sizes resized to.

Param mode:

Interpolation mode chosen from linear or nearest.

Param align_corners:

If true, the corner pixels are aligned to preserve the values of the input corner pixels.

Param half_pixel:

If true, in the coordinate transformation, 0.5 is added to the output coordinate and 0.5 is subtracted from the input coordinate after scaling. Default is `False`. This option is only applicable to the `mode` being linear.

Param half_pixel_for_nn:

This is a special argument to support the backward-compatibility of the nearest neighbor interpolation. Default is `False`.

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.