Skip to content

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

@ProGamerGov

Description

@ProGamerGov

🚀 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Staleoncall: jitAdd this issue/PR to JIT oncall triage queue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions