# How do we do mid layer integration after Aten fx graph

**URL:** <https://dev-discuss.pytorch.org/t/how-do-we-do-mid-layer-integration-after-aten-fx-graph/1140>\
**Category:** compiler\
**Created:** [March 20, 2023, 10:15am UTC](https://dev-discuss.pytorch.org/t/how-do-we-do-mid-layer-integration-after-aten-fx-graph/1140 "2023-03-20T10:15:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AR51](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@AR51](https://dev-discuss.pytorch.org/u/AR51)\
**Post date:** [March 20, 2023, 10:15am UTC](https://dev-discuss.pytorch.org/t/how-do-we-do-mid-layer-integration-after-aten-fx-graph/1140/1 "2023-03-20T10:15:37Z")

</div>

Hi all,

How do we do mid-layer integration after the Aten FX graph?

I have a custom backend compiler in cpp that compiles a custom graph data structure. I wanted to convert the final Aten fx graph into my own custom graph data structure and get the binary out and run on the hardware.  
Could someone point me to this?

---

<div class="post-metadata">

**Author:** ![AR51](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@AR51](https://dev-discuss.pytorch.org/u/AR51)\
**Post date:** [March 21, 2023, 10:25am UTC](https://dev-discuss.pytorch.org/t/how-do-we-do-mid-layer-integration-after-aten-fx-graph/1140/2 "2023-03-21T10:25:27Z")

</div>

Can somebody help me?

---

<div class="post-metadata">

**Author:** ![albanD](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/alband/32/9_2.png) [@albanD](https://dev-discuss.pytorch.org/u/albanD)\
**Post date:** [March 21, 2023, 2:58pm UTC](https://dev-discuss.pytorch.org/t/how-do-we-do-mid-layer-integration-after-aten-fx-graph/1140/3 "2023-03-21T14:58:11Z")

</div>

cc @SherlockNoMad might be able to help?

---

<div class="post-metadata">

**Author:** ![SherlockNoMad](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/sherlocknomad/32/346_2.png) [@SherlockNoMad](https://dev-discuss.pytorch.org/u/SherlockNoMad)\
**Post date:** [March 21, 2023, 5:14pm UTC](https://dev-discuss.pytorch.org/t/how-do-we-do-mid-layer-integration-after-aten-fx-graph/1140/4 "2023-03-21T17:14:13Z")

</div>

Sounds like you will need

- A converter that convert from FX-aten graph into your own custom graph
- A python binding for your cpp backend, if you wish to run your backend in python env.

Also, you can find examples of NvFuser, OnnxRuntime, XLA from this thread [[Dynamo] Integrating CapabilityBasedPartitioner in PyTorch/XLA · Issue #4758 · pytorch/xla · GitHub](https://github.com/pytorch/xla/issues/4758)

---

<div class="post-metadata">

**Author:** ![AR51](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@AR51](https://dev-discuss.pytorch.org/u/AR51)\
**Post date:** [March 22, 2023, 4:12pm UTC](https://dev-discuss.pytorch.org/t/how-do-we-do-mid-layer-integration-after-aten-fx-graph/1140/5 "2023-03-22T16:12:41Z")

</div>

Thanks for the pointers. I’ll check it out.
