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

Function verify_slice

tests/python/tirx/test_layout.py:1549–1570  ·  view source on GitHub ↗
(layout, shape, region, sliced)

Source from the content-addressed store, hash-verified

1547
1548def test_slice():
1549 def verify_slice(layout, shape, region, sliced):
1550 r_shape = [r[1] - r[0] for r in region]
1551 r_size = functools.reduce(operator.mul, [r[1] - r[0] for r in region])
1552
1553 def get_region_coord(u):
1554 coord = []
1555 for r in reversed(region):
1556 coord.append(u % (r[1] - r[0]))
1557 u //= r[1] - r[0]
1558 return coord[::-1]
1559
1560 def get_shape_coord(r_coord, region):
1561 return [region[i][0] + r_coord[i] for i in range(len(region))]
1562
1563 analyzer = Analyzer()
1564
1565 for u in range(r_size):
1566 r_coord = get_region_coord(u)
1567 s_coord = get_shape_coord(r_coord, region)
1568 a = layout.apply(*s_coord, shape=shape)["m"]
1569 b = sliced.apply(*r_coord, shape=r_shape)["m"]
1570 assert analyzer.simplify(a == b)
1571
1572 def case1():
1573 layout = TileLayout(S[(8, 8) : (8, 1)])

Callers 7

case1Function · 0.70
case2Function · 0.70
case3Function · 0.70
case4Function · 0.70
case_swizzle_sliceFunction · 0.70
case_compose_sliceFunction · 0.70
case_compose_slice_2dFunction · 0.70

Calls 6

simplifyMethod · 0.95
AnalyzerClass · 0.90
get_region_coordFunction · 0.85
get_shape_coordFunction · 0.85
reduceMethod · 0.80
applyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…