I'm trying to do compile time shape checking for linear algebra and I'm specifying two definitions for matmul():
/// Vector vector multiplication
impl <const DIM1: DimType, const DIM2: DimType, const DIM3: DimType, const DIM4: DimType, const DIM5: DimType>Tensor<DIM1, DIM2, DIM3, DIM4, DIM5>
where Assert::<{dim_eq_1(DIM2)}>: IsTrue, Assert::<{dim_eq_1(DIM3)}>: IsTrue, Assert::<{dim_eq_1(DIM4)}>: IsTrue, Assert::<{dim_eq_1(DIM5)}>: IsTrue {
pub fn matmul<const DIM6: DimType>(&self, rhs: &Tensor<DIM1, DIM2, DIM3, DIM4, DIM5>) -> Tensor<DIM1, DIM2, DIM3, DIM4, DIM5>
where Assert::<{dim_eq_1(DIM6)}>: IsTrue {
Tensor::from_tch(self.data.matmul(&rhs.data))
}
}
/// Matrix vector multiplication
impl <const DIM1: DimType, const DIM2: DimType, const DIM3: DimType, const DIM4: DimType, const DIM5: DimType>Tensor<DIM1, DIM2, DIM3, DIM4, DIM5>
where Assert::<{dim_eq_1(DIM3)}>: IsTrue, Assert::<{dim_eq_1(DIM4)}>: IsTrue, Assert::<{dim_eq_1(DIM5)}>: IsTrue {
pub fn matmul<const DIM6: DimType>(&self, rhs: &Tensor<DIM2, DIM3, DIM4, DIM5, DIM6>) -> Tensor<DIM1, DIM3, DIM4, DIM5, DIM6>
where Assert::<{dim_eq_1(DIM6)}>: IsTrue {
Tensor::from_tch(self.data.matmul(&rhs.data))
}
}
As you can see, the assertions on const generic parameters are different, but I'm getting an error:
duplicate definitions with name matmul
Is there a way to seperate these two implementations?