Home / Class/ grid_sampler_unnormalize_set_grad Class — pytorch Architecture

grid_sampler_unnormalize_set_grad Class — pytorch Architecture

Architecture documentation for the grid_sampler_unnormalize_set_grad class in GridSampler.h from the pytorch codebase.

Entity Profile

Source Code

aten/src/ATen/native/GridSampler.h lines 41–53

template <typename scalar_t>
static inline scalar_t grid_sampler_unnormalize_set_grad(scalar_t coord, int64_t size,
                                                         bool align_corners, scalar_t *grad_in) {
  if (align_corners) {
    // unnormalize coord from [-1, 1] to [0, size - 1]
    *grad_in = static_cast<scalar_t>(size - 1) / 2;
    return ((coord + 1) / 2) * (size - 1);
  } else {
    // unnormalize coord from [-1, 1] to [-0.5, size - 0.5]
    *grad_in = static_cast<scalar_t>(size) / 2;
    return ((coord + 1) * size - 1) / 2;
  }
}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free