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

Function test_apply

tests/python/tirx/test_layout.py:1067–1252  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1065
1066
1067def test_apply():
1068 ################ TileLayout
1069 def test_tile_layout_0():
1070 layout = TileLayout(S[(8, 8) : (8, 1)])
1071 for i, j in itertools.product(range(8), range(8)):
1072 assert layout.apply(i * 8 + j)["m"] == i * 8 + j * 1
1073 for i, j in itertools.product(range(8), range(8)):
1074 assert layout.apply(i, j, shape=(8, 8))["m"] == i * 8 + j * 1
1075 # # apply can accept coord larger than size
1076 # for p in range(1024):
1077 # outer = p // 64
1078 # inner = p % 64
1079 # i, j = inner // 8, inner % 8
1080 # assert layout.apply(p)["m"] == outer * 64 + i * 8 + j * 1
1081 with pytest.raises(Exception):
1082 layout.apply(1, 1, 1)
1083
1084 test_tile_layout_0()
1085
1086 def test_tile_layout_1():
1087 layout = TileLayout(S[(8, 8) : (10, 1)])
1088 for i, j in itertools.product(range(8), range(8)):
1089 assert layout.apply(i * 8 + j)["m"] == i * 10 + j * 1
1090 for i, j in itertools.product(range(8), range(8)):
1091 assert layout.apply(i, j, shape=(8, 8))["m"] == i * 10 + j * 1
1092
1093 # # apply can accept coord larger than size
1094 # for p in range(1024):
1095 # outer = p // 64
1096 # inner = p % 64
1097 # i, j = inner // 8, inner % 8
1098 # assert (
1099 # layout.apply(
1100 # p,
1101 # )[0]
1102 # == outer * 78 + i * 10 + j * 1
1103 # )
1104
1105 test_tile_layout_1()
1106
1107 def test_tile_layout_2():
1108 layout = TileLayout(S[(2, 3, 4, 2, 2) : (1, 2, 12, 6, 48)])
1109
1110 def f(i0, i1):
1111 leaf1 = i0 // 3
1112 leaf2 = i0 % 3
1113 leaf3 = i1 // 4
1114 leaf4 = (i1 % 4) // 2
1115 leaf5 = i1 % 2
1116 assert (
1117 layout.apply(i0, i1, shape=(6, 16))["m"]
1118 == leaf1 * 1 + leaf2 * 2 + leaf3 * 12 + leaf4 * 6 + leaf5 * 48
1119 )
1120
1121 for i0, i1 in itertools.product(range(6), range(16)):
1122 f(i0, i1)
1123 for i in range(6 * 16):
1124 f(i // 16, i % 16)

Callers

nothing calls this directly

Calls 14

test_tile_layout_0Function · 0.85
test_tile_layout_1Function · 0.85
test_tile_layout_2Function · 0.85
test_tile_layout_3Function · 0.85
test_tile_layout_4Function · 0.85
test_swizzle_layout_0Function · 0.85
test_swizzle_layout_1Function · 0.85
test_swizzle_layout_2Function · 0.85
test_swizzle_layout_3Function · 0.85
test_compose_layout_0Function · 0.85
test_compose_layout_1Function · 0.85
test_trainium_layout_0Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…