def pointer_to_inner(
dtype: _FloatTypeName | _ComplexTypeName | _MiniFloatType,
/,
) -> int | Symbol |
|---|
pointer_to_inner |
pointer_to_dot |
pointer_to_vdot |
Dot products are their own family because storage type, conjugation rules, and output widening matter.
import numpy as np
import numkong as nk
a = (np.random.randn(256) + 1j * np.random.randn(256)).astype(np.complex64)
b = (np.random.randn(256) + 1j * np.random.randn(256)).astype(np.complex64)
dot = nk.dot(a, b) # numpy.dot(a, b)
vdot = nk.vdot(a, b) # numpy.vdot(a, b)
print(dot, vdot)Real low-precision inputs can also be routed through explicit dtype tags when the storage buffer itself is raw bytes.
pointer_to_*× 3Return the address of the inner kernel for dtype, as an integer.def pointer_to_inner(
dtype: _FloatTypeName | _ComplexTypeName | _MiniFloatType,
/,
) -> int | Symbol |
|---|
pointer_to_inner |
pointer_to_dot |
pointer_to_vdot |
*× 2Compute the inner product of two real or complex vectors.def inner(
a: _BufferType,
b: _BufferType,
/,
dtype: _FloatTypeName | _ComplexTypeName | _MiniFloatType | None = None,
*,
out: _BufferType | None = None,
out_dtype: _FloatTypeName | _ComplexTypeName | _MiniFloatType | None = None,
capabilities: Capability | int | None = ...,
stream: int | None = ...,
) -> float | complex | Tensor | None | Symbol |
|---|
inner |
dot |
Similar to numpy.inner. Two vectors give a scalar. Matrices pair row i of a with row i of
b, a single row pairing with every row of the other, into a new Tensor of one result per pair,
or into out, returning None.
Similar to numpy.dot. Two vectors give a scalar. Matrices pair row i of a with row i of b,
a single row pairing with every row of the other, into a new Tensor of one result per pair, or
into out, returning None.
a_BufferType | First real or complex vector or matrix. | |
|---|---|---|
b_BufferType | Second real or complex vector or matrix, of the dtype of a. | |
dtype_FloatTypeName | _ComplexTypeName | _MiniFloatType | None | Input dtype to read both buffers as, overriding the one they report. | |
out_BufferType | None | Output vector for the results. | |
out_dtype_FloatTypeName | _ComplexTypeName | _MiniFloatType | None | Result dtype, by default that of out, else float64, complex128 for complex input. | |
capabilitiesCapability | int | None | Capabilities to run within: every CPU one by default, or for packed operands the mask that packed them. | |
streamint | None | A GPU stream pointer, left None on the CPU. |
vdotCompute the dot product of two complex vectors, conjugating the first.def vdot(
a: _BufferType,
b: _BufferType,
/,
dtype: _ComplexTypeName | _MiniFloatType | None = None,
*,
out: _BufferType | None = None,
out_dtype: _ComplexTypeName | _MiniFloatType | None = None,
capabilities: Capability | int | None = ...,
stream: int | None = ...,
) -> complex | Tensor | None Similar to numpy.vdot. Two vectors give a scalar. Matrices pair row i of a with row i of
b, a single row pairing with every row of the other, into a new Tensor of one result per pair,
or into out, returning None.
a_BufferType | First complex vector or matrix. | |
|---|---|---|
b_BufferType | Second complex vector or matrix, of the dtype of a. | |
dtype_ComplexTypeName | _MiniFloatType | None | Input dtype to read both buffers as, overriding the one they report. | |
out_BufferType | None | Output vector for the results. | |
out_dtype_ComplexTypeName | _MiniFloatType | None | Result dtype, by default that of out, else complex128. | |
capabilitiesCapability | int | None | Capabilities to run within: every CPU one by default, or for packed operands the mask that packed them. | |
streamint | None | A GPU stream pointer, left None on the CPU. |