docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
upsample_node.h File Reference

Bilinear 2D upsampling node compatible with aten::upsample_bilinear2d.vec. More...

Go to the source code of this file.

Classes

class  sdfg::math::tensor::UpsampleBilinear2DNode
 2D bilinear upsampling operation More...
class  sdfg::math::tensor::UpsampleBilinear2DNodeSerializer
 Serializer for UpsampleBilinear2DNode. More...

Namespaces

namespace  sdfg
namespace  sdfg::math
namespace  sdfg::math::tensor

Functions

data_flow::LibraryNodeCode sdfg::math::tensor::LibraryNodeType_UpsampleBilinear2D ("ml::UpsampleBilinear2D")

Detailed Description

Bilinear 2D upsampling node compatible with aten::upsample_bilinear2d.vec.

This file defines the UpsampleBilinear2DNode class which implements a 2D bilinear resize following the PyTorch aten::upsample_bilinear2d.vec operator semantics:

upsample_bilinear2d.vec(Tensor input, SymInt[]? output_size, bool align_corners, float[]? scale_factors) -> Tensor

Input/Output Requirements

  • Input connector "X": Input tensor [N, C, H_in, W_in]
  • Input connector "Y": Output tensor [N, C, H_out, W_out] (written in place)

Source-coordinate mapping

For each output index o along a spatial dimension the corresponding (fractional) source coordinate is computed exactly as PyTorch does:

  • align_corners: src = o * (In - 1) / (Out - 1) (0 if Out == 1)
  • otherwise: src = max(0, (o + 0.5) * rscale - 0.5) where rscale is 1 / scale_factor when explicit scale factors were provided, and In / Out otherwise.

The integer neighbours are i0 = floor(src) and i1 = min(i0 + 1, In - 1) with interpolation weight lambda = src - i0.