use candle_core::{Result, Tensor};
pub struct Scorer;
impl Scorer {
pub fn forward(&self, span_rep: &Tensor, struct_proj: &Tensor) -> Result<Tensor> {
let (t, w, h) = span_rep.dims3()?;
let (count, f, h2) = struct_proj.dims3()?;
if h != h2 {
return Err(candle_core::Error::Msg(format!("scorer: hidden mismatch {h} vs {h2}")));
}
let span_flat = span_rep.reshape(((), h))?.contiguous()?;
let struct_flat = struct_proj.reshape(((), h))?.contiguous()?;
let scores_flat = struct_flat.matmul(&span_flat.transpose(0, 1)?.contiguous()?)?;
let scores = scores_flat.reshape((count, f, t, w))?;
candle_nn::ops::sigmoid(&scores)
}
}