Skip to content

torch dot function consistent with numpy #138

@glample

Description

@glample

That would be nice to have the dot function in pytorch consistent with the numpy one:

For 2-D arrays it is equivalent to matrix multiplication, and for 1-D arrays to inner product of vectors (without complex conjugation). For N dimensions it is a sum product over the last axis of a and the second-to-last of b.
https://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.html

So that with:
x = torch.Tensor(5, 3, 4).normal_()
y = torch.Tensor(4, 7).normal_()

x.dot(y) returns a tensor of shape (5, 3, 7)

Metadata

Metadata

Assignees

No one assigned

    Labels

    todoNot 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