Open carmocca opened 5 months ago
We can definitely represent it using __getitem__
when it's executed by PyTorch (we can even use a subscript instead of the dunder).
In general we should be sure we're importing the necessary functions so that we always generate a Python function that can be run independently.
🚀 Feature
Motivation
Tensor slices are represented in traces as:
But there's no
torch_slice_prim_impl
import. And we can use Python to represent it.This reference comes from:
https://github.com/Lightning-AI/lightning-thunder/blob/ea1d1302f4a630e3832c07dc3adfe559111ba099/thunder/executors/torchex.py#L533-L534
https://github.com/Lightning-AI/lightning-thunder/blob/ea1d1302f4a630e3832c07dc3adfe559111ba099/thunder/executors/torchex.py#L507-L517
Pitch
Instead represent it with
__getitem__
andslice()
:Alternatives
Add the
torch_slice_prim_impl
import from torchex to the trace so that it's a valid programcc @apaz-cli @nikitaved