TypeTensor - v0.1.0
    Preparing search index...

    Type Alias MatMulShape<A, B>

    MatMulShape: HasMatchingInnerDims<A, B> extends false
        ? never
        : A extends readonly [infer K1]
            ? K1 extends number
                ? B extends readonly [infer K2]
                    ? K2 extends number ? readonly [] : never
                    : VectorMatrixMul<readonly [K1], B>
                : never
            : B extends readonly [infer K2]
                ? K2 extends number ? MatrixVectorMul<A, readonly [K2]> : never
                : MatrixMatrixMul<A, B>

    Infer the result shape of matrix multiplication

    Handles all standard matrix multiplication cases:

    • 1D × 1D: [K] × [K] → scalar (returns readonly [])
    • 1D × 2D: [K] × [K, N] → [N]
    • 2D × 1D: [M, K] × [K] → [M]
    • 2D × 2D: [M, K] × [K, N] → [M, N]
    • ND × ND: [...batch, M, K] × [...batch, K, N] → [...batch, M, N]

    Type Parameters

    type Result1 = MatMulShape<[2, 3], [3, 4]> // readonly [2, 4]
    type Result2 = MatMulShape<[10], [10, 5]> // readonly [5]
    type Result3 = MatMulShape<[5, 2, 3], [5, 3, 4]> // readonly [5, 2, 4]