import { sgemm as sgemm_chrome } from "./sgemm_chrome" ; import { sgemm as sgemm_wsl } from "./sgemm_wsl" ; import { sgemm as sgemm_fallback } from "./sgemm_fallback" ; const isSafari = navigator . userAgent . includes ( 'Safari' ) && ! navigator . userAgent . includes ( 'Chrome' ) ; let useFallback = false ; export async function sgemm ( m , n , k , alpha , a , b , beta = 0.0 , c ? ) { if ( useFallback ) { return sgemm_fallback ( m , n , k , alpha , a , b , beta , c ) ; } let result = null ; if ( isSafari ) { try { result = await sgemm_wsl ( m , n , k , alpha , a , b , beta , c ) ; } catch ( error ) { console . warn ( 'Error using WebGPU; fallback to pure JavaScript' , error ) ; } } else { try { result = await sgemm_chrome ( m , n , k , alpha , a , b , beta , c ) ; } catch ( error ) { console . warn ( 'Error using WebGPU; fallback to pure JavaScript' , error ) ; } } if ( result === null ) { useFallback = true ; return sgemm_fallback ( m , n , k , alpha , a , b , beta , c ) ; } return result ; }