MCPcopy Index your code
hub / github.com/apache/tvm / get_slice

Function get_slice

python/tvm/topi/testing/poolnd_python.py:71–99  ·  view source on GitHub ↗

Programmatically create a slice object of the right dimensions for pad_np. We assume pad_np's first two dimensions are not spatial and are not touched by the pad. pad_np[slice] should give the elements of the data that a pool operation will use for the step given in dim_coord.

(
    spatial_dimensions: int,
    pad_np: np.array,
    dim_coord: tuple[int],
    kernel: tuple[int],
    strides: tuple[int],
    dilation: tuple[int],
)

Source from the content-addressed store, hash-verified

69
70
71def get_slice(
72 spatial_dimensions: int,
73 pad_np: np.array,
74 dim_coord: tuple[int],
75 kernel: tuple[int],
76 strides: tuple[int],
77 dilation: tuple[int],
78) -> tuple[slice]:
79 """
80 Programmatically create a slice object of the right dimensions for pad_np.
81
82 We assume pad_np's first two dimensions are not spatial and are not touched by the pad.
83
84 pad_np[slice] should give the elements of the data that a pool operation will use for the
85 step given in dim_coord.
86 """
87 slices = [slice(None)] * spatial_dimensions
88
89 for nd in range(spatial_dimensions):
90 slices[nd] = slice(
91 dim_coord[nd] * strides[nd],
92 dim_coord[nd] * strides[nd] + (kernel[nd] - 1) * dilation[nd] + 1,
93 dilation[nd],
94 )
95
96 # Add back batch and channel dimensions
97 slices = [slice(None), slice(None)] + slices
98
99 return tuple(slices)
100
101
102def pad_tensor(

Callers 1

poolnd_pythonFunction · 0.85

Calls 1

tupleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…