# How is pattern matching in inductor/fx implemented?

**URL:** <https://dev-discuss.pytorch.org/t/how-is-pattern-matching-in-inductor-fx-implemented/1720>\
**Category:** compiler\
**Created:** [December 9, 2023, 3:56pm UTC](https://dev-discuss.pytorch.org/t/how-is-pattern-matching-in-inductor-fx-implemented/1720 "2023-12-09T15:56:40Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![youkaichao](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/youkaichao/32/1278_2.png) [@youkaichao](https://dev-discuss.pytorch.org/u/youkaichao)\
**Post date:** [December 12, 2023, 5:26am UTC](https://dev-discuss.pytorch.org/t/how-is-pattern-matching-in-inductor-fx-implemented/1720/4 "2023-12-12T05:26:48Z")

</div>

Put it this way:

If I have a computation graph `g`, and a pattern `search_fn` represented by another computation graph `s`, does `inductor` promise to find all matching graph (up to isomorphism) `s` in `g`?

If the answer is yes, are there any constraints on the structure of `s`, either by limiting the number of nodes or limiting the number of edges?

If the answer is no, are there any suggestions for writing `search_fn` so that `inductor` works better?

---

_[View the full topic](https://dev-discuss.pytorch.org/t/how-is-pattern-matching-in-inductor-fx-implemented/1720)._
