Skip to main content

qualia_core_db/wgsl_forge/
dispatch.rs

1use super::ForgeError;
2pub use etalon_wgsl_forge::numerical::dispatch::*;
3pub fn ensure_cuda_runtime_path() {
4    #[cfg(not(target_arch = "wasm32"))]
5    super::install_device_policy();
6    etalon_wgsl_forge::numerical::dispatch::ensure_cuda_runtime_path()
7}
8pub fn caps() -> ComputeCaps {
9    #[cfg(not(target_arch = "wasm32"))]
10    super::install_device_policy();
11    etalon_wgsl_forge::numerical::dispatch::caps()
12}
13pub fn gemm_f32(
14    m: usize,
15    k: usize,
16    n: usize,
17    a: &[f32],
18    b: &[f32],
19) -> Result<Vec<f32>, ForgeError> {
20    #[cfg(not(target_arch = "wasm32"))]
21    super::install_device_policy();
22    etalon_wgsl_forge::numerical::dispatch::gemm_f32(m, k, n, a, b)
23}
24pub fn gemm_f64(
25    m: usize,
26    k: usize,
27    n: usize,
28    a: &[f64],
29    b: &[f64],
30) -> Result<Vec<f64>, ForgeError> {
31    #[cfg(not(target_arch = "wasm32"))]
32    super::install_device_policy();
33    etalon_wgsl_forge::numerical::dispatch::gemm_f64(m, k, n, a, b)
34}
35pub fn coopmat_usable() -> bool {
36    #[cfg(not(target_arch = "wasm32"))]
37    super::install_device_policy();
38    etalon_wgsl_forge::numerical::dispatch::coopmat_usable()
39}
40pub fn gemm_f32_tc_coopmat(
41    m: usize,
42    k: usize,
43    n: usize,
44    a: &[f32],
45    b: &[f32],
46) -> Result<Vec<f32>, ForgeError> {
47    #[cfg(not(target_arch = "wasm32"))]
48    super::install_device_policy();
49    etalon_wgsl_forge::numerical::dispatch::gemm_f32_tc_coopmat(m, k, n, a, b)
50}
51pub fn gemm_f32_tc(
52    m: usize,
53    k: usize,
54    n: usize,
55    a: &[f32],
56    b: &[f32],
57) -> Result<Vec<f32>, ForgeError> {
58    #[cfg(not(target_arch = "wasm32"))]
59    super::install_device_policy();
60    etalon_wgsl_forge::numerical::dispatch::gemm_f32_tc(m, k, n, a, b)
61}
62pub fn gemm_f32_tc_reduced(
63    m: usize,
64    k: usize,
65    n: usize,
66    a: &[f32],
67    b: &[f32],
68) -> Result<Vec<f32>, ForgeError> {
69    #[cfg(not(target_arch = "wasm32"))]
70    super::install_device_policy();
71    etalon_wgsl_forge::numerical::dispatch::gemm_f32_tc_reduced(m, k, n, a, b)
72}
73#[cfg(feature = "cuda")]
74pub fn gemm_tc_cuda(
75    m: usize,
76    k: usize,
77    n: usize,
78    a: &[f32],
79    b: &[f32],
80) -> Result<Vec<f32>, ForgeError> {
81    #[cfg(not(target_arch = "wasm32"))]
82    super::install_device_policy();
83    etalon_wgsl_forge::numerical::dispatch::gemm_tc_cuda(m, k, n, a, b)
84}
85pub fn gemm_f64_df64(
86    m: usize,
87    k: usize,
88    n: usize,
89    a: &[f64],
90    b: &[f64],
91) -> Result<Vec<f64>, ForgeError> {
92    #[cfg(not(target_arch = "wasm32"))]
93    super::install_device_policy();
94    etalon_wgsl_forge::numerical::dispatch::gemm_f64_df64(m, k, n, a, b)
95}
96pub fn gemm_cpu_f64(a: &[f64], b: &[f64], m: usize, k: usize, n: usize) -> Vec<f64> {
97    #[cfg(not(target_arch = "wasm32"))]
98    super::install_device_policy();
99    etalon_wgsl_forge::numerical::dispatch::gemm_cpu_f64(a, b, m, k, n)
100}
101pub fn pairwise_sq_dist_f64(a: &[f64], b: &[f64], n: usize, m: usize, p: usize) -> Vec<f64> {
102    #[cfg(not(target_arch = "wasm32"))]
103    super::install_device_policy();
104    etalon_wgsl_forge::numerical::dispatch::pairwise_sq_dist_f64(a, b, n, m, p)
105}
106pub fn pairwise_sq_dist_cpu_f64(a: &[f64], b: &[f64], n: usize, m: usize, p: usize) -> Vec<f64> {
107    #[cfg(not(target_arch = "wasm32"))]
108    super::install_device_policy();
109    etalon_wgsl_forge::numerical::dispatch::pairwise_sq_dist_cpu_f64(a, b, n, m, p)
110}
111pub fn gemv_f32(m: usize, n: usize, a: &[f32], x: &[f32]) -> Result<Vec<f32>, ForgeError> {
112    #[cfg(not(target_arch = "wasm32"))]
113    super::install_device_policy();
114    etalon_wgsl_forge::numerical::dispatch::gemv_f32(m, n, a, x)
115}
116pub fn gemv_f64(m: usize, n: usize, a: &[f64], x: &[f64]) -> Result<Vec<f64>, ForgeError> {
117    #[cfg(not(target_arch = "wasm32"))]
118    super::install_device_policy();
119    etalon_wgsl_forge::numerical::dispatch::gemv_f64(m, n, a, x)
120}
121pub fn gemv_cpu_f64(a: &[f64], x: &[f64], m: usize, n: usize) -> Vec<f64> {
122    #[cfg(not(target_arch = "wasm32"))]
123    super::install_device_policy();
124    etalon_wgsl_forge::numerical::dispatch::gemv_cpu_f64(a, x, m, n)
125}
126pub fn fft_f32(complex_interleaved: &[f32]) -> Result<Vec<f32>, ForgeError> {
127    #[cfg(not(target_arch = "wasm32"))]
128    super::install_device_policy();
129    etalon_wgsl_forge::numerical::dispatch::fft_f32(complex_interleaved)
130}