Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ExecuTorch] Cannot Use Dynamic Index to Select #2189

Open
YifanShenSZ opened this issue Apr 5, 2024 · 1 comment
Open

[ExecuTorch] Cannot Use Dynamic Index to Select #2189

YifanShenSZ opened this issue Apr 5, 2024 · 1 comment
Labels
bug Unexpected behaviour that should be corrected (type)

Comments

@YifanShenSZ
Copy link
Collaborator

This toy model fails in ExecuTorch

        class M(torch.nn.Module):
            def forward(self, float_arr, int_arr):
                dynamic_index = int_arr[1]
                float_arr[dynamic_index] = 12.95
                return float_arr

due to

E               torch._dynamo.exc.UserError: Consider annotating your code using torch._constrain_as_*(). Could not guard on data-dependent expression u0 (unhinted: u0).  (Size-like symbols: none)
E               
E               Potential framework code culprit (scroll up for full backtrace):
E                 File "<eval_with_key>.223", line 8, in forward
E                   l_float_arr_[dynamic_index] = 12.95;  setitem = l_float_arr_;  dynamic_index = None
E               
E               For more information, run with TORCH_LOGS="dynamic"
E               For extended logs when we create symbols, also add TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="u0"
E               If you suspect the guard was triggered from C++, add TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
E               For more debugging help, see https://docs.google.com/document/d/1HSuTTVvYH1pTew89Rtpeu84Ht3nQEFTYhAX3Ypa_xJs/edit?usp=sharing
E               
E               For C++ stack trace, run with TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
E               For more information about this error, see: https://pytorch.org/docs/main/generated/exportdb/index.html#constrain-as-size-example

But some other dynamic indexing models are fine, e.g.

        class IndexPutModel(torch.nn.Module):
            def forward(self, x, position, val):
                y = x.clone()
                y[:, position] = val
                return y
@YifanShenSZ YifanShenSZ added the bug Unexpected behaviour that should be corrected (type) label Apr 5, 2024
@YifanShenSZ
Copy link
Collaborator Author

Similarly, dynamic slice would also fail

        class DynamicSlicer(torch.nn.Module):
            def forward(self, x, context_length):
                return x[context_length:, :, :]

due to

torch._dynamo.exc.Unsupported: Dynamic slicing on data-dependent value is not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behaviour that should be corrected (type)
Projects
None yet
Development

No branches or pull requests

1 participant