Shortcuts

Struct InterpolateFuncOptions

Page Contents

Struct Documentation

struct InterpolateFuncOptions

Options for torch::nn::functional::interpolate.

Example:

namespace F = torch::nn::functional;
F::interpolate(input,
F::InterpolateFuncOptions().size(std::vector<int64_t>({4})).mode(torch::kNearest));

Public Types

typedef std::variant<enumtype::kNearest, enumtype::kLinear, enumtype::kBilinear, enumtype::kBicubic, enumtype::kTrilinear, enumtype::kArea, enumtype::kNearestExact> mode_t

Public Functions

inline auto size(const std::optional<std::vector<int64_t>> &new_size) -> decltype(*this)

output spatial sizes.

inline auto size(std::optional<std::vector<int64_t>> &&new_size) -> decltype(*this)
inline const std::optional<std::vector<int64_t>> &size() const noexcept
inline std::optional<std::vector<int64_t>> &size() noexcept
inline auto scale_factor(const std::optional<std::vector<double>> &new_scale_factor) -> decltype(*this)

multiplier for spatial size.

inline auto scale_factor(std::optional<std::vector<double>> &&new_scale_factor) -> decltype(*this)
inline const std::optional<std::vector<double>> &scale_factor() const noexcept
inline std::optional<std::vector<double>> &scale_factor() noexcept
inline auto mode(const mode_t &new_mode) -> decltype(*this)

the upsampling algorithm: one of “nearest”, “linear”, “bilinear”, “bicubic”, “trilinear”, “area”, “nearest-exact”.

Default: “nearest”

inline auto mode(mode_t &&new_mode) -> decltype(*this)
inline const mode_t &mode() const noexcept
inline mode_t &mode() noexcept
inline auto align_corners(const std::optional<bool> &new_align_corners) -> decltype(*this)

Geometrically, we consider the pixels of the input and output as squares rather than points.

If set to “True”, the input and output tensors are aligned by the center points of their corner pixels, preserving the values at the corner pixels. If set to “False”, the input and output tensors are aligned by the corner points of their corner pixels, and the interpolation uses edge value padding for out-of-boundary values, making this operation independent of input size when scale_factor is kept the same. It is required when interpolating mode is “linear”, “bilinear”, “bicubic” or “trilinear”. Default: “False”

inline auto align_corners(std::optional<bool> &&new_align_corners) -> decltype(*this)
inline const std::optional<bool> &align_corners() const noexcept
inline std::optional<bool> &align_corners() noexcept
inline auto recompute_scale_factor(const std::optional<bool> &new_recompute_scale_factor) -> decltype(*this)

recompute the scale_factor for use in the interpolation calculation.

When scale_factor is passed as a parameter, it is used to compute the output_size. If recompute_scale_factor is true or not specified, a new scale_factor will be computed based on the output and input sizes for use in the interpolation computation (i.e. the computation will be identical to if the computed output_size were passed-in explicitly). Otherwise, the passed-in scale_factor will be used in the interpolation computation. Note that when scale_factor is floating-point, the recomputed scale_factor may differ from the one passed in due to rounding and precision issues.

inline auto recompute_scale_factor(std::optional<bool> &&new_recompute_scale_factor) -> decltype(*this)
inline const std::optional<bool> &recompute_scale_factor() const noexcept
inline std::optional<bool> &recompute_scale_factor() noexcept
inline auto antialias(const bool &new_antialias) -> decltype(*this)

flag to apply anti-aliasing.

Using anti-alias option together with :attr:align_corners equals “False”, interpolation result would match Pillow result for downsampling operation. Supported modes: “bilinear”. Default: “False”.

inline auto antialias(bool &&new_antialias) -> decltype(*this)
inline const bool &antialias() const noexcept
inline bool &antialias() noexcept

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources