accelforge 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- accelforge/__init__.py +21 -0
- accelforge/_accelerated_imports.py +16 -0
- accelforge/_deprecate/_simanneal/evalmapping.py +271 -0
- accelforge/_deprecate/_simanneal/mapspaceglobals.py +298 -0
- accelforge/_deprecate/_simanneal/simanneal.py +666 -0
- accelforge/_deprecate/_simanneal/tracking.py +105 -0
- accelforge/_deprecate/_simanneal/wrappers.py +218 -0
- accelforge/_deprecate/_simanneal2/__init__.py +7 -0
- accelforge/_deprecate/_simanneal2/simanneal.py +493 -0
- accelforge/_deprecate/_simanneal2/tracking.py +116 -0
- accelforge/_deprecate/compatibility_util.py +181 -0
- accelforge/_deprecate/layerdeduplication/__init__.py +2 -0
- accelforge/_deprecate/layerdeduplication/group_similar_einsums.py +160 -0
- accelforge/_deprecate/layerdeduplication/grouped_einsums.py +84 -0
- accelforge/_deprecate/mapping_filter_tags/__init__.py +2 -0
- accelforge/_deprecate/mapping_filter_tags/ffmt.py +212 -0
- accelforge/_deprecate/mapping_filter_tags/onesplit.py +24 -0
- accelforge/_deprecate/mapping_filter_tags/util.py +24 -0
- accelforge/_deprecate/tags.py +69 -0
- accelforge/_deprecate/viz/__init__.py +0 -0
- accelforge/_deprecate/viz/interactive.py +159 -0
- accelforge/_deprecate/viz/reservationtree.py +307 -0
- accelforge/_deprecate/viz/ski_slope.py +88 -0
- accelforge/_version.py +15 -0
- accelforge/examples.py +39 -0
- accelforge/frontend/__init__.py +10 -0
- accelforge/frontend/_binding.py +129 -0
- accelforge/frontend/_workload_isl/__init__.py +2 -0
- accelforge/frontend/_workload_isl/_isl.py +149 -0
- accelforge/frontend/_workload_isl/_symbolic.py +141 -0
- accelforge/frontend/arch copy.py +1544 -0
- accelforge/frontend/arch.py +1642 -0
- accelforge/frontend/config.py +63 -0
- accelforge/frontend/mapper/__init__.py +5 -0
- accelforge/frontend/mapper/ffm.py +126 -0
- accelforge/frontend/mapper/mapper.py +7 -0
- accelforge/frontend/mapper/metrics.py +30 -0
- accelforge/frontend/mapping/__init__.py +1 -0
- accelforge/frontend/mapping/mapping.py +1736 -0
- accelforge/frontend/model.py +14 -0
- accelforge/frontend/renames.py +150 -0
- accelforge/frontend/spec copy.py +230 -0
- accelforge/frontend/spec.py +301 -0
- accelforge/frontend/variables.py +12 -0
- accelforge/frontend/workload.py +952 -0
- accelforge/mapper/FFM/__init__.py +9 -0
- accelforge/mapper/FFM/_join_pmappings/__init__.py +0 -0
- accelforge/mapper/FFM/_join_pmappings/compatibility.py +653 -0
- accelforge/mapper/FFM/_join_pmappings/compress_pmappings.py +140 -0
- accelforge/mapper/FFM/_join_pmappings/join_pmappings.py +703 -0
- accelforge/mapper/FFM/_join_pmappings/pmapping_dataframe.py +901 -0
- accelforge/mapper/FFM/_join_pmappings/pmapping_group.py +337 -0
- accelforge/mapper/FFM/_make_pmappings/contraints/__init__.py +0 -0
- accelforge/mapper/FFM/_make_pmappings/contraints/constraints.py +360 -0
- accelforge/mapper/FFM/_make_pmappings/make_pmapping_templates/__init__.py +1 -0
- accelforge/mapper/FFM/_make_pmappings/make_pmapping_templates/make_loops.py +373 -0
- accelforge/mapper/FFM/_make_pmappings/make_pmapping_templates/make_pmapping_templates.py +463 -0
- accelforge/mapper/FFM/_make_pmappings/make_pmapping_templates/make_reservations.py +95 -0
- accelforge/mapper/FFM/_make_pmappings/make_pmapping_templates/make_storage_order.py +382 -0
- accelforge/mapper/FFM/_make_pmappings/make_pmapping_templates/make_storages.py +155 -0
- accelforge/mapper/FFM/_make_pmappings/make_pmappings.py +411 -0
- accelforge/mapper/FFM/_make_pmappings/make_pmappings_from_templates/__init__.py +1 -0
- accelforge/mapper/FFM/_make_pmappings/make_pmappings_from_templates/make_pmappings_from_templates.py +407 -0
- accelforge/mapper/FFM/_make_pmappings/make_pmappings_from_templates/make_tile_shapes.py +1681 -0
- accelforge/mapper/FFM/_make_pmappings/make_pmappings_from_templates/run_model.py +170 -0
- accelforge/mapper/FFM/_make_pmappings/make_pmappings_from_templates/symbol_relations.py +174 -0
- accelforge/mapper/FFM/_make_pmappings/pmapper_job.py +282 -0
- accelforge/mapper/FFM/_pareto_df/df_convention.py +273 -0
- accelforge/mapper/FFM/_pareto_df/pareto copy.py +836 -0
- accelforge/mapper/FFM/_pareto_df/pareto.py +508 -0
- accelforge/mapper/FFM/data.py +61 -0
- accelforge/mapper/FFM/main copy.py +236 -0
- accelforge/mapper/FFM/main.py +208 -0
- accelforge/mapper/FFM/mappings.py +510 -0
- accelforge/mapper/FFM/pmappings.py +310 -0
- accelforge/mapper/__init__.py +4 -0
- accelforge/mapper.py +0 -0
- accelforge/model/__init__.py +1 -0
- accelforge/model/_looptree/__init__.py +0 -0
- accelforge/model/_looptree/accesses.py +335 -0
- accelforge/model/_looptree/capacity/__init__.py +1 -0
- accelforge/model/_looptree/capacity/aggregators.py +36 -0
- accelforge/model/_looptree/capacity/capacity.py +47 -0
- accelforge/model/_looptree/energy.py +150 -0
- accelforge/model/_looptree/equivalent_ranks.py +29 -0
- accelforge/model/_looptree/latency/__init__.py +1 -0
- accelforge/model/_looptree/latency/latency.py +98 -0
- accelforge/model/_looptree/latency/memory.py +120 -0
- accelforge/model/_looptree/latency/processors.py +92 -0
- accelforge/model/_looptree/mapping_utilities.py +71 -0
- accelforge/model/_looptree/reuse/__init__.py +4 -0
- accelforge/model/_looptree/reuse/isl/__init__.py +1 -0
- accelforge/model/_looptree/reuse/isl/des.py +59 -0
- accelforge/model/_looptree/reuse/isl/isl_functions.py +374 -0
- accelforge/model/_looptree/reuse/isl/mapping_to_isl/__init__.py +4 -0
- accelforge/model/_looptree/reuse/isl/mapping_to_isl/analyze_mapping.py +297 -0
- accelforge/model/_looptree/reuse/isl/mapping_to_isl/skews_from_mapping.py +236 -0
- accelforge/model/_looptree/reuse/isl/mapping_to_isl/tiling.py +685 -0
- accelforge/model/_looptree/reuse/isl/mapping_to_isl/types.py +188 -0
- accelforge/model/_looptree/reuse/isl/spatial.py +260 -0
- accelforge/model/_looptree/reuse/isl/temporal.py +182 -0
- accelforge/model/_looptree/reuse/symbolic/__init__.py +1 -0
- accelforge/model/_looptree/reuse/symbolic/symbolic copy 2.py +1346 -0
- accelforge/model/_looptree/reuse/symbolic/symbolic copy.py +1408 -0
- accelforge/model/_looptree/reuse/symbolic/symbolic.py +1396 -0
- accelforge/model/_looptree/run.py +122 -0
- accelforge/model/_looptree/types.py +26 -0
- accelforge/model/_looptree/visualization/__init__.py +0 -0
- accelforge/model/_looptree/visualization/occupancy.py +11 -0
- accelforge/model/main.py +222 -0
- accelforge/plotting/__init__.py +2 -0
- accelforge/plotting/mappings.py +219 -0
- accelforge/plotting/specs.py +57 -0
- accelforge/util/__init__.py +4 -0
- accelforge/util/_base_analysis_types.py +24 -0
- accelforge/util/_basetypes.py +1089 -0
- accelforge/util/_frozenset.py +36 -0
- accelforge/util/_isl.py +29 -0
- accelforge/util/_itertools.py +14 -0
- accelforge/util/_mathfuncs.py +57 -0
- accelforge/util/_parse_expressions.py +339 -0
- accelforge/util/_picklecache.py +32 -0
- accelforge/util/_setexpressions.py +268 -0
- accelforge/util/_sympy/__init__.py +0 -0
- accelforge/util/_sympy/broadcast_max.py +18 -0
- accelforge/util/_visualization.py +112 -0
- accelforge/util/_yaml.py +579 -0
- accelforge/util/parallel.py +193 -0
- accelforge-0.0.1.dist-info/METADATA +64 -0
- accelforge-0.0.1.dist-info/RECORD +258 -0
- accelforge-0.0.1.dist-info/WHEEL +5 -0
- accelforge-0.0.1.dist-info/licenses/LICENSE +19 -0
- accelforge-0.0.1.dist-info/top_level.txt +5 -0
- docs/_build/html/_sources/fastfusion.frontend.mapper.rst.txt +37 -0
- docs/_build/html/_sources/fastfusion.frontend.rst.txt +70 -0
- docs/_build/html/_sources/fastfusion.frontend.workload.rst.txt +21 -0
- docs/_build/html/_sources/fastfusion.mapper.FFM.rst.txt +37 -0
- docs/_build/html/_sources/fastfusion.mapper.rst.txt +18 -0
- docs/_build/html/_sources/fastfusion.rst.txt +20 -0
- docs/_build/html/_sources/fastfusion.util.rst.txt +21 -0
- docs/_build/html/_sources/index.rst.txt +87 -0
- docs/_build/html/_sources/modules.rst.txt +7 -0
- docs/_build/html/_sources/notes/citation.rst.txt +45 -0
- docs/_build/html/_sources/notes/definitions.rst.txt +43 -0
- docs/_build/html/_sources/notes/faqs.rst.txt +39 -0
- docs/_build/html/_sources/notes/modeling/accelerator_energy_latency.rst.txt +72 -0
- docs/_build/html/_sources/notes/modeling/component_energy_area.rst.txt +96 -0
- docs/_build/html/_sources/notes/modeling/mapping.rst.txt +100 -0
- docs/_build/html/_sources/notes/modeling.rst.txt +33 -0
- docs/_build/html/_sources/notes/parsing/arithmetic_parsing.rst.txt +136 -0
- docs/_build/html/_sources/notes/parsing/setexpressions.rst.txt +63 -0
- docs/_build/html/_sources/notes/parsing/yaml_parsing.rst.txt +176 -0
- docs/_build/html/_sources/notes/quickstart_and_installation.rst.txt +9 -0
- docs/_build/html/_sources/notes/spec/architecture.rst.txt +133 -0
- docs/_build/html/_sources/notes/spec/mapping.rst.txt +12 -0
- docs/_build/html/_sources/notes/spec/workload.rst.txt +83 -0
- docs/_build/html/_sources/notes/spec.rst.txt +36 -0
- docs/source/_ext/include_attrs.py +213 -0
- docs/source/_ext/include_docstring.py +364 -0
- docs/source/_ext/include_functions.py +154 -0
- docs/source/_ext/include_notebook.py +131 -0
- docs/source/_ext/include_yaml.py +119 -0
- docs/source/_ext/inherited_attributes.py +222 -0
- docs/source/_ext/paths.py +4 -0
- docs/source/conf.py +79 -0
- examples/arches/compute_in_memory/_include.yaml +74 -0
- examples/arches/compute_in_memory/_include_functions.py +229 -0
- examples/arches/compute_in_memory/_load_spec.py +57 -0
- examples/arches/compute_in_memory/components/c2c_multiplier.py +181 -0
- examples/arches/compute_in_memory/components/dac_c2c_r2r.py +605 -0
- examples/arches/compute_in_memory/components/misc.py +195 -0
- examples/arches/compute_in_memory/components/util/bit_functions.py +51 -0
- examples/arches/compute_in_memory/components/zero_comparator.py +92 -0
- examples/arches/compute_in_memory/isaac.yaml +233 -0
- examples/arches/compute_in_memory/memory_cells/ecram_demo.yaml +63 -0
- examples/arches/compute_in_memory/memory_cells/rram_example.yaml +63 -0
- examples/arches/compute_in_memory/memory_cells/rram_isaac_isca_2016.yaml +64 -0
- examples/arches/compute_in_memory/memory_cells/rram_neurosim_default.yaml +63 -0
- examples/arches/compute_in_memory/memory_cells/rram_raella_isca_2023.yaml +70 -0
- examples/arches/compute_in_memory/memory_cells/rram_wan_nature_2022.yaml +63 -0
- examples/arches/compute_in_memory/memory_cells/sram_colonnade_jssc_2021.yaml +63 -0
- examples/arches/compute_in_memory/memory_cells/sram_example.yaml +63 -0
- examples/arches/compute_in_memory/memory_cells/sram_jia_jssc_2020.yaml +63 -0
- examples/arches/compute_in_memory/memory_cells/sram_sinangil_jssc_2021.yaml +63 -0
- examples/arches/compute_in_memory/memory_cells/sram_wang_vlsi_2022.yaml +63 -0
- examples/arches/compute_in_memory/wang_vlsi_2022.yaml +289 -0
- examples/arches/eyeriss.yaml +68 -0
- examples/arches/fanout_variations/at_glb.yaml +31 -0
- examples/arches/fanout_variations/at_glb_with_fanout_node.yaml +34 -0
- examples/arches/fanout_variations/at_mac.yaml +31 -0
- examples/arches/fanout_variations/at_mac_with_constraints.yaml +38 -0
- examples/arches/fanout_variations/at_mac_with_fanout_node.yaml +34 -0
- examples/arches/nvdla.yaml +47 -0
- examples/arches/simple.yaml +28 -0
- examples/arches/tpu_v4i.yaml +67 -0
- examples/mappings/unfused_matmuls_to_simple.yaml +33 -0
- examples/misc/component_annotated.yaml +33 -0
- examples/workloads/gpt3_6.7B.yaml +124 -0
- examples/workloads/matmuls.yaml +20 -0
- examples/workloads/mobilenet_28.yaml +81 -0
- examples/workloads/mobilenet_various_separate.yaml +106 -0
- examples/workloads/three_matmuls_annotated.yaml +59 -0
- notebooks/.ipynb_checkpoints/fastfusion_arch_study_michael-checkpoint.ipynb +359 -0
- notebooks/compute_in_memory/_scripts.py +339 -0
- notebooks/compute_in_memory/isaac.guide.ipynb +270 -0
- notebooks/compute_in_memory/wang_vlsi_2022.ipynb +602 -0
- notebooks/paths.py +4 -0
- notebooks/tutorials/.ipynb_checkpoints/1_FFM-checkpoint.ipynb +3110 -0
- notebooks/tutorials/FFM.ipynb +3498 -0
- notebooks/tutorials/_include.py +48 -0
- notebooks/tutorials/component_energy_area.ipynb +363 -0
- tests/Q_mapping.yaml +38 -0
- tests/__init__.py +0 -0
- tests/conv.mapping.yaml +27 -0
- tests/conv.workload.yaml +13 -0
- tests/conv_sym.mapping.yaml +43 -0
- tests/copy.mapping.yaml +35 -0
- tests/copy.workload.yaml +15 -0
- tests/distribuffers/__init__.py +0 -0
- tests/distribuffers/multicast/test_cases.yaml +482 -0
- tests/distribuffers/spec/binding/valid_bindings.yaml +97 -0
- tests/distribuffers/spec/distributed.yaml +100 -0
- tests/distribuffers/spec/logical_arch.yaml +32 -0
- tests/distribuffers/spec/physical_arch.yaml +69 -0
- tests/distribuffers/test_binding.py +48 -0
- tests/frontend/__init__.py +0 -0
- tests/frontend/test_mapping_viz.py +52 -0
- tests/mapper/__init__.py +0 -0
- tests/mapper/configs/conv1d/conv1d.mapping.yaml +31 -0
- tests/mapper/configs/conv1d/conv1d.workload.yaml +11 -0
- tests/mapper/configs/two_conv1d/two_conv1d.expected.yaml +38 -0
- tests/mapper/configs/two_conv1d/two_conv1d.mapping.yaml +54 -0
- tests/mapper/configs/two_conv1d/two_conv1d.workload.yaml +19 -0
- tests/mapper/test_mapping_to_isl.py +90 -0
- tests/mapper/test_spatial_reuse_analysis.py +67 -0
- tests/mapper/test_temporal_reuse_analysis.py +56 -0
- tests/mapper/util.py +58 -0
- tests/matmul.mapping.yaml +29 -0
- tests/matmul.workload.yaml +12 -0
- tests/matmul_spatial.mapping.yaml +44 -0
- tests/mha.renames.yaml +65 -0
- tests/mha.workload.yaml +67 -0
- tests/mha.yaml +59 -0
- tests/mha_full.workload.yaml +67 -0
- tests/mobilenet.workload.yaml +35 -0
- tests/mobilenet_long.workload.yaml +64 -0
- tests/pmappingcache.py +24 -0
- tests/processing_stage.arch.yaml +40 -0
- tests/snowcat.arch.yaml +36 -0
- tests/test_ffm_join_pmappings.py +106 -0
- tests/test_ffm_make_pmappings.py +82 -0
- tests/test_ffm_make_tile_shapes.py +49 -0
- tests/test_mapper.py +100 -0
- tests/test_model.py +37 -0
- tests/test_plotting.py +72 -0
- tests/test_processing_stage.py +46 -0
- tests/test_symbolic_model.py +248 -0
- tests/test_workload.py +141 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
mapping:
|
|
2
|
+
nodes:
|
|
3
|
+
- !Storage
|
|
4
|
+
tensors: [T1, T0, W0]
|
|
5
|
+
component: MainMemory
|
|
6
|
+
- !Temporal
|
|
7
|
+
rank_variable: m
|
|
8
|
+
tile_shape: 64
|
|
9
|
+
- !Storage
|
|
10
|
+
tensors: [T1]
|
|
11
|
+
component: LocalBuffer
|
|
12
|
+
- !Spatial
|
|
13
|
+
rank_variable: n0
|
|
14
|
+
tile_shape: 8
|
|
15
|
+
name: 0
|
|
16
|
+
component: LocalBuffer
|
|
17
|
+
- !Spatial
|
|
18
|
+
rank_variable: n0
|
|
19
|
+
tile_shape: 2
|
|
20
|
+
name: 1
|
|
21
|
+
component: LocalBuffer
|
|
22
|
+
- !Spatial
|
|
23
|
+
rank_variable: n1
|
|
24
|
+
tile_shape: 8
|
|
25
|
+
name: 0
|
|
26
|
+
component: LocalBuffer
|
|
27
|
+
- !Temporal
|
|
28
|
+
rank_variable: n0
|
|
29
|
+
tile_shape: 1
|
|
30
|
+
- !Storage
|
|
31
|
+
tensors: [T0]
|
|
32
|
+
component: LocalBuffer
|
|
33
|
+
- !Temporal
|
|
34
|
+
rank_variable: n1
|
|
35
|
+
tile_shape: 1
|
|
36
|
+
- !Storage
|
|
37
|
+
tensors: [W0]
|
|
38
|
+
component: LocalBuffer
|
|
39
|
+
- !Temporal
|
|
40
|
+
rank_variable: m
|
|
41
|
+
tile_shape: 1
|
|
42
|
+
- !Compute
|
|
43
|
+
einsum: Matmul1
|
|
44
|
+
compute: MAC
|
tests/mha.renames.yaml
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
renames:
|
|
2
|
+
einsums:
|
|
3
|
+
- name: default
|
|
4
|
+
tensor_accesses:
|
|
5
|
+
- name: input
|
|
6
|
+
source: Inputs & Intermediates
|
|
7
|
+
expected_count: 1
|
|
8
|
+
- name: output
|
|
9
|
+
source: Outputs
|
|
10
|
+
expected_count: 1
|
|
11
|
+
- name: weight
|
|
12
|
+
source: ~(input | output)
|
|
13
|
+
expected_count: 1
|
|
14
|
+
|
|
15
|
+
rank_variables:
|
|
16
|
+
- name: head
|
|
17
|
+
source: h
|
|
18
|
+
expected_count: 1
|
|
19
|
+
- name: parallel_rank
|
|
20
|
+
source: (output.rank_variables & weight.rank_variables) - head
|
|
21
|
+
expected_count: 1
|
|
22
|
+
- name: reduced_rank
|
|
23
|
+
source: input.rank_variables & weight.rank_variables - head - output.rank_variables - parallel_rank
|
|
24
|
+
expected_count: 1
|
|
25
|
+
|
|
26
|
+
- name: I
|
|
27
|
+
tensor_accesses:
|
|
28
|
+
- name: weight
|
|
29
|
+
source: Nothing
|
|
30
|
+
- name: input
|
|
31
|
+
source: Inputs
|
|
32
|
+
{% if FFMT | default(false) %}
|
|
33
|
+
- name: Intermediates
|
|
34
|
+
source: Nothing
|
|
35
|
+
{% endif %}
|
|
36
|
+
rank_variables:
|
|
37
|
+
- {name: head, source: Nothing.rank_variables}
|
|
38
|
+
- {name: reduced_rank, source: b, expected_count: 1}
|
|
39
|
+
- {name: parallel_rank, source: m, expected_count: 1}
|
|
40
|
+
|
|
41
|
+
- name: QK
|
|
42
|
+
tensor_accesses:
|
|
43
|
+
- name: input
|
|
44
|
+
source: Q
|
|
45
|
+
expected_count: 1
|
|
46
|
+
rank_variables:
|
|
47
|
+
- {name: parallel_rank, source: m, expected_count: 1}
|
|
48
|
+
|
|
49
|
+
- name: AV
|
|
50
|
+
tensor_accesses:
|
|
51
|
+
- name: input
|
|
52
|
+
source: QK
|
|
53
|
+
expected_count: 1
|
|
54
|
+
rank_variables:
|
|
55
|
+
- {name: parallel_rank, source: f, expected_count: 1}
|
|
56
|
+
# - {name: reduced_rank, source: p, expected_count: 1}
|
|
57
|
+
|
|
58
|
+
- name: FFA
|
|
59
|
+
rank_variables:
|
|
60
|
+
- {name: head, source: Nothing.rank_variables}
|
|
61
|
+
|
|
62
|
+
- name: FFB
|
|
63
|
+
rank_variables:
|
|
64
|
+
- {name: head, source: Nothing.rank_variables}
|
|
65
|
+
|
tests/mha.workload.yaml
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
workload:
|
|
2
|
+
shape:
|
|
3
|
+
b: 0 <= b < 2
|
|
4
|
+
m: 0 <= m < 2
|
|
5
|
+
p: 0 <= p < 2
|
|
6
|
+
h: 0 <= h < 2
|
|
7
|
+
e: 0 <= e < 2
|
|
8
|
+
f: 0 <= f < 2
|
|
9
|
+
d: 0 <= d < 4
|
|
10
|
+
c: 0 <= c < 1
|
|
11
|
+
j: 0 <= j < 1
|
|
12
|
+
g: 0 <= g < 1
|
|
13
|
+
|
|
14
|
+
einsums:
|
|
15
|
+
- name: I
|
|
16
|
+
is_copy_operation: True
|
|
17
|
+
tensor_accesses:
|
|
18
|
+
- {name: I_in, projection: [b, m, d]}
|
|
19
|
+
- {name: I, projection: [b, m, d], output: True}
|
|
20
|
+
|
|
21
|
+
- name: V
|
|
22
|
+
tensor_accesses:
|
|
23
|
+
- {name: I, projection: [ b, m, d ]}
|
|
24
|
+
- {name: WV, projection: [ h, e, d ]}
|
|
25
|
+
- {name: V, projection: [ b, m, h, e ], output: True}
|
|
26
|
+
|
|
27
|
+
- name: K
|
|
28
|
+
tensor_accesses:
|
|
29
|
+
- {name: I, projection: [ b, m, d ]}
|
|
30
|
+
- {name: WK, projection: [ h, e, d ]}
|
|
31
|
+
- {name: K, projection: [ b, m, h, e ], output: True}
|
|
32
|
+
|
|
33
|
+
- name: Q
|
|
34
|
+
tensor_accesses:
|
|
35
|
+
- {name: I, projection: [ b, m, d ]}
|
|
36
|
+
- {name: WQ, projection: [ h, e, d ]}
|
|
37
|
+
- {name: Q, projection: [ b, m, h, e ], output: True}
|
|
38
|
+
|
|
39
|
+
- name: QK
|
|
40
|
+
tensor_accesses:
|
|
41
|
+
- {name: Q, projection: [ b, m, h, e ]}
|
|
42
|
+
- {name: K, projection: { B: b, M: p, H: h, E: e }}
|
|
43
|
+
- {name: QK, projection: [ b, m, p, h ], output: True}
|
|
44
|
+
|
|
45
|
+
- name: AV
|
|
46
|
+
tensor_accesses:
|
|
47
|
+
- {name: QK, projection: [ b, m, p, h ]}
|
|
48
|
+
- {name: V, projection: { B: b, M: p, H: h, E: f}}
|
|
49
|
+
- {name: AV, projection: [ b, m, h, f ], output: True}
|
|
50
|
+
|
|
51
|
+
- name: Z
|
|
52
|
+
tensor_accesses:
|
|
53
|
+
- {name: AV, projection: [ b, m, h, f ]}
|
|
54
|
+
- {name: WZ, projection: [ h, f, g ]}
|
|
55
|
+
- {name: Z, projection: [ b, m, g ], output: True}
|
|
56
|
+
|
|
57
|
+
- name: FFA
|
|
58
|
+
tensor_accesses:
|
|
59
|
+
- {name: Z, projection: [ b, m, g ]}
|
|
60
|
+
- {name: WFFA, projection: [ g, c ]}
|
|
61
|
+
- {name: FFA, projection: [ b, m, c ], output: True}
|
|
62
|
+
|
|
63
|
+
- name: FFB
|
|
64
|
+
tensor_accesses:
|
|
65
|
+
- {name: FFA, projection: [ b, m, c ]}
|
|
66
|
+
- {name: WFFB, projection: [ c, j ]}
|
|
67
|
+
- {name: FFB, projection: [ b, m, j ], output: True}
|
tests/mha.yaml
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
workload:
|
|
2
|
+
shape:
|
|
3
|
+
b: 0 <= b < 2
|
|
4
|
+
m: 0 <= m < 2
|
|
5
|
+
h: 0 <= h < 2
|
|
6
|
+
e: 0 <= e < 2
|
|
7
|
+
d: 0 <= d < 4
|
|
8
|
+
c: 0 <= c < 1
|
|
9
|
+
j: 0 <= j < 1
|
|
10
|
+
g: 0 <= g < 1
|
|
11
|
+
|
|
12
|
+
einsums:
|
|
13
|
+
- name: V
|
|
14
|
+
tensor_accesses:
|
|
15
|
+
- {name: I, projection: [ b, m, d ]}
|
|
16
|
+
- {name: WV, projection: [ h, e, d ]}
|
|
17
|
+
- {name: V, projection: [ b, m, h, e ], output: True}
|
|
18
|
+
|
|
19
|
+
- name: K
|
|
20
|
+
tensor_accesses:
|
|
21
|
+
- {name: I, projection: [ b, m, d ]}
|
|
22
|
+
- {name: WK, projection: [ h, e, d ]}
|
|
23
|
+
- {name: K, projection: [ b, m, h, e ], output: True}
|
|
24
|
+
|
|
25
|
+
- name: Q
|
|
26
|
+
tensor_accesses:
|
|
27
|
+
- {name: I, projection: [ b, m, d ]}
|
|
28
|
+
- {name: WQ, projection: [ h, e, d ]}
|
|
29
|
+
- {name: Q, projection: [ b, m, h, e ], output: True}
|
|
30
|
+
|
|
31
|
+
- name: QK
|
|
32
|
+
tensor_accesses:
|
|
33
|
+
- {name: Q, projection: [ b, m, h, e ]}
|
|
34
|
+
- {name: K, projection: { B: b, M: P, H: h, E: e }}
|
|
35
|
+
- {name: QK, projection: [ b, m, P, h ], output: True}
|
|
36
|
+
|
|
37
|
+
- name: AV
|
|
38
|
+
tensor_accesses:
|
|
39
|
+
- {name: QK, projection: [ b, m, p, h ]}
|
|
40
|
+
- {name: V, projection: { B: b, M: p, H: h, E: f}}
|
|
41
|
+
- {name: AV, projection: [ b, m, h, f ], output: True}
|
|
42
|
+
|
|
43
|
+
- name: Z
|
|
44
|
+
tensor_accesses:
|
|
45
|
+
- {name: AV, projection: [ b, m, h, F ]}
|
|
46
|
+
- {name: WZ, projection: [ h, F, g ]}
|
|
47
|
+
- {name: Z, projection: [ b, m, g ], output: True}
|
|
48
|
+
|
|
49
|
+
- name: FFA
|
|
50
|
+
tensor_accesses:
|
|
51
|
+
- {name: Z, projection: [ b, m, g ]}
|
|
52
|
+
- {name: WFFA, projection: [ g, c ]}
|
|
53
|
+
- {name: FFA, projection: [ b, m, c ], output: True}
|
|
54
|
+
|
|
55
|
+
- name: FFB
|
|
56
|
+
tensor_accesses:
|
|
57
|
+
- {name: FFA, projection: [ b, m, c ]}
|
|
58
|
+
- {name: WFFB, projection: [ c, j ]}
|
|
59
|
+
- {name: FFB, projection: [ b, m, j ], output: True}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
workload:
|
|
2
|
+
shape:
|
|
3
|
+
b: 0 <= b < 1
|
|
4
|
+
m: 0 <= m < 128
|
|
5
|
+
p: 0 <= p < 128 # = m
|
|
6
|
+
h: 0 <= h < 8
|
|
7
|
+
e: 0 <= e < 32
|
|
8
|
+
f: 0 <= f < 32
|
|
9
|
+
d: 0 <= d < 256 # = e * h
|
|
10
|
+
c: 0 <= c < 1024
|
|
11
|
+
j: 0 <= j < 256
|
|
12
|
+
g: 0 <= g < 256
|
|
13
|
+
|
|
14
|
+
einsums:
|
|
15
|
+
- name: I
|
|
16
|
+
is_copy_operation: True
|
|
17
|
+
tensor_accesses:
|
|
18
|
+
- {name: I_in, projection: [b, m, d]}
|
|
19
|
+
- {name: I, projection: [b, m, d], output: True}
|
|
20
|
+
|
|
21
|
+
- name: V
|
|
22
|
+
tensor_accesses:
|
|
23
|
+
- {name: I, projection: [b, m, d]}
|
|
24
|
+
- {name: WV, projection: [h, e, d]}
|
|
25
|
+
- {name: V, projection: [b, m, h, e], output: True}
|
|
26
|
+
|
|
27
|
+
- name: K
|
|
28
|
+
tensor_accesses:
|
|
29
|
+
- {name: I, projection: [b, m, d]}
|
|
30
|
+
- {name: WK, projection: [h, e, d]}
|
|
31
|
+
- {name: K, projection: [b, m, h, e], output: True}
|
|
32
|
+
|
|
33
|
+
- name: Q
|
|
34
|
+
tensor_accesses:
|
|
35
|
+
- {name: I, projection: [b, m, d]}
|
|
36
|
+
- {name: WQ, projection: [h, e, d]}
|
|
37
|
+
- {name: Q, projection: [b, m, h, e], output: True}
|
|
38
|
+
|
|
39
|
+
- name: QK
|
|
40
|
+
tensor_accesses:
|
|
41
|
+
- {name: Q, projection: [b, m, h, e]}
|
|
42
|
+
- {name: K, projection: { B: b, M: p, H: h, E: e }}
|
|
43
|
+
- {name: QK, projection: [b, m, p, h], output: True}
|
|
44
|
+
|
|
45
|
+
- name: AV
|
|
46
|
+
tensor_accesses:
|
|
47
|
+
- {name: QK, projection: [b, m, p, h]}
|
|
48
|
+
- {name: V, projection: { B: b, M: p, H: h, E: f}}
|
|
49
|
+
- {name: AV, projection: [b, m, h, f], output: True}
|
|
50
|
+
|
|
51
|
+
- name: Z
|
|
52
|
+
tensor_accesses:
|
|
53
|
+
- {name: AV, projection: [b, m, h, f]}
|
|
54
|
+
- {name: WZ, projection: [h, f, g]}
|
|
55
|
+
- {name: Z, projection: [b, m, g], output: True}
|
|
56
|
+
|
|
57
|
+
- name: FFA
|
|
58
|
+
tensor_accesses:
|
|
59
|
+
- {name: Z, projection: [b, m, g]}
|
|
60
|
+
- {name: WFFA, projection: [g, c]}
|
|
61
|
+
- {name: FFA, projection: [b, m, c], output: True}
|
|
62
|
+
|
|
63
|
+
- name: FFB
|
|
64
|
+
tensor_accesses:
|
|
65
|
+
- {name: FFA, projection: [b, m, c]}
|
|
66
|
+
- {name: WFFB, projection: [c, j]}
|
|
67
|
+
- {name: FFB, projection: [b, m, j], output: True}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
workload:
|
|
2
|
+
shape:
|
|
3
|
+
pa0: 0 <= pa0 < 25
|
|
4
|
+
qa0: 0 <= qa0 < 25
|
|
5
|
+
pb0: 0 <= pb0 < 25
|
|
6
|
+
qb0: 0 <= qb0 < 25
|
|
7
|
+
n0: 0 <= n0 < 2
|
|
8
|
+
t0: 0 <= t0 < 4
|
|
9
|
+
n1: 0 <= n1 < 2
|
|
10
|
+
|
|
11
|
+
einsums:
|
|
12
|
+
- name: PiecewiseA0
|
|
13
|
+
tensor_accesses:
|
|
14
|
+
- {name: T0, projection: [pa0, qa0, n0]}
|
|
15
|
+
- {name: WA0, projection: [n0, t0]}
|
|
16
|
+
- {name: TA0, projection: [pa0, qa0, t0], output: True}
|
|
17
|
+
|
|
18
|
+
- name: Depthwise0
|
|
19
|
+
tensor_accesses:
|
|
20
|
+
- name: TA0
|
|
21
|
+
projection:
|
|
22
|
+
PA0: pb0 + r0
|
|
23
|
+
QA0: qb0 + s0
|
|
24
|
+
T0: t0
|
|
25
|
+
- {name: WAB0, projection: [r0, s0, t0]}
|
|
26
|
+
- {name: TB0, projection: [pb0, qb0, t0], output: True}
|
|
27
|
+
shape:
|
|
28
|
+
- 0 <= r0 < 3
|
|
29
|
+
- 0 <= s0 < 3
|
|
30
|
+
|
|
31
|
+
- name: PiecewiseB0
|
|
32
|
+
tensor_accesses:
|
|
33
|
+
- {name: TB0, projection: [pb0, qb0, t0]}
|
|
34
|
+
- {name: WB0, projection: [t0, n1]}
|
|
35
|
+
- {name: T1, projection: [pb0, qb0, n1], output: True}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
workload:
|
|
2
|
+
shape:
|
|
3
|
+
p0: 0 <= p0 < 7
|
|
4
|
+
q0: 0 <= q0 < 7
|
|
5
|
+
n0: 0 <= n0 < 2
|
|
6
|
+
t0: 0 <= t0 < 4
|
|
7
|
+
n1: 0 <= n1 < 2
|
|
8
|
+
p1: 0 <= p1 < 7
|
|
9
|
+
q1: 0 <= q1 < 7
|
|
10
|
+
p2: 0 <= p2 < 7
|
|
11
|
+
q2: 0 <= q2 < 7
|
|
12
|
+
t1: 0 <= t1 < 4
|
|
13
|
+
n2: 0 <= n2 < 2
|
|
14
|
+
|
|
15
|
+
einsums:
|
|
16
|
+
- name: PiecewiseA0
|
|
17
|
+
tensor_accesses:
|
|
18
|
+
- {name: T0, projection: [p0, q0, n0]}
|
|
19
|
+
- {name: WA0, projection: [n0, t0]}
|
|
20
|
+
- {name: TA0, projection: [p0, q0, t0], output: True}
|
|
21
|
+
|
|
22
|
+
- name: Depthwise0
|
|
23
|
+
tensor_accesses:
|
|
24
|
+
- name: TA0
|
|
25
|
+
projection:
|
|
26
|
+
P0: p1 + r0
|
|
27
|
+
Q0: q1 + s0
|
|
28
|
+
T0: t0
|
|
29
|
+
- {name: WAB0, projection: [r0, s0, t0]}
|
|
30
|
+
- {name: TB0, projection: [p1, q1, t0], output: True}
|
|
31
|
+
shape:
|
|
32
|
+
- 0 <= r0 < 3
|
|
33
|
+
- 0 <= s0 < 3
|
|
34
|
+
|
|
35
|
+
- name: PiecewiseB0
|
|
36
|
+
tensor_accesses:
|
|
37
|
+
- {name: TB0, projection: [p1, q1, t0]}
|
|
38
|
+
- {name: WB0, projection: [t0, n1]}
|
|
39
|
+
- {name: T1, projection: [p1, q1, n1], output: True}
|
|
40
|
+
|
|
41
|
+
- name: PiecewiseA1
|
|
42
|
+
tensor_accesses:
|
|
43
|
+
- {name: T1, projection: [p1, q1, n1]}
|
|
44
|
+
- {name: WA1, projection: [n1, t1]}
|
|
45
|
+
- {name: TA1, projection: [p1, q1, t1], output: True}
|
|
46
|
+
|
|
47
|
+
- name: Depthwise1
|
|
48
|
+
tensor_accesses:
|
|
49
|
+
- name: TA1
|
|
50
|
+
projection:
|
|
51
|
+
P1: p2 + r1
|
|
52
|
+
Q1: q2 + s1
|
|
53
|
+
T1: t1
|
|
54
|
+
- {name: WAB1, projection: [r1, s1, t1]}
|
|
55
|
+
- {name: TB1, projection: [p2, q2, t1], output: True}
|
|
56
|
+
shape:
|
|
57
|
+
- 0 <= r1 < 3
|
|
58
|
+
- 0 <= s1 < 3
|
|
59
|
+
|
|
60
|
+
- name: PiecewiseB2
|
|
61
|
+
tensor_accesses:
|
|
62
|
+
- {name: TB1, projection: [p2, q2, t1]}
|
|
63
|
+
- {name: WB1, projection: [t1, n2]}
|
|
64
|
+
- {name: T2, projection: [p2, q2, n2], output: True}
|
tests/pmappingcache.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from collections.abc import Iterable
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from accelforge.util._picklecache import PickleCache
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
TEST_PmappingGroup_DIR = Path(__file__).parent / "tmp" / "pmapping_cache"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def make_pmapping_pickle_cache(config_names: Iterable[str]) -> PickleCache:
|
|
11
|
+
"""
|
|
12
|
+
Return a `PickleCache` using path generated by `make_pmapping_pickle_path`.
|
|
13
|
+
"""
|
|
14
|
+
return PickleCache(make_pmapping_pickle_path(config_names))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def make_pmapping_pickle_path(config_names: Iterable[str]) -> Path:
|
|
18
|
+
"""
|
|
19
|
+
Creates a path to a file in `TEST_PmappingGroup_DIR` with a file name that is
|
|
20
|
+
`config_names` joined using "---" as separators.
|
|
21
|
+
"""
|
|
22
|
+
pickle_name = "---".join(sorted(config_names)) + ".pkl"
|
|
23
|
+
pickle_path = TEST_PmappingGroup_DIR / pickle_name
|
|
24
|
+
return pickle_path
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
arch:
|
|
2
|
+
nodes:
|
|
3
|
+
- !Memory
|
|
4
|
+
name: main_memory
|
|
5
|
+
attributes:
|
|
6
|
+
_size: 1e9
|
|
7
|
+
_datawidth: 8
|
|
8
|
+
tensors: {keep: All}
|
|
9
|
+
actions:
|
|
10
|
+
- {name: read, arguments: {_energy: 0}}
|
|
11
|
+
- {name: write, arguments: {_energy: 0}}
|
|
12
|
+
- {name: leak, arguments: {_energy: 0}}
|
|
13
|
+
|
|
14
|
+
- !ProcessingStage
|
|
15
|
+
name: ProcessingStage
|
|
16
|
+
attributes:
|
|
17
|
+
_datawidth: 8
|
|
18
|
+
_direction: up_and_down
|
|
19
|
+
tensors: {keep: All}
|
|
20
|
+
actions:
|
|
21
|
+
- {name: read, arguments: {_energy: 100}}
|
|
22
|
+
- {name: write, arguments: {_energy: 0}}
|
|
23
|
+
- {name: leak, arguments: {_energy: 0}}
|
|
24
|
+
|
|
25
|
+
- !Memory
|
|
26
|
+
name: LocalBuffer
|
|
27
|
+
attributes:
|
|
28
|
+
_size: 1e9
|
|
29
|
+
_datawidth: 8
|
|
30
|
+
tensors: {keep: All}
|
|
31
|
+
actions:
|
|
32
|
+
- {name: read, arguments: {_energy: 0}}
|
|
33
|
+
- {name: write, arguments: {_energy: 0}}
|
|
34
|
+
- {name: leak, arguments: {_energy: 0}}
|
|
35
|
+
|
|
36
|
+
- !Compute
|
|
37
|
+
name: mac
|
|
38
|
+
actions:
|
|
39
|
+
- {name: compute, arguments: {_energy: 0.0}}
|
|
40
|
+
- {name: leak, arguments: {_energy: 0}}
|
tests/snowcat.arch.yaml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
variables:
|
|
2
|
+
tech_node: 7e-9
|
|
3
|
+
|
|
4
|
+
arch:
|
|
5
|
+
nodes:
|
|
6
|
+
- !Memory
|
|
7
|
+
name: MainMemory
|
|
8
|
+
component_class: DRAM
|
|
9
|
+
attributes:
|
|
10
|
+
size: 9999999999999
|
|
11
|
+
area: 1
|
|
12
|
+
tensors: {keep: ~Intermediates, may_keep: Intermediates}
|
|
13
|
+
actions:
|
|
14
|
+
- {name: read, arguments: {_energy: 1}}
|
|
15
|
+
- {name: write, arguments: {_energy: 1}}
|
|
16
|
+
- {name: leak, arguments: {_energy: 0}}
|
|
17
|
+
|
|
18
|
+
- !Memory
|
|
19
|
+
name: GlobalBuffer
|
|
20
|
+
component_class: SRAM
|
|
21
|
+
attributes:
|
|
22
|
+
size: 9999999999999
|
|
23
|
+
area: 1
|
|
24
|
+
tensors: {keep: All}
|
|
25
|
+
actions:
|
|
26
|
+
- {name: read, arguments: {_energy: 0}}
|
|
27
|
+
- {name: write, arguments: {_energy: 0}}
|
|
28
|
+
- {name: leak, arguments: {_energy: 0}}
|
|
29
|
+
|
|
30
|
+
- !Compute
|
|
31
|
+
name: MAC
|
|
32
|
+
component_class: intmac
|
|
33
|
+
attributes: {area: 1}
|
|
34
|
+
actions:
|
|
35
|
+
- {name: compute, arguments: {_energy: 0}}
|
|
36
|
+
- {name: leak, arguments: {_energy: 0}}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import pickle
|
|
3
|
+
import unittest
|
|
4
|
+
|
|
5
|
+
from accelforge.frontend import Spec
|
|
6
|
+
from accelforge.mapper.FFM._make_pmappings.make_pmappings import make_pmappings
|
|
7
|
+
from accelforge.mapper.FFM._join_pmappings.compatibility_util import (
|
|
8
|
+
join_compatibilities,
|
|
9
|
+
pmappings2untiled_compatibilities,
|
|
10
|
+
)
|
|
11
|
+
from accelforge.mapper.FFM._join_pmappings.join_pmappings import join_pmappings
|
|
12
|
+
|
|
13
|
+
from pmappingcache import make_pmapping_pickle_cache
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
PARENT_DIR = Path(__file__).parent
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class TestPreJoin(unittest.TestCase):
|
|
20
|
+
def test_mha_full(self):
|
|
21
|
+
config_names = ["snowcat.arch", "mha_full.workload", "mha.renames"]
|
|
22
|
+
paths = [PARENT_DIR / f"{config_name}.yaml" for config_name in config_names]
|
|
23
|
+
spec = Spec.from_yaml(*paths)
|
|
24
|
+
flattened_arch = spec._get_flattened_architecture()
|
|
25
|
+
|
|
26
|
+
pmapping_cache = make_pmapping_pickle_cache(config_names)
|
|
27
|
+
pmapping_groups, decompress_data = pmapping_cache.get(
|
|
28
|
+
lambda: make_pmappings(spec, flattened_arch)
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
untiled_compats = pmappings2untiled_compatibilities(pmapping_groups)
|
|
32
|
+
einsum2important_compats = join_compatibilities(untiled_compats, spec)
|
|
33
|
+
|
|
34
|
+
for einsum, compats in untiled_compats.items():
|
|
35
|
+
before_size = sum(
|
|
36
|
+
len(pm.mappings.data.index) for pm in pmapping_groups[einsum]
|
|
37
|
+
)
|
|
38
|
+
after_size = sum(
|
|
39
|
+
len(pm.mappings.data.index) for pm in einsum2pruned_pmappings[einsum]
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
print(
|
|
43
|
+
f"{einsum} has {len(einsum2important_compats[einsum])}"
|
|
44
|
+
f"/{len(compats)} compatibilities left and "
|
|
45
|
+
f"{after_size}/{before_size} pmappings left."
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class TestJoin(unittest.TestCase):
|
|
50
|
+
def test_mha(self):
|
|
51
|
+
spec = Spec.from_yaml(
|
|
52
|
+
PARENT_DIR / "four_level.arch.yaml",
|
|
53
|
+
PARENT_DIR / "mha.workload.yaml",
|
|
54
|
+
PARENT_DIR / "mha.renames.yaml",
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
flattened_arch = spec._get_flattened_architecture()
|
|
58
|
+
pmapping_groups, decompress_data = make_pmappings(spec, flattened_arch)
|
|
59
|
+
mappings = join_pmappings(
|
|
60
|
+
pmapping_groups, spec, flattened_arch, drop_valid_reservations=False
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
def test_mha_full(self):
|
|
64
|
+
config_names = ["snowcat.arch", "mha_full.workload", "mha.renames"]
|
|
65
|
+
paths = [PARENT_DIR / f"{config_name}.yaml" for config_name in config_names]
|
|
66
|
+
spec = Spec.from_yaml(*paths)
|
|
67
|
+
flattened_arch = spec._get_flattened_architecture()
|
|
68
|
+
|
|
69
|
+
pmapping_cache = make_pmapping_pickle_cache(config_names)
|
|
70
|
+
pmapping_groups, decompress_data = pmapping_cache.get(
|
|
71
|
+
lambda: make_pmappings(spec, flattened_arch)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
mappings = join_pmappings(pmapping_groups, spec, flattened_arch)
|
|
75
|
+
|
|
76
|
+
def test_mha_full_with_prejoin_pruning(self):
|
|
77
|
+
config_names = ["snowcat.arch", "mha_full.workload", "mha.renames"]
|
|
78
|
+
paths = [PARENT_DIR / f"{config_name}.yaml" for config_name in config_names]
|
|
79
|
+
spec = Spec.from_yaml(*paths)
|
|
80
|
+
flattened_arch = spec._get_flattened_architecture()
|
|
81
|
+
|
|
82
|
+
pmapping_cache = make_pmapping_pickle_cache(config_names)
|
|
83
|
+
pmapping_groups, decompress_data = pmapping_cache.get(
|
|
84
|
+
lambda: make_pmappings(spec, flattened_arch)
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
untiled_compats = pmappings2untiled_compatibilities(pmapping_groups)
|
|
88
|
+
einsum2important_compats = join_compatibilities(untiled_compats, spec)
|
|
89
|
+
|
|
90
|
+
mappings = join_pmappings(einsum2pruned_pmappings, spec, flattened_arch)
|
|
91
|
+
|
|
92
|
+
def test_mobilenet(self):
|
|
93
|
+
config_names = [
|
|
94
|
+
"snowcat.arch",
|
|
95
|
+
"mobilenet_long.workload",
|
|
96
|
+
]
|
|
97
|
+
paths = [PARENT_DIR / f"{config_name}.yaml" for config_name in config_names]
|
|
98
|
+
spec = Spec.from_yaml(*paths)
|
|
99
|
+
flattened_arch = spec._get_flattened_architecture()
|
|
100
|
+
|
|
101
|
+
pmapping_cache = make_pmapping_pickle_cache(config_names)
|
|
102
|
+
pmapping_groups, decompress_data = pmapping_cache.get(
|
|
103
|
+
lambda: make_pmappings(spec)
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
mappings = join_pmappings(pmapping_groups, spec, flattened_arch)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import unittest
|
|
3
|
+
|
|
4
|
+
from accelforge.frontend import Spec, Workload
|
|
5
|
+
|
|
6
|
+
from accelforge.mapper import Metrics
|
|
7
|
+
from accelforge.mapper.FFM import make_pmappings
|
|
8
|
+
from accelforge.mapper.FFM._make_pmappings.make_pmappings import make_pmappings
|
|
9
|
+
from accelforge.mapper.FFM._join_pmappings.pmapping_dataframe import nameloop2col
|
|
10
|
+
|
|
11
|
+
from pmappingcache import make_pmapping_pickle_cache
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
PARENT_DIR = Path(__file__).parent
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TestPmappingExploration(unittest.TestCase):
|
|
18
|
+
def test_mha(self):
|
|
19
|
+
spec = Spec.from_yaml(
|
|
20
|
+
PARENT_DIR / "four_level.arch.yaml",
|
|
21
|
+
PARENT_DIR / "mha.workload.yaml",
|
|
22
|
+
PARENT_DIR / "mha.renames.yaml",
|
|
23
|
+
)
|
|
24
|
+
spec.mapper.ffm.metrics = Metrics.ENERGY | Metrics.LATENCY
|
|
25
|
+
pmappings = make_pmappings(spec, ["Q"])
|
|
26
|
+
|
|
27
|
+
def test_mha_full(self):
|
|
28
|
+
config_names = ["snowcat.arch", "mha_full.workload", "mha.renames"]
|
|
29
|
+
paths = [PARENT_DIR / f"{config_name}.yaml" for config_name in config_names]
|
|
30
|
+
spec = Spec.from_yaml(*paths)
|
|
31
|
+
|
|
32
|
+
pmapping_cache = make_pmapping_pickle_cache(config_names)
|
|
33
|
+
|
|
34
|
+
pmapping_groups, decompress_data = pmapping_cache.set(make_pmappings(spec))
|
|
35
|
+
for per_einsum_pmappings in pmapping_groups.values():
|
|
36
|
+
for pmapping_group in per_einsum_pmappings:
|
|
37
|
+
for (
|
|
38
|
+
resource,
|
|
39
|
+
levels,
|
|
40
|
+
) in pmapping_group.mappings.right_reservations.items():
|
|
41
|
+
for level in levels:
|
|
42
|
+
self.assertTrue(
|
|
43
|
+
nameloop2col(resource, level)
|
|
44
|
+
in pmapping_group.mappings.data.columns,
|
|
45
|
+
f"{resource} at {level} not in {pmapping_group.mappings.data.columns}. Compatibility: {pmapping_group.compatibility}",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def test_mha_with_tags(self):
|
|
49
|
+
spec = Spec.from_yaml(
|
|
50
|
+
PARENT_DIR / "four_level.arch.yaml",
|
|
51
|
+
PARENT_DIR / "mha.workload.yaml",
|
|
52
|
+
PARENT_DIR / "mha.renames.yaml",
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
pmapping_groups, decompress_data = make_pmappings(spec, einsum_names=["Q"])
|
|
56
|
+
|
|
57
|
+
def test_conv_with_snowcat(self):
|
|
58
|
+
spec = Spec.from_yaml(
|
|
59
|
+
PARENT_DIR / "snowcat.arch.yaml",
|
|
60
|
+
PARENT_DIR / "mobilenet_long.workload.yaml",
|
|
61
|
+
)
|
|
62
|
+
config_names = [
|
|
63
|
+
"snowcat.arch",
|
|
64
|
+
"mobilenet_long.workload",
|
|
65
|
+
]
|
|
66
|
+
paths = [PARENT_DIR / f"{config_name}.yaml" for config_name in config_names]
|
|
67
|
+
spec = Spec.from_yaml(*paths)
|
|
68
|
+
|
|
69
|
+
pmapping_cache = make_pmapping_pickle_cache(config_names)
|
|
70
|
+
|
|
71
|
+
pmapping_groups, decompress_data = pmapping_cache.set(make_pmappings(spec))
|
|
72
|
+
for per_einsum_pmappings in pmapping_groups.values():
|
|
73
|
+
for pmapping_group in per_einsum_pmappings:
|
|
74
|
+
print(pmapping_group.compatibility)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class TestInitialDeltaGeneration(unittest.TestCase):
|
|
78
|
+
def test_mobilenet_long(self):
|
|
79
|
+
workload = Workload.from_yaml(
|
|
80
|
+
Path(__file__).parent / "mobilenet_long.workload.yaml"
|
|
81
|
+
)
|
|
82
|
+
choices = get_initial_delta_choices("Dwise0", workload)
|