Skip to content

Commit

Permalink
Add simple test for embedding function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Liang-Chi Hsieh committed Feb 21, 2025
1 parent ac9cdbd commit ac0bfd0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions candle-nn/tests/embedding.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use candle::{DType, Result, Shape};
use candle_nn::{VarBuilder, VarMap};
use candle_nn::embedding;

#[test]
fn test_embedding() -> Result<()> {
let device = candle::Device::Cpu;

let varmap = VarMap::new();
let vb = VarBuilder::from_varmap(&varmap, DType::F32, &device);
let embed = embedding(10, 20, vb)?;

assert_eq!(embed.embeddings().shape(), &Shape::from((10, 20)));

Ok(())
}

0 comments on commit ac0bfd0

Please sign in to comment.