use super::kernels::Kernels;
use super::shape::{assert_same_len, for_each_row};
use crate::runtime::cpu::kernels::{i8xi8_dot_f32_with, i8xi8_dot_i32_with};
impl Kernels {
#[track_caller]
#[inline]
pub fn dot_i8(&self, a: &[i8], b: &[i8]) -> i32 {
assert_same_len("dot_i8", a.len(), b.len());
unsafe { i8xi8_dot_i32_with(self.level(), a.as_ptr(), b.as_ptr(), a.len()) }
}
#[track_caller]
#[inline]
pub fn dot_i8_scaled(&self, a: &[i8], b: &[i8], scale: f32) -> f32 {
assert_same_len("dot_i8_scaled", a.len(), b.len());
unsafe { i8xi8_dot_f32_with(self.level(), a.as_ptr(), b.as_ptr(), scale, a.len()) }
}
#[track_caller]
pub fn dot_i8_many(&self, query: &[i8], rows: &[i8], d: usize, out: &mut [i32]) {
for_each_row("dot_i8_many", query, rows, d, out, |row| {
self.dot_i8(query, row)
});
}
}
#[track_caller]
#[inline]
pub fn dot_i8(a: &[i8], b: &[i8]) -> i32 {
Kernels::detect().dot_i8(a, b)
}
#[track_caller]
#[inline]
pub fn dot_i8_scaled(a: &[i8], b: &[i8], scale: f32) -> f32 {
Kernels::detect().dot_i8_scaled(a, b, scale)
}
#[track_caller]
pub fn dot_i8_many(query: &[i8], rows: &[i8], d: usize, out: &mut [i32]) {
Kernels::detect().dot_i8_many(query, rows, d, out);
}