Module Sarek_matrix_advice

What matrix units could do for a recognised GEMM nest.

Static knowledge only: which Sarek_coopmat_types.config a lowering would use for the nest's element types, which backends can run it, and whether the result would stay bit-identical (Sarek_coopmat_types.accuracy_regime.Strict) or only bounded (Sarek_coopmat_types.accuracy_regime.Relaxed_bounded). Nothing here probes a device or changes code. Table: specs/matrix-pattern-advice.md.

type element_case =
  1. | F16_inputs
    (*

    float16 x float16, float32 accumulator

    *)
  2. | F32_inputs
    (*

    float32 throughout

    *)
  3. | Int32_inputs
    (*

    int32 throughout

    *)
  4. | No_case
    (*

    anything else: no configuration

    *)

The element types of A, B, the accumulator and C.

type lowering =
  1. | Direct
    (*

    the operands are the configuration's operand types

    *)
  2. | Operand_rounding
    (*

    float32 operands rounded to float16

    *)
  3. | Byte_planes of int
    (*

    each int32 operand split into its four unsigned bytes; the int payload is the number of 8-bit products per tile

    *)
type accuracy_class =
  1. | Exact
    (*

    bit-identical (integer, modulo 232)

    *)
  2. | Relaxed_accumulation
    (*

    only the addition order changes: the gamma_K bound and the existing opt-in apply

    *)
  3. | Relaxed_operands
    (*

    operands are rounded to a narrower type: no existing opt-in covers it

    *)

How a lowering would change results. Not Sarek_coopmat_types.accuracy_regime on purpose: Relaxed_operands is a larger deviation than the Relaxed_bounded that Sarek_coopmat.accept_relaxed_accumulation admits, and must not be mistaken for it.

type advice = {
  1. case : element_case;
  2. config : Sarek_coopmat_types.config option;
  3. lowering : lowering option;
  4. accuracy_class : accuracy_class option;
  5. accuracy : string;
  6. backends : (string * string) list;
    (*

    backend, status

    *)
}
val has_matrix_unit : advice -> bool

A configuration exists for this nest.

val render : ?kernel_name:string -> Sarek_matrix_pattern.gemm -> advice -> string

The alert text, several lines.