Register patterns which will be used to partition the DataflowBlock into subgraphs that are supported by external backends. Parameters ---------- patterns: List[Pattern] Patterns to be registered. Patterns that appear later in the list have higher priority when
(patterns: list[Pattern])
| 61 | |
| 62 | |
| 63 | def register_patterns(patterns: list[Pattern]): |
| 64 | """ |
| 65 | Register patterns which will be used to partition the DataflowBlock into |
| 66 | subgraphs that are supported by external backends. |
| 67 | |
| 68 | Parameters |
| 69 | ---------- |
| 70 | patterns: List[Pattern] |
| 71 | Patterns to be registered. Patterns that appear later in the list have |
| 72 | higher priority when partitioning DataflowBlock. |
| 73 | """ |
| 74 | _ensure_cleanup_function_registered() |
| 75 | |
| 76 | entries = [] |
| 77 | for item in patterns: |
| 78 | if isinstance(item, FusionPattern): |
| 79 | entries.append(item) |
| 80 | elif isinstance(item, tuple): |
| 81 | entries.append(FusionPattern(*item)) |
| 82 | _REGISTERED_PATTERN_NAMES.add(item[0]) |
| 83 | else: |
| 84 | raise TypeError(f"Cannot register type {type(item)} as pattern") |
| 85 | _ffi_api.RegisterPatterns(entries) |
| 86 | |
| 87 | |
| 88 | def get_patterns_with_prefix(prefix: str) -> list[FusionPattern]: |
no test coverage detected
searching dependent graphs…