use burn::{
Tensor,
tensor::DType,
};
use crate::burner::module::HasDType;
#[derive(Clone, Debug)]
pub struct AttnKvPair {
pub key: Tensor<4>,
pub value: Tensor<4>,
}
impl HasDType for AttnKvPair {
fn dtype(&self) -> DType {
self.key.dtype()
}
}
impl AttnKvPair {
pub fn seq_len(&self) -> usize {
self.key.dims()[2]
}
pub fn batch_size(&self) -> usize {
self.key.dims()[0]
}
pub fn concat(
self,
next: Self,
) -> Self {
Self {
key: Tensor::cat(vec![self.key, next.key], 2),
value: Tensor::cat(vec![self.value, next.value], 2),
}
}
}