MCPcopy Create free account
hub / github.com/apache/tvm / _reflect_coordinates

Function _reflect_coordinates

python/tvm/topi/testing/grid_sample_python.py:72–91  ·  view source on GitHub ↗
(i, size)

Source from the content-addressed store, hash-verified

70 return min(max(x, 0), size - 1)
71
72 def _reflect_coordinates(i, size):
73 def __refelection(i, size, corner_start):
74 def __reflect(index, size, corner_start):
75 index_align_corner = abs(corner_start - index)
76 size_times = index_align_corner // size
77 even = size_times % 2 == 0
78 extra = index_align_corner - size_times * size
79 return extra + corner_start if even else size - extra + corner_start
80
81 if corner_start <= i <= size + corner_start:
82 new_i = i
83 else:
84 new_i = __reflect(i, size, corner_start)
85 return new_i
86
87 if align_corners:
88 x = __refelection(i, size - 1, 0)
89 else:
90 x = __refelection(i, size, -0.5)
91 return x
92
93 def _compute_source_index(b, h, w):
94 y = grid[b, 1, h, w]

Callers 2

_compute_source_indexFunction · 0.70
coefficients_along_xFunction · 0.70

Calls 1

__refelectionFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…