Skip to content

RFC: linalg.outer support batches of vectors #242

Open
@AnirudhDagar

Description

@AnirudhDagar

Current Status

Current API spec defines the linalg.outer behaviour for one-dimensional vector inputs only.

Quoting from the docs.

Computes the outer product of two vectors x1 and x2 .
Parameters

  • x1 :
    • first one-dimensional input array of size N . Should have a numeric data type.
  • x2 :
    • second one-dimensional input array of size M . Should have a numeric data type.

Proposal

Most of the array/tensor libraries involve the manipulation and usage of batched vectors. It would be worth considering batch support in linalg.outer for the Array API standard, instead of only the 1D Vectors. This will also make linalg.outer more in line with the behaviour offered by other linalg functions in the spec which generally take in an nd-array/tensor.


Interestingly

  • PyTorch currently has torch.outer which also only supports 1d Tensors.
  • NumPy though supports nd-arrays with numpy.outer, but the behaviour is to flatten the inputs to 1d Vectors in case the input is not already 1-dimensional.

This was initially discussed in pytorch/pytorch#63293.

cc @lezcano @rgommers

Metadata

Metadata

Assignees

No one assigned

    Labels

    API changeChanges to existing functions or objects in the API.RFCRequest for comments. Feature requests and proposed changes.status: BlockedIssue or pull request which is current blocked.topic: Linear AlgebraLinear algebra.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions