# \[question\] how dynamo or aot-autograd optimize slice operation?

**URL:** <https://dev-discuss.pytorch.org/t/question-how-dynamo-or-aot-autograd-optimize-slice-operation/3089>\
**Category:** compiler\
**Created:** [June 27, 2025, 8:13am UTC](https://dev-discuss.pytorch.org/t/question-how-dynamo-or-aot-autograd-optimize-slice-operation/3089 "2025-06-27T08:13:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yepgang](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/yepgang/32/1145_2.png) [@Yepgang](https://dev-discuss.pytorch.org/u/Yepgang)\
**Post date:** [June 27, 2025, 8:13am UTC](https://dev-discuss.pytorch.org/t/question-how-dynamo-or-aot-autograd-optimize-slice-operation/3089/1 "2025-06-27T08:13:35Z")

</div>

For the following case, the fx graph obtained by the inductor entry no longer contains the slice op. Does anyone know where this part is optimized?

e.g. slice ut case

```python
import torch

class NaiveModel(torch.nn.Module):
    def __init__ (self):
        super(). __init__ ()
    def forward(self, arg0_1):
        slice_1 = torch.ops.aten.slice.Tensor(arg0_1, 0, 0, 9223372036854775807)
        return slice_1

model = NaiveModel()
opt_mod = torch.compile(model, backend="inductor")

x0 = torch.rand(256, 256)

golden = model(x0)
outs = opt_mod(x0)

```

stage1. pdb in inductor\_compile\_fx\_inner

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pytorch1/original/2X/b/b14ffc8f845ee42dacd73c66cf9ba46b1e26c6dd.jpeg)

stage2. print(gm.code)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pytorch1/original/2X/4/4b024fde16c51755cfce7e015d2247b0f15b0d47.png)

---

<div class="post-metadata">

**Author:** ![Yepgang](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/yepgang/32/1145_2.png) [@Yepgang](https://dev-discuss.pytorch.org/u/Yepgang)\
**Post date:** [June 27, 2025, 8:35am UTC](https://dev-discuss.pytorch.org/t/question-how-dynamo-or-aot-autograd-optimize-slice-operation/3089/2 "2025-06-27T08:35:37Z")

</div>

It seems torch/\_inductor/fx\_passes/joint\_graph.py::joint\_graph\_passes deal with the optimize. 🧐
