oa::Matrix
A multidimensional semantic value backed by OA-managed storage. A matrix carries shape, element stride, dtype, device, byte-offset, and optional autograd metadata. Copying a matrix shares its storage and autograd state. Metadata-only views also alias storage; use `clone()` when independent storage is required. Matrix operations use OA's Vulkan execution path. Direct host observation is an explicit synchronization boundary, not a CPU compute fallback. Stateful device ownership remains with `oa::Engine`; a matrix only retains the storage required for its value and recorded graph lifetime.
Public Methods
Constructor & Destructor Documentation
Parameters
inShapeMatrixShapeLogical dimensions of the matrix.
inFillValueoa::F32Value written to every element.
inDtypeoa::ScalarTypeScalar representation used by the allocation.
Public Method Documentation
Parameters
inContributionconst Matrix &Gradient contribution with a compatible element count.
Returns
voidThe declared return value.
Returns
const Matrix &The declared return value.
Parameters
inIdxoa::I64Row-major logical flat index. It must be in range.
Returns
oa::F32The selected value converted to FP32.
Returns
oa::U64The declared return value.
Returns
oa::I64The declared return value.
Returns
MatrixThe independent copy, or an empty matrix when this matrix is empty.
Returns
MatrixA contiguous copy, or an empty matrix when allocation fails.
Parameters
inOtherconst Matrix &Source values to copy.
Returns
voidThe declared return value.
Returns
oa::U64The declared return value.
Returns
const void *Pointer to this view's first byte, or `nullptr` when inaccessible.
Returns
void *Pointer to this view's first byte, or `nullptr` when inaccessible.
Returns
T *The declared return value.
Returns
const T *The declared return value.
Parameters
inRequiresGradboolInitial tracking state for the detached metadata.
Returns
voidThe declared return value.
Returns
MatrixThe declared return value.
Returns
oa::DeviceThe declared return value.
Returns
oa::ScalarTypeThe declared return value.
Returns
oa::SharedPtr<GradNode>The declared return value.
Returns
oa::MemoryPlacementThe declared return value.
Returns
MatrixShapeThe declared return value.
Returns
const Stride &The declared return value.
Returns
MatrixThe declared return value.
Returns
boolThe declared return value.
Returns
oa::I32The declared return value.
Returns
MemoryBlockThe declared return value.
Returns
boolThe declared return value.
Returns
boolThe declared return value.
Returns
boolThe declared return value.
Returns
boolThe declared return value.
Returns
oa::F32The scalar value converted to FP32.
Returns
voidThe declared return value.
Returns
AutogradMeta &The declared return value.
Returns
Matrix &The declared return value.
Returns
oa::I64The declared return value.
Returns
oa::U64The declared return value.
Parameters
inOtherconst Matrix &—
Returns
MatrixThe declared return value.
Parameters
inScalaroa::F32—
Returns
MatrixThe declared return value.
Parameters
inOtherconst Matrix &—
Returns
Matrix &The declared return value.
Parameters
inScalaroa::F32—
Returns
Matrix &The declared return value.
Parameters
inOtherconst Matrix &—
Returns
MatrixThe declared return value.
Parameters
inScalaroa::F32—
Returns
MatrixThe declared return value.
Parameters
inOtherconst Matrix &—
Returns
Matrix &The declared return value.
Parameters
inScalaroa::F32—
Returns
Matrix &The declared return value.
Returns
MatrixThe declared return value.
Parameters
inOtherconst Matrix &—
Returns
MatrixThe declared return value.
Parameters
inScalaroa::F32—
Returns
MatrixThe declared return value.
Parameters
inOtherconst Matrix &—
Returns
Matrix &The declared return value.
Parameters
inScalaroa::F32—
Returns
Matrix &The declared return value.
Parameters
inOtherconst Matrix &—
Returns
MatrixThe declared return value.
Parameters
inScalaroa::F32—
Returns
MatrixThe declared return value.
Parameters
inOtherconst Matrix &—
Returns
Matrix &The declared return value.
Parameters
inScalaroa::F32—
Returns
Matrix &The declared return value.
Parameters
inDimsoa::Span<const oa::I32>Source dimension for every output dimension.
Returns
MatrixA strided storage-sharing view; an empty matrix for an invalid permutation, or this matrix unchanged when the rank does not match.
Returns
oa::I32The declared return value.
Returns
boolThe declared return value.
Parameters
inNewShapeMatrixShapeLogical shape of the returned view.
Returns
MatrixThe storage-sharing view, or an empty matrix on count mismatch.
Parameters
inIdxoa::I64Row-major logical flat index to update.
inValueoa::F32Value converted to the matrix dtype and written.
Returns
voidThe declared return value.
Parameters
inValueboolWhether this leaf should accumulate gradients.
Returns
voidThe declared return value.
Parameters
inDimoa::I32Dimension index to query.
Returns
oa::I64Number of elements along the resolved dimension.
Parameters
inDimoa::I32Dimension to remove.
Returns
MatrixA storage-sharing view, or this matrix unchanged when the dimension is invalid or is not size one.
Parameters
inDim0oa::I32First dimension to exchange.
inDim1oa::I32Second dimension to exchange.
Returns
MatrixA matrix with the requested dimensions exchanged.
Parameters
inDimoa::I32Position of the inserted dimension.
Returns
MatrixA storage-sharing view with rank increased by one.
Parameters
inNewShapeMatrixShapeLogical shape of the returned view.
Returns
MatrixThe storage-sharing view, or an empty matrix on count mismatch.
Returns
voidThe declared return value.
Returns
voidThe declared return value.