We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Implement dpctl.tensor.trace per array API spec.
dpctl.tensor.trace
This could be an all top-level function:
dpctl.tensor.sum
Possible implementation for offset=0:
offset=0
def trace(ary): assert isinstance(ary, dpt.usm_ndarray) assert ary.ndim >= 2 res_shape = ary.shape[:-2] + (min(ary.shape[-2:]), ) res_strides = ary.strides[:-2] + (sum(ary.strides[-2:]),) view = dpt.usm_ndarray(res_shape, dtype=ary.dtype, buffer=ary, strides=res_strides) return dpt.sum(view, axis=-1, dtype=ary.dtype)
With sample usage:
In [4]: trace(dpt.ones((3,3,4,4))) Out[4]: usm_ndarray([[4., 4., 4.], [4., 4., 4.], [4., 4., 4.]], dtype=float32)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Implement
dpctl.tensor.trace
per array API spec.This could be an all top-level function:
dpctl.tensor.sum
on the last axis of the viewPossible implementation for
offset=0
:With sample usage:
The text was updated successfully, but these errors were encountered: