Skip to main content

Crate strided_einsum2

Crate strided_einsum2 

Source
Expand description

Binary Einstein summation on strided views.

Provides einsum2_into for computing binary tensor contractions with accumulation semantics: C = alpha * A * B + beta * C.

§Example

use strided_view::StridedArray;
use strided_einsum2::einsum2_into;

// Matrix multiply: C_ik = A_ij * B_jk
let a = StridedArray::<f64>::from_fn_row_major(&[2, 3], |idx| (idx[0] * 3 + idx[1] + 1) as f64);
let b = StridedArray::<f64>::from_fn_row_major(&[3, 2], |idx| (idx[0] * 2 + idx[1] + 1) as f64);
let mut c = StridedArray::<f64>::row_major(&[2, 2]);

einsum2_into(
    c.view_mut(), &a.view(), &b.view(),
    &['i', 'k'], &['i', 'j'], &['j', 'k'],
    1.0, 0.0,
).unwrap();

Re-exports§

pub use backend::Backend;
pub use dot_general::dot_general_into;
pub use dot_general::dot_general_with_backend_into;
pub use dot_general::DotGeneralConfig;
pub use plan::Einsum2Plan;
pub use raw_bgemm::bgemm_raw_strided_into;
pub use raw_bgemm::bgemm_raw_strided_into_unchecked;
pub use raw_bgemm::bgemm_raw_with_backend_into;
pub use raw_bgemm::bgemm_raw_with_backend_into_unchecked;

Modules§

backend
Backend abstraction for batched GEMM dispatch. Backend abstraction for batched GEMM dispatch.
bgemm_faer
Batched GEMM backend using the [faer] library. faer-backed batched GEMM kernel on strided views.
bgemm_naive
Batched GEMM fallback using explicit loops. Naive batched GEMM kernel on strided views.
contiguous
GEMM-ready operand types and preparation functions for contiguous data. GEMM-ready operand types and preparation functions for contiguous data.
dot_general
Axis-based general dot product API. Axis-based general dot product API.
plan
Contraction planning: axis classification and permutation computation. Einsum2 plan: axis classification and permutation computation.
raw_bgemm
Raw borrowed-layout batched GEMM entry points. Raw borrowed-layout batched GEMM entry points.
trace
Trace-axis reduction (summing axes that appear only in one operand). Trace-axis reduction for einsum operands.
util
Shared helpers (permutation inversion, multi-index iteration, dimension fusion). Shared helpers for strided-einsum2.

Structs§

RawStridedMut
Borrowed raw strided output layout.
RawStridedRef
Borrowed raw strided input layout.
StridedView
Dynamic-rank immutable strided view with lazy element operations.
StridedViewMut
Dynamic-rank mutable strided view.

Enums§

EinsumError
Errors specific to einsum operations.

Traits§

AxisId
Trait alias for axis label types.
Scalar
Trait alias for element types supported by the faer active backend.
ScalarBase
Shared trait bounds for all element types usable with einsum, independent of GEMM backend.

Functions§

col_major_strides
Compute column-major strides (Julia default: first index varies fastest).
einsum2_into
Binary einsum contraction: C = alpha * contract(A, B) + beta * C.
einsum2_into_owned
Binary einsum accepting owned inputs for zero-copy optimization.
einsum2_naive_into
Binary einsum for custom scalar types using naive GEMM.
einsum2_with_backend_into
Binary einsum with a pluggable GEMM backend.

Type Aliases§

Result
Convenience alias for Result<T, EinsumError>.