einx.get_at#
- einx.get_at(description, *tensors, backend=None, **parameters)[source]#
Retrieves values from a tensor at the coordinates specified by another tensor.
The elementary operation has the signature
[...] , [n] -> []. The first argument is the n-dimensional value tensor, the second argument specifies a single n-dimensional coordinate, and the result is the value at that coordinate.For 1-dimensional value tensors, the elementary operation also accepts the signature
[...] , [] -> []. For example, the following two operations compute the same output:y = einx.get_at("[h], p [1] -> p", x, idx) y = einx.get_at("[h], p -> p", x, idx[:, 0])
The elementary operation also accepts multiple coordinate tensors as input, in which case they are concatenated first. The length of the resulting coordinate vector must equal the number of dimensions of the value tensor. For example, the following two operations compute the same output:
y = einx.get_at("[a b c d], p [n] -> p", x, idx) y = einx.get_at("[a b c d], p, p [2], p [1] -> p", x, idx[:, 0], idx[:, 1:3], idx[:, 3:4])
- Parameters:
description (
str) – Description string for the operation in einx notation.*tensors (
Tensor) – Input tensors or tensor factories matching the description string.backend (
Union[Backend,str,None]) – Backend to use for all operations. If None, uses the default backend for the given setting. Defaults to None.graph – Whether to return the compiled code representation of this operation instead of computing the result. Defaults to False.
**parameters (
Union[_Buffer,_SupportsArray[dtype[Any]],_NestedSequence[_SupportsArray[dtype[Any]]],bool,int,float,complex,str,bytes,_NestedSequence[bool|int|float|complex|str|bytes]]) – Additional parameters that specify dimension sizes, e.g.a=4.
- Return type:
Tensor- Returns:
The result of the operation if
graph=False, otherwise the compiled code representation of the operation.