Skip to content

[pytorch] [feature request] Add torch.broadcast (e.g. for using with torch.stack) #8076

@vadimkantorov

Description

@vadimkantorov
a = torch.arange(3).unsqueeze(1)
b = torch.arange(4).unsqueeze(0)
c = a + b # works
d = torch.stack([a, b]) # fails because of dimensions
e = torch.stack([a.expand(3, 4), b.expand(3, 4)]) # works

Currently torch.stack requires arguments to be expanded manually, which is not the case for many other operations. It would be nice if it supported broadcasting, if it's easy enough to implement.

Metadata

Metadata

Assignees

Labels

high prioritytodoNot as important as medium or high priority tasks, but we will work on these.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions