MCPcopy Create free account
hub / github.com/evilsocket/cake / test_encoder_block_forward

Function test_encoder_block_forward

cake-core/src/models/vibevoice/vae_encoder.rs:431–455  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

429
430 #[test]
431 fn test_encoder_block_forward() {
432 let ch = 32;
433 let mut map = std::collections::HashMap::new();
434 let dev = Device::Cpu;
435
436 map.insert("norm.weight".into(), Tensor::ones(ch, DType::F32, &dev).unwrap());
437 map.insert("gamma".into(), Tensor::ones(ch, DType::F32, &dev).unwrap());
438 map.insert("mixer.conv.conv.conv.weight".into(), mt(&[ch, 1, 7], 1));
439 map.insert("mixer.conv.conv.conv.bias".into(), mt(&[ch], 2));
440 map.insert("ffn_norm.weight".into(), Tensor::ones(ch, DType::F32, &dev).unwrap());
441 map.insert("ffn_gamma".into(), Tensor::ones(ch, DType::F32, &dev).unwrap());
442 map.insert("ffn.linear1.weight".into(), mt(&[ch * 4, ch], 3));
443 map.insert("ffn.linear1.bias".into(), mt(&[ch * 4], 4));
444 map.insert("ffn.linear2.weight".into(), mt(&[ch, ch * 4], 5));
445 map.insert("ffn.linear2.bias".into(), mt(&[ch], 6));
446
447 let vb = candle_nn::VarBuilder::from_tensors(map, DType::F32, &dev);
448 let backend = crate::backends::create_backend(&dev);
449 let block = EncoderBlock::load(vb, ch, 1e-5, backend).unwrap();
450
451 // Input: (batch=1, channels=32, seq=16)
452 let x = mt(&[1, ch, 16], 10);
453 let y = block.forward(&x).unwrap();
454 assert_eq!(y.dims(), &[1, ch, 16]);
455 }
456
457 #[test]
458 fn test_encoder_block_residual() {

Callers

nothing calls this directly

Calls 3

create_backendFunction · 0.85
mtFunction · 0.70
forwardMethod · 0.45

Tested by

no test coverage detected