| 38 | |
| 39 | |
| 40 | def get_operator_backend_files(filelist, operators, backend='', techs=[], attrs=[], include_common=True): |
| 41 | files = {"common": []} |
| 42 | |
| 43 | # Early return if filelist is empty |
| 44 | if backend not in filelist: |
| 45 | return files |
| 46 | |
| 47 | # Iterate over operators and create the file lists to compiler |
| 48 | for operator in operators: |
| 49 | if operator in filelist[backend]['operators']: |
| 50 | if include_common: |
| 51 | files['common'] += filelist[backend]['operators'][operator]["files"]["common"] |
| 52 | for tech in techs: |
| 53 | if tech in filelist[backend]['operators'][operator]["files"]: |
| 54 | # Add tech as a key to dictionary if not there |
| 55 | if tech not in files: |
| 56 | files[tech] = [] |
| 57 | |
| 58 | # Add tech files to the tech file list |
| 59 | tech_files = filelist[backend]['operators'][operator]["files"][tech] |
| 60 | if include_common: |
| 61 | files[tech] += tech_files.get('common', []) |
| 62 | for attr in attrs: |
| 63 | files[tech] += tech_files.get(attr, []) |
| 64 | |
| 65 | # Remove duplicates if they exist |
| 66 | return {k: list(set(v)) for k, v in files.items()} |
| 67 | |
| 68 | |
| 69 | def collect_operators(filelist, operators, backend=''): |