-
Notifications
You must be signed in to change notification settings - Fork 24.3k
[Array API] Add linalg.vecdot #70542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5cbd57d
c926457
69c1492
a426304
96bafa1
205ed55
5d36d6f
82bfbdd
d97e06f
dd97da7
c26e36c
e6ee479
94f5d4b
160db10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ Matrix Products | |
|
||
cross | ||
matmul | ||
vecdot | ||
multi_dot | ||
householder_product | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1148,6 +1148,7 @@ | |
"tensorinv", | ||
"tensorsolve", | ||
"vander", | ||
"vecdot", | ||
"vector_norm" | ||
], | ||
"torch.multiprocessing": [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2801,3 +2801,38 @@ | |
[ 1, 3, 9], | ||
[ 1, 5, 25]]) | ||
""") | ||
|
||
vecdot = _add_docstr(_linalg.linalg_vecdot, r""" | ||
linalg.vecdot(x, y, *, dim=-1, out=None) -> Tensor | ||
|
||
Computes the dot product of two batches of vectors along a dimension. | ||
|
||
In symbols, this function computes | ||
|
||
.. math:: | ||
|
||
\sum_{i=1}^n \overline{x_i}y_i. | ||
|
||
over the dimension :attr:`dim` where :math:`\overline{x_i}` denotes the conjugate for complex | ||
vectors, and it is the identity for real vectors. | ||
|
||
Supports input of half, bfloat16, float, double, cfloat, cdouble and integral dtypes. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it supports everything do we need to mention it? I think it's fine to be explicit here. Also, many other linalg functions have a note on supported dtypes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving it as "better explicit than implicit". Also, it does support |
||
It also supports broadcasting. | ||
|
||
Args: | ||
x (Tensor): first batch of vectors of shape `(*, n)`. | ||
y (Tensor): second batch of vectors of shape `(*, n)`. | ||
|
||
Keyword args: | ||
dim (int): Dimension along which to compute the dot product. Default: `-1`. | ||
out (Tensor, optional): output tensor. Ignored if `None`. Default: `None`. | ||
|
||
Examples:: | ||
|
||
>>> v1 = torch.randn(3, 2) | ||
>>> v2 = torch.randn(3, 2) | ||
>>> linalg.vecdot(v1, v2) | ||
tensor([ 0.3223, 0.2815, -0.1944]) | ||
>>> torch.vdot(v1[0], v2[0]) | ||
tensor(0.3223) | ||
""") |
Uh oh!
There was an error while loading. Please reload this page.