/* Appellation: params Contrib: FL03 */ extern crate concision_core as concision; extern crate concision_transformer as transformer; use concision::{linarr, Matmul}; use transformer::Qkv; use ndarray::prelude::*; #[test] fn test_qkv() { let shape = (2048, 10); let params = Qkv::::new(shape); assert_eq!(params.q(), &Array::default(shape)); } #[test] fn test_qkv_matmul() { let shape = (2048, 10); // generate some sample data let data = linarr(shape).unwrap(); // initialize the parameters let params = Qkv::::ones(shape); // calculate the expected result let exp = Array2::::ones(shape).dot(&data.t()); // calculate the result let res = params.matmul(&data.t()); // compare the results assert_eq!(res.q(), &exp); assert_eq!(res.k(), &exp); assert_eq!(res.v(), &exp); }