Skip to main content

ruvector_attention_wasm/
lib.rs

1use wasm_bindgen::prelude::*;
2
3pub mod attention;
4pub mod training;
5pub mod utils;
6
7/// Initialize the WASM module with panic hook
8#[wasm_bindgen(start)]
9pub fn init() {
10    #[cfg(feature = "console_error_panic_hook")]
11    console_error_panic_hook::set_once();
12}
13
14/// Get the version of the ruvector-attention-wasm crate
15#[wasm_bindgen]
16pub fn version() -> String {
17    env!("CARGO_PKG_VERSION").to_string()
18}
19
20/// Get information about available attention mechanisms
21#[wasm_bindgen]
22pub fn available_mechanisms() -> JsValue {
23    let mechanisms = vec![
24        "scaled_dot_product",
25        "multi_head",
26        "hyperbolic",
27        "linear",
28        "flash",
29        "local_global",
30        "moe",
31    ];
32    serde_wasm_bindgen::to_value(&mechanisms).unwrap()
33}