8000 JIT / TorchScript should support for sum(List[torch.Tensor]) like non-JIT PyTorch already does · Issue #70533 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

JIT / TorchScript should support for sum(List[torch.Tensor]) like non-JIT PyTorch already does #70533

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

Open
ProGamerGov opened this issue Dec 30, 2021 · 1 comment
Labels
oncall: jit Add this issue/PR to JIT oncall triage queue Stale

Comments

@ProGamerGov
Copy link
Contributor
ProGamerGov commented Dec 30, 2021

🚀 The feature, motivation and pitch

The following code currently fails due to JIT not supporting the summarization of tensor lists:

from typing import List
import torch

def test_func(x: List[torch.Tensor]) -> torch.Tensor:
    return sum(x)

test_input = [torch.randn(1,2,4,4) for i in range(5)]

out_test = test_func(test_input) # Works

jit_test = torch.jit.script(test_func) # Fails

out_jit = jit_test(test_input)

It would be nice if JIT would work here for use cases like these.

Alternatives

No response

Additional context

This feature already works in normal PyTorch and it's simple enough that many would probably expect it to work in JIT.

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Dec 30, 2021
@vadimkantorov
Copy link
Contributor

regular sum also seems not very nice in terms of computational complexity (unless JIT can optimize it). A related feature request: #27522

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
oncall: jit Add this issue/PR to JIT oncall triage queue Stale
Projects
None yet
Development

No branches or pull requests

3 participants
0