A context object for doing graph (topogical) pattern matching.
| 25 | |
| 26 | |
| 27 | class PatternContext(tvm.runtime.Object): |
| 28 | """A context object for doing graph (topogical) pattern matching.""" |
| 29 | |
| 30 | def __init__(self, incremental=False): |
| 31 | """ |
| 32 | Initialize the PatternContext |
| 33 | |
| 34 | Parameters |
| 35 | ---------- |
| 36 | incremental : bool, optional |
| 37 | perform incremental matching based on the recent context, by default False |
| 38 | """ |
| 39 | self.__init_handle_by_constructor__(ffi.PatternContext, incremental) # type: ignore |
| 40 | |
| 41 | def __enter__(self): |
| 42 | """Enter the context""" |
| 43 | ffi.enter_context(self) # type: ignore |
| 44 | return self |
| 45 | |
| 46 | def __exit__(self, exc_type, exc_value, traceback): |
| 47 | """Exit the context""" |
| 48 | ffi.exit_context(self) # type: ignore |
| 49 | |
| 50 | @staticmethod |
| 51 | def current() -> "PatternContext": |
| 52 | """ |
| 53 | Get the current context |
| 54 | |
| 55 | Returns |
| 56 | ------- |
| 57 | PatternContext |
| 58 | The current context |
| 59 | """ |
| 60 | return ffi.current_context() # type: ignore |
| 61 | |
| 62 | def match_dfb( |
| 63 | self, |
| 64 | dfb: DataflowBlock, |
| 65 | ) -> dict[DFPattern, Var]: |
| 66 | """ |
| 67 | Match a DataflowBlock via a graph of DFPattern and corresponding constraints |
| 68 | |
| 69 | Parameters |
| 70 | ---------- |
| 71 | dfb : DataflowBlock |
| 72 | The DataflowBlock to match |
| 73 | |
| 74 | Returns |
| 75 | ------- |
| 76 | Dict[DFPattern, Var] |
| 77 | The mapping from DFPattern to matched expression |
| 78 | """ |
| 79 | return ffi.match_dfb(self, dfb) # type: ignore |
no outgoing calls
searching dependent graphs…