Skip to content

Extract common pipeline from einsum2 entry points in lib.rs #121

@shinaoka

Description

@shinaoka

Summary

strided-einsum2/src/lib.rs has 4 public einsum2 functions that duplicate the entire pipeline:

  1. einsum2_into() — generic Scalar with ElementOp
  2. einsum2_naive_into() — custom ScalarBase with closures
  3. einsum2_with_backend_into() — custom backend dispatch
  4. einsum2_into_owned() — owned arrays with conjugation

Each repeats: plan creation → dimension validation → trace reduction → permutation → fast-path check → contiguous prep → GEMM dispatch.

Proposal

Extract the common pipeline into a single internal einsum2_core() function. The 4 public functions become thin wrappers that provide type-specific parameters. Estimated ~300 lines reduction.

Risk

Medium. Requires careful trait design to avoid excessive indirection, but the benefit (single source of truth, easier maintenance) is substantial.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions