-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:Accelergy-Project/timeloop-python
- Loading branch information
Showing
5 changed files
with
60 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
def get_paths(mapping): | ||
cur_path = [] | ||
for node in mapping: | ||
cur_path.append(node) | ||
if node['type'] in ['pipeline', 'sequential']: | ||
for child in node['branches']: | ||
for subpath in get_paths(child): | ||
yield cur_path + subpath | ||
elif node['type'] == 'compute': | ||
yield cur_path.copy() | ||
|
||
|
||
def get_leaves(mapping): | ||
for node in mapping: | ||
if node['type'] in ['pipeline', 'sequential']: | ||
for child in node['branches']: | ||
yield from get_leaves(child) | ||
elif node['type'] == 'compute': | ||
yield node | ||
|
||
|
||
def get_einsums_with_complete_mappings(mapping): | ||
einsums_with_complete_mappings = set() | ||
for compute_node in get_leaves(mapping): | ||
if 'incomplete' not in compute_node: | ||
einsums_with_complete_mappings.add(compute_node['einsum']) | ||
if 'incomplete' in compute_node and not compute_node['incomplete']: | ||
einsums_with_complete_mappings.add(compute_node['einsum']) | ||
return einsums_with_complete_mappings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters