Module Sarek_matrix

Run a kernel, on matrix units when it is a recognised matrix product and that is allowed (specs/matrix-pattern-rewrite.md).

run is a drop-in for Sarek.Execute.run_vectors that asks for the rewrite explicitly: unlike the default path it also rewrites on the interpreter (specs/matrix-pattern-dynamic.md). When the kernel is a GEMM nest (Sarek_matrix_pattern) whose indices and guards the rewrite can bound (Sarek_matrix_mapping), the device offers the configuration and the accuracy policy admits it, it launches the rewritten kernel (Sarek_matrix_rewrite) over exactly the outputs the original launch writes; otherwise it launches the original kernel, unchanged. The returned outcome says which, and why.

Policy: an int32 product is rewritten by default (bit-identical). A float16-operand product needs Sarek_coopmat.accept_relaxed_accumulation. A float32 product needs ~precision and Sarek_coopmat.accept_operand_rounding for that precision, and Sarek_coopmat.accept_relaxed_accumulation. This explicit entry point does NOT need Sarek_coopmat.accept_automatic_float_rewrite: that opt-in is for the rewrite Execute.run_vectors applies on its own to a program's own kernels.

type outcome =
  1. | Rewritten of {
    1. lowering : Sarek_matrix_rewrite.lowering;
    2. config : Sarek_coopmat.config;
    }
  2. | Original of string
    (*

    why the original kernel ran

    *)
val outcome_text : outcome -> string