Skip to content

[FEAT] Support transpose flags transa, transb != 'N' in GEMM #13

Closed

Description

@SwayamInSync

Summary

qblas_gemm and the higher-level wrappers currently reject any value other than 'N' for the transpose flags, which makes it impossible for
callers to handle mixed-layout operands (e.g. row-major × col-major) without doing a full copy into a contiguous buffer first.

Reference (in the numpy-quaddtype tree at src/csrc/quadblas_interface.cpp, but the upstream QBLAS-side QuadBLAS::gemm shares the same limitation):

// For now, we only support no transpose
// TODO: Implement transpose support if needed
if ((transa != 'N' && transa != 'n') || (transb != 'N' && transb != 'n')) {
    return -1;  // Transpose not implemented yet
}

QuadBLAS::gemm(qblas_layout, m, n, k, *alpha, A, lda, B, ldb, *beta, C, ldc);

qblas_gemv already accepts 'T' (implemented as a layout swap), but
the same T / C semantics aren't available for gemm.

Proposed API

Match the BLAS convention so the wrapper can pass transa/transb
through directly:

// Each of 'N', 'T', 'C' supported (C == T for real-valued types).
QuadBLAS::gemm(Layout layout,
               Trans transa, Trans transb,
               size_t m, size_t n, size_t k,
               Sleef_quad alpha,
               const Sleef_quad *A, size_t lda,
               const Sleef_quad *B, size_t ldb,
               Sleef_quad beta,
               Sleef_quad *C, size_t ldc);

Layout already exists; adding a Trans enum (or a char) and honoring it in the kernel would let the C wrapper drop the "transpose not implemented yet" guard.

Notes / acceptance

  • Implementation can reuse the same trick qblas_gemv uses (swap dims + flip layout) when that's enough, or do a real transposed kernel where it matters for performance.
  • Existing tests in tests/ should be extended with transa/transb variants of the gemm cases.

Activity

  1. changed the title [-][FEAT] Support transpose flags `transa, transb != 'N'` in `qblas_gemm` / `qblas_gemv`[/-] [+][FEAT] Support transpose flags `transa, transb != 'N'` in GEMM[/+] on May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions