Skip to content

[pytorch] torch.einsum processes ellipsis differently from NumPy #9930

@vadimkantorov

Description

@vadimkantorov
import torch
import numpy as np

a = torch.rand(32, 48, 9, 3)
print(np.einsum('...ji,...jk ->...ik', a, a).shape)
# (32, 48, 3, 3)

print(torch.einsum('...ji,...jk ->...ik', [a, a]).shape)
# RuntimeError: ellipsis must represent 2 dimensions in all terms

Found during porting matting laplacian to PyTorch: https://github.com/NVIDIA/FastPhotoStyle/blob/master/photo_smooth.py#L76

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions