Sarek_execute.Epilogue_policyWhich backends run epilogue fusion, and for which kernels (specs/epilogue-fusion.md, FR-104; specs/optimisation-policy.md).
The fused kernel equals the unfused pair only if no kernel of the backend is contracted: the device compiler may share a subexpression of P and C (or forward P's stored value) in the fused kernel that the unfused C contracts. HIP compiles every kernel with -ffp-contract=off and every Metal kernel starts with #pragma METAL fp contract(off) (Sarek_ir_metal.metal_fp_contract_pragma), so fusion is exact there. CUDA, OpenCL and Vulkan contract inside kernels (docs/fp-contraction-policy.md section 14): there a fused kernel may differ from the pair by one contraction per element, a deviation the program accepts for the kernels concerned with Cross_kernel_contraction (Sarek_policy.requires).
What this module adds to that decision is a per-backend switch that only restricts: every backend is on by default, set_backend_enabled false switches one off and true only undoes that; SAREK_OPT_DISABLE=epilogue restricts epilogue fusion for the whole process, for good. Neither grants anything.
Switch epilogue fusion off (false) or back on (true) for one backend. Switching on is not a grant: on CUDA, OpenCL and Vulkan fusion still needs Sarek_policy.deviation.Cross_kernel_contraction for both kernels.
val pair_cache :
(string * string * string, int * Sarek_policy.decision) Stdlib.Hashtbl.tval policy_decision :
backend:string ->
producer:string ->
consumer:string ->
Sarek_policy.decisionval decide_pair :
backend:string ->
producer:string ->
consumer:string ->
Sarek_policy.decisionWhether the epilogue of consumer may be merged into producer on backend: the backend is not switched off or inexact, and Sarek_policy.decide allows Sarek_policy.optimisation.Epilogue_fusion for the meet of both kernels' budgets.
Whether fusion can run on backend under the process grants alone: not switched off, exact, and allowed by Sarek_policy.decide for the process budget (HIP and Metal; the others once Cross_kernel_contraction is granted at process scope). Kernel-scoped grants are not seen: the decision per pair is decide_pair.