Skip to content

Commit

Permalink
add one test for forwarding
Browse files Browse the repository at this point in the history
Signed-off-by: José Carlos García <hola@josecarlos.me>
  • Loading branch information
JoseCarlosGarcia95 committed Dec 9, 2024
1 parent 231a83e commit f64d885
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions candle-nn/tests/bit_linear.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use candle::{Device::Cpu, Result, Tensor};
use candle_nn::{BitLinear, Module};

#[test]
fn test_forward_no_bias() -> Result<()> {
let weight = Tensor::new(&[[1f32, -1.], [-1., 1.], [1., 1.]], &Cpu)?;
let layer = BitLinear::new(weight.clone(), None);

let input = Tensor::new(&[[1f32, -1.]], &Cpu)?;
let output = layer.forward(&input)?;
let expected_output = Tensor::new(&[[2.0f32, -2.0, 0.0]], &Cpu)?;

assert_eq!(output.to_vec2::<f32>()?, expected_output.to_vec2::<f32>()?);
Ok(())
}

0 comments on commit f64d885

Please sign in to comment.