Implement the module trait directly for QMatMul. (#1372)

This commit is contained in:
Laurent Mazare
2023-11-25 10:09:45 +00:00
committed by GitHub
parent 762e996ce6
commit bfa7c8fc01
7 changed files with 11 additions and 18 deletions

View File

@ -123,12 +123,6 @@ pub trait Module {
fn forward(&self, xs: &Tensor) -> Result<Tensor>;
}
impl Module for quantized::QMatMul {
fn forward(&self, xs: &Tensor) -> Result<Tensor> {
self.forward(xs)
}
}
impl<T: Fn(&Tensor) -> Result<Tensor>> Module for T {
fn forward(&self, xs: &Tensor) -> Result<Tensor> {
self(xs)

View File

@ -307,8 +307,8 @@ impl crate::CustomOp1 for QTensor {
}
}
impl QMatMul {
pub fn forward(&self, xs: &Tensor) -> Result<Tensor> {
impl crate::Module for QMatMul {
fn forward(&self, xs: &Tensor) -> Result<Tensor> {
match self {
Self::QTensor(t) => xs.apply_op1_no_bwd(t.as_ref()),
Self::Tensor(w) => {