Skip to content

Commit 68079b9

Browse files
Test updates ; vibe tests
1 parent b95d545 commit 68079b9

29 files changed

Lines changed: 7623 additions & 40 deletions

accelforge/frontend/_binding.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Domain(EvalableModel):
2020
_prefix: str
2121
name: str
2222
dims: EvalableList[str]
23-
23+
2424
@property
2525
def isl_space(self) -> isl.Space:
2626
return isl.Space.create_from_names(
@@ -36,7 +36,8 @@ class LogicalDomain(Domain):
3636
"""
3737
Represents the logical architecture domain space of logical dims × tensor ranks.
3838
"""
39-
_prefix: str = 'l'
39+
40+
_prefix: str = "l"
4041
pass
4142

4243

@@ -45,7 +46,8 @@ class PhysicalDomain(Domain):
4546
Represents the logical architecture domain space of physical dims.
4647
The physical space is defined as the physical architecture dims.
4748
"""
48-
_prefix: str = 'p'
49+
50+
_prefix: str = "p"
4951
pass
5052

5153

@@ -109,6 +111,7 @@ class Binding(EvalableModel):
109111
nodes: EvalableList[BindingNode]
110112
"""Parts of the binding."""
111113

114+
112115
'''
113116
class NetworkOnChip(ParsableModel):
114117
"""A model of a network-on-chip on the physical chip."""
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
"""Applies the binding layer into one that can be used for later analysis,"""
2+
23
from accelforge.frontend.binding import Binding
34
from accelforge.frontend.mapping import Mapping
45
from accelforge.frontend.workload import Workload
56

67
from accelforge.model._looptree.reuse.isl.mapping_to_isl.analyze_mapping import (
78
occupancies_from_mapping,
8-
MappingAnalysisResult
9+
MappingAnalysisResult,
910
)
1011

1112

12-
1313
def apply_binding(binding: Binding, mapping: Mapping, workload: Workload):
1414
"""
1515
Given a mapping, apply the mapping from logical components onto physical
1616
components.
1717
"""
18-
map_analysis: MappingAnalysisResult = occupancies_from_mapping(
19-
mapping, workload
20-
)
18+
map_analysis: MappingAnalysisResult = occupancies_from_mapping(mapping, workload)
2119
for buffet, occ in map_analysis.buffet_to_occupancy.items():
2220
print(occ)
2321
print(binding)

accelforge/model/_looptree/reuse/isl/distributed/distributed_buffers.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def identify_mesh_casts(
3939
space, corresponding to the `src` and `dst`, and returns the distance
4040
between the two points in terms of `hops`, a quantized atomic distance of
4141
data transmission cost.
42-
42+
4343
Returns
4444
-------
4545
{ [data] -> [dst -> src] } where { [dst] -> [data] } and { [src] -> [data] } are in
@@ -57,9 +57,11 @@ def identify_mesh_casts(
5757
data_presence: isl.Map = src_occupancy.reverse()
5858

5959
# { [dst -> data] -> [dst -> src] } where src contains data.
60-
fills_to_matches: isl.Map = fill_to_fill.uncurry( # { [[dst -> data] -> dst] -> data }
61-
).apply_range(data_presence # { [[dst -> data] -> dst] -> src }
62-
).curry() # { [[dst -> data] -> [dst -> src] }
60+
fills_to_matches: isl.Map = (
61+
fill_to_fill.uncurry() # { [[dst -> data] -> dst] -> data }
62+
.apply_range(data_presence) # { [[dst -> data] -> dst] -> src }
63+
.curry()
64+
) # { [[dst -> data] -> [dst -> src] }
6365
if DUMP_ISL_IR:
6466
logging.info(f"fills_to_matches: {fills_to_matches}")
6567

@@ -68,13 +70,19 @@ def identify_mesh_casts(
6870
fill_min_dist: isl.Map = fills_to_matches.apply_range(dist_fn).lexmin()
6971
# Isolates the relevant minimal pairs.
7072
# { [dst -> data] -> [dst -> src] :.dst -> src is minimized distance }
71-
minimal_pairs: isl.Map = fill_min_dist.apply_range(
72-
# Note: Need to match fill -> min_dist with min_dist -> [fill -> match] as lexmin over
73-
# fill and match will minimize distance over the tuple (src, dst, data), but that
74-
# overconstrains the optimization as we want to minimize over distance (dst, data)
75-
# only for all src.
76-
fills_to_matches.range_map().apply_range(dist_fn).reverse()
77-
).range().unwrap()
73+
minimal_pairs: isl.Map = (
74+
fill_min_dist.apply_range(
75+
# Note: Need to match fill -> min_dist with min_dist -> [fill -> match] as lexmin over
76+
# fill and match will minimize distance over the tuple (src, dst, data), but that
77+
# overconstrains the optimization as we want to minimize over distance (dst, data)
78+
# only for all src.
79+
fills_to_matches.range_map()
80+
.apply_range(dist_fn)
81+
.reverse()
82+
)
83+
.range()
84+
.unwrap()
85+
)
7886
if DUMP_ISL_IR:
7987
logging.info(f"minimal_pairs: {minimal_pairs}")
8088

@@ -211,7 +219,7 @@ def _cost_mesh_cast_hypercube(self, mcns: isl.Map) -> int:
211219
mcns:
212220
Multicast networks grouped together by [srcs -> data] fulfilling
213221
[dsts -> data], where there is at least 1 src and 1 dst in each mcn.
214-
222+
215223
Returns
216224
-------
217225
The upperbound of doing all the multicasts specified by the multicast

tests/__init__.py

Whitespace-only changes.

tests/isl/distributed/test_multicast.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ def test_gamut(self):
6666
fill: Fill = Fill(dim_tags, test["fill"])
6767
occ: Occupancy = Occupancy(dim_tags, test["occ"])
6868
dist_fn: isl.Map = test["dist_fn"]
69-
multicast_model: HypercubeMulticastModel = HypercubeMulticastModel(
70-
dist_fn
71-
)
69+
multicast_model: HypercubeMulticastModel = HypercubeMulticastModel(dist_fn)
7270

7371
# Applies the model.
7472
info: TransferInfo = multicast_model.apply(0, fill, occ)

tests/isl/mapper/configs/conv1d/conv1d.workload.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
workload:
2-
shape:
2+
iteration_space_shape:
33
r: 0 <= r < 3
44
p: 0 <= p < 16
55

tests/isl/mapper/configs/two_conv1d/two_conv1d.workload.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
workload:
2-
shape:
2+
iteration_space_shape:
33
ra: 0 <= ra < 3
44
pa: 0 <= pa < 16
55
rb: 0 <= rb < 3

tests/isl/mapper/test_isl_functions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
from accelforge.model._looptree.reuse.isl.isl_functions import *
1010

11+
1112
class BasicIslFunctionTests(unittest.TestCase):
1213
"""
1314
Prima facie checks of `isl_functions` to ensure basic functionality.
1415
"""
1516

1617
def test_project_dim_after(self):
17-
pass
18+
pass

tests/isl/mapper/test_mapping_to_isl.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
TEST_CONFIG_PATH: Path = Path(__file__).parent / "configs"
2323

24+
2425
class TestMappingToIsl(unittest.TestCase):
2526
"""
2627
Tests taking a `Mapping` and `Workload` and converting it into relevant isl
@@ -33,9 +34,13 @@ def test_conv1d(self):
3334
"""
3435
# Loads in the CONV1D Config
3536
config_path: Path = TEST_CONFIG_PATH / "conv1d"
36-
workload: Workload = Workload.from_yaml(config_path / "conv1d.workload.yaml")
37+
workload: Workload = Workload.from_yaml(
38+
config_path / "conv1d.workload.yaml", top_key="workload"
39+
)
3740

38-
mapping: Mapping = Mapping.from_yaml(config_path / "conv1d.mapping.yaml")
41+
mapping: Mapping = Mapping.from_yaml(
42+
config_path / "conv1d.mapping.yaml", top_key="mapping"
43+
)
3944
occupancies: MappingAnalysisResult = analyze_mapping.occupancies_from_mapping(
4045
mapping, workload
4146
)
@@ -56,10 +61,12 @@ def test_two_conv1d(self):
5661
# Loads in the CONV1D Config
5762
config_path: Path = TEST_CONFIG_PATH / "two_conv1d"
5863
workload: Workload = Workload.from_yaml(
59-
config_path / "two_conv1d.workload.yaml"
64+
config_path / "two_conv1d.workload.yaml", top_key="workload"
6065
)
6166

62-
mapping: Mapping = Mapping.from_yaml(config_path / "two_conv1d.mapping.yaml")
67+
mapping: Mapping = Mapping.from_yaml(
68+
config_path / "two_conv1d.mapping.yaml", top_key="mapping"
69+
)
6370
occupancies: MappingAnalysisResult = analyze_mapping.occupancies_from_mapping(
6471
mapping, workload
6572
)

tests/isl/util.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from ruamel.yaml import YAML
99

10+
1011
def to_isl_maps(obj: str | list | dict) -> dict:
1112
"""
1213
Given an object, attempt to reduce all strings in tree with isl.Map
@@ -26,10 +27,7 @@ def _to_isl_maps(obj: str | dict | list) -> isl.Map | dict | list:
2627
if isinstance(obj, str):
2728
return isl.Map.read_from_str(isl.DEFAULT_CONTEXT, obj)
2829
if isinstance(obj, dict):
29-
return {
30-
k: (_to_isl_maps(v) if k != 'type' else v)
31-
for k, v in obj.items()
32-
}
30+
return {k: (_to_isl_maps(v) if k != "type" else v) for k, v in obj.items()}
3331
if isinstance(obj, list):
3432
return [_to_isl_maps(v) for v in obj]
3533
return obj

0 commit comments

Comments
 (0)