# How to invoke symbolic shape propagation?

**URL:** https://dev-discuss.pytorch.org/t/how-to-invoke-symbolic-shape-propagation/1652
**Category:** frontend API
**Created:** [November 11, 2023, 12:05am UTC](https://dev-discuss.pytorch.org/t/how-to-invoke-symbolic-shape-propagation/1652 "2023-11-11T00:05:27Z")
**Posts on this page:** 4
**Page:** 1

<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: [November 11, 2023, 12:05am UTC](https://dev-discuss.pytorch.org/t/how-to-invoke-symbolic-shape-propagation/1652/1 "2023-11-11T00:05:27Z")

</div>

The faketensor colab [Google Colab](https://colab.research.google.com/drive/1zjAisRrc8R6uixKsrs1DRm3lwz5MWN68) has an example of trying maximum batchsize, but it uses concrete shapes with trial and error.

How to create a faketensor with symbolic shape and pass it to a module to get the output symbolic shape?

The documentation [Fake tensor — PyTorch 2.1 documentation](https://pytorch.org/docs/stable/torch.compiler_fake_tensor.html#interaction-with-dynamic-shapes) mentioned `ShapeEnv`, but I can’t find a simple usage.

---

<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: [November 11, 2023, 12:13am UTC](https://dev-discuss.pytorch.org/t/how-to-invoke-symbolic-shape-propagation/1652/2 "2023-11-11T00:13:48Z")

</div>

Might be relevant: @ezyang @albanD @Chillee

---

<div class="post-metadata">

### Author: ![Lezcano](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/lezcano/32/300_2.png) [@Lezcano](https://dev-discuss.pytorch.org/u/Lezcano)
#### Post date: [November 14, 2023, 3:59pm UTC](https://dev-discuss.pytorch.org/t/how-to-invoke-symbolic-shape-propagation/1652/3 "2023-11-14T15:59:31Z")

</div>

This sort of general questions are better suited for the general PyTorch forum [https://discuss.pytorch.org/](https://discuss.pytorch.org/)

At any rate, for this and similar questions, it’s always easy to find examples in the testing suite, that is `test/`. In this case, you can find plenty of examples in `test/test_dynamic_shapes.py`.

---

<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: [November 16, 2023, 5:05pm UTC](https://dev-discuss.pytorch.org/t/how-to-invoke-symbolic-shape-propagation/1652/4 "2023-11-16T17:05:06Z")

</div>

@Lezcano Thanks for the pointer. It is indeed very helpful.
