-
Notifications
You must be signed in to change notification settings - Fork 149
[F2Dace] Copy over the Fortran frontend from f2dace/dev branch and merge it into main branch. #2147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 35 commits
72742bd
cedc7cf
cdd490c
80fbc35
bf47282
793afb0
c04d9e7
6e0f83c
a2fb0bc
9dc4672
abc074b
bdea1ab
086c431
bfc5678
def6c9e
4fe2db3
7d1a990
654b727
e849865
82845dc
341bacd
4d81233
72c86c7
21b05ef
f841298
c541615
b253ad0
46bc426
bcbc02c
6e5e91e
0a320e7
063b810
1fbfb8b
75e4750
1d34b0c
440ce14
36cdb3d
4a65b52
a2edcb3
8a6f752
a7cbaf6
0e64842
59efefb
07d2b35
c71830f
e5ae5e9
b49527d
a78e466
5322bbb
5023237
ce608f6
afc23c6
a5c4770
63d3f1e
f1759f4
0e5f11b
e31eba4
72d19ed
203bf5a
42cb8c6
6cb1dcd
e9a3c52
192a55d
2580654
d5d151d
4757ffd
f6f19ec
cf2b121
2c24410
0bf3b4a
cfa606d
3de93a4
add2d46
f906d65
4397936
177dd69
0d72c8f
41ee552
94d44d7
b597a29
b4455a7
1350ba6
362d423
819f0e9
b06f389
2f29e38
fd59cf0
9efd66f
60a36f2
c95817e
ed0170c
c3fa1ef
0192dfc
67e7c45
160a06d
76b4be1
44b6b63
3c65e4e
54cde00
253d165
3a4b2f8
c001d49
9f36d92
879cbc8
e26b1f7
bb7a07e
6951c0d
f66b024
a414283
4ebe934
7dece8c
ecc5439
059c5f9
8ad0593
e2cea27
c975d77
f6bc4a5
4bdd101
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like desugaring, this is a file that should be a folder. It's lengthy and can be divided into topics. Easier to do this now than later!
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Copyright 2019-2025 ETH Zurich and the DaCe authors. All rights reserved. | ||
| import json | ||
| import sys | ||
| from pathlib import Path | ||
| from typing import List, Any, Dict, Optional, Generator, Iterable, Tuple | ||
|
|
||
| from dace.frontend.fortran.ast_desugaring import ConstTypeInjection, ConstInstanceInjection, ConstInjection, SPEC | ||
|
|
||
|
|
||
| def serialize(x: ConstInjection) -> str: | ||
| assert isinstance(x, (ConstTypeInjection, ConstInstanceInjection)) | ||
| d: Dict[str, Any] = { | ||
| 'type': type(x).__name__, | ||
| 'scope': '.'.join(x.scope_spec) if x.scope_spec else None, | ||
| 'root': '.'.join(x.type_spec if isinstance(x, ConstTypeInjection) else x.root_spec), | ||
| 'component': '.'.join(x.component_spec), | ||
| 'value': x.value | ||
| } | ||
| return json.dumps(d) | ||
|
|
||
|
|
||
| def deserialize(s: str) -> ConstInjection: | ||
| d = json.loads(s) | ||
| assert d['type'] in {'ConstTypeInjection', 'ConstInstanceInjection'} | ||
| scope = tuple(d['scope'].split('.')) if d['scope'] else None | ||
| root = tuple(d['root'].split('.')) | ||
| component = tuple(d['component'].split('.')) if d['component'] else tuple() | ||
| value = d['value'] | ||
| return ConstTypeInjection(scope, root, component, value) \ | ||
| if d['type'] == 'ConstTypeInjection' \ | ||
| else ConstInstanceInjection(scope, root, component, value) | ||
|
|
||
|
|
||
| def find_all_config_injection_files(root: Path) -> Generator[Path, None, None]: | ||
| if root.is_file(): | ||
| yield root | ||
| else: | ||
| for f in root.rglob('*.ti'): | ||
| yield f | ||
|
|
||
|
|
||
| def find_all_config_injections(ti_files: Iterable[Path]) -> Generator[ConstInjection, None, None]: | ||
| inj_map: Dict[Tuple[str, str], ConstInjection] = {} | ||
| for f in ti_files: | ||
| for l in f.read_text().strip().splitlines(): | ||
| if not l.strip(): | ||
| continue | ||
| x = deserialize(l.strip()) | ||
| if len(x.component_spec) > 1: | ||
| print(f"{x}/{x.component_spec} must have just one-level for now; moving on...", file=sys.stderr) | ||
| continue | ||
| root = '.'.join(x.type_spec if isinstance(x, ConstTypeInjection) else x.root_spec) | ||
| comp = '.'.join(x.component_spec) | ||
| key = (root, comp) | ||
| if key in inj_map: | ||
| assert inj_map[key].value == x.value, \ | ||
| f"Inconsistent values in constant injections: {x} vs. {inj_map[key]}" | ||
| else: | ||
| inj_map[key] = x | ||
| yield x |
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.