mumu-gpu 0.1.0

GPU/Vulkan matrix and tensor operations for the mumu/lava language
Documentation
use mumu::parser::interpreter::{Interpreter, DynamicFnInfo};
use mumu::parser::types::{Value, FunctionValue};
use std::sync::{Arc, Mutex};
use crate::operators;
#[cfg(debug_assertions)]
use crate::debug::gpu_last_call_bridge;

pub fn register_all_gpu_fns(interp: &mut Interpreter) {
    {
        let func = Arc::new(Mutex::new(operators::gpu_multiply_bridge));
        let info = DynamicFnInfo::new(func, false);
        interp.register_dynamic_function_ex("gpu:multiply", info);
        interp.set_variable(
            "gpu:multiply",
            Value::Function(Box::new(FunctionValue::Named("gpu:multiply".to_string())))
        );
    }
    {
        let func = Arc::new(Mutex::new(operators::gpu_add_bridge));
        let info = DynamicFnInfo::new(func, false);
        interp.register_dynamic_function_ex("gpu:add", info);
        interp.set_variable(
            "gpu:add",
            Value::Function(Box::new(FunctionValue::Named("gpu:add".to_string())))
        );
    }
    {
        let func = Arc::new(Mutex::new(operators::gpu_subtract_bridge));
        let info = DynamicFnInfo::new(func, false);
        interp.register_dynamic_function_ex("gpu:subtract", info);
        interp.set_variable(
            "gpu:subtract",
            Value::Function(Box::new(FunctionValue::Named("gpu:subtract".to_string())))
        );
    }
    {
        let func = Arc::new(Mutex::new(operators::gpu_hadamard_bridge));
        let info = DynamicFnInfo::new(func, false);
        interp.register_dynamic_function_ex("gpu:hadamard", info);
        interp.set_variable(
            "gpu:hadamard",
            Value::Function(Box::new(FunctionValue::Named("gpu:hadamard".to_string())))
        );
    }
    {
        let func = Arc::new(Mutex::new(operators::gpu_inverse_bridge));
        let info = DynamicFnInfo::new(func, false);
        interp.register_dynamic_function_ex("gpu:inverse", info);
        interp.set_variable(
            "gpu:inverse",
            Value::Function(Box::new(FunctionValue::Named("gpu:inverse".to_string())))
        );
    }
    {
        let func = Arc::new(Mutex::new(operators::gpu_transpose_bridge));
        let info = DynamicFnInfo::new(func, false);
        interp.register_dynamic_function_ex("gpu:transpose", info);
        interp.set_variable(
            "gpu:transpose",
            Value::Function(Box::new(FunctionValue::Named("gpu:transpose".to_string())))
        );
    }
    {
        let func = Arc::new(Mutex::new(operators::gpu_reduce_sum_bridge));
        let info = DynamicFnInfo::new(func, false);
        interp.register_dynamic_function_ex("gpu:reduce_sum", info);
        interp.set_variable(
            "gpu:reduce_sum",
            Value::Function(Box::new(FunctionValue::Named("gpu:reduce_sum".to_string())))
        );
    }
    {
        let func = Arc::new(Mutex::new(operators::gpu_scale_bridge));
        let info = DynamicFnInfo::new(func, false);
        interp.register_dynamic_function_ex("gpu:scale", info);
        interp.set_variable(
            "gpu:scale",
            Value::Function(Box::new(FunctionValue::Named("gpu:scale".to_string())))
        );
    }
    {
        let func = Arc::new(Mutex::new(operators::gpu_to_tensor_bridge));
        let info = DynamicFnInfo::new(func, false);
        interp.register_dynamic_function_ex("gpu:to_tensor", info);
        interp.set_variable(
            "gpu:to_tensor",
            Value::Function(Box::new(FunctionValue::Named("gpu:to_tensor".to_string())))
        );
    }
    {
        let func = Arc::new(Mutex::new(operators::gpu_to_array_bridge));
        let info = DynamicFnInfo::new(func, false);
        interp.register_dynamic_function_ex("gpu:to_array", info);
        interp.set_variable(
            "gpu:to_array",
            Value::Function(Box::new(FunctionValue::Named("gpu:to_array".to_string())))
        );
    }
    #[cfg(debug_assertions)]
    {
        let debug_fn = Arc::new(Mutex::new(gpu_last_call_bridge));
        let dbg_info = DynamicFnInfo::new(debug_fn, false);
        interp.register_dynamic_function_ex("gpu:last_call", dbg_info);
        interp.set_variable(
            "gpu:last_call",
            Value::Function(Box::new(FunctionValue::Named("gpu:last_call".to_string())))
        );
    }
}