#![allow(dead_code, unused_imports)]
pub mod image;
pub mod modules;
pub mod qwen2;
pub mod rope;
pub use modules::{
GateUpDownMLP, NaiveAttention, NaiveAttnGateUpDownMLPBlock, NaiveAttnTwoLinearMLPBlock, QKVCatAttention,
TwoLinearMLP, eager_attention_forward, get_conv1d, get_conv2d, get_layer_norm, quick_gelu,
};
use candle_core::Tensor;
use crate::error::Result;
#[derive(Clone, Debug)]
pub struct MultiModalData {
pub data_vec: Vec<Option<Tensor>>,
}
impl MultiModalData {
#[must_use]
pub fn new(data_vec: Vec<Option<Tensor>>) -> Self {
Self { data_vec }
}
}
pub trait InferenceModel {
fn forward_initial(&mut self, input_ids: &Tensor, seqlen_offset: usize, data: MultiModalData) -> Result<Tensor> {
let _ = data;
self.forward_step(input_ids, seqlen_offset)
}
fn forward_step(&mut self, input_ids: &Tensor, seqlen_offset: usize) -> Result<Tensor>;
fn forward_step_with_position_ids(
&mut self,
input_ids: &Tensor,
position_ids: Option<&Tensor>,
seqlen_offset: usize,
) -> Result<Tensor> {
let _ = position_ids;
self.forward_step(input_ids, seqlen_offset)
}
fn clear_cache(&mut self);
fn stop_token_ids(&self) -> Vec<u32>;
}