D2c M4, gate 7 (delete). - int_hyper_synth::decode_conditional, the unchecked conditional decode, is deleted; its callers decode through decode_conditional_checked (the lowering, with its check ranges): the int_hyper_decode_frame example (step 3 of tools/wai_sota_vectors.sh), wai_decode_bench's tiny-vector case, int_payload's JSON-equivalence unit tests, tests/int_hyper_synth.rs, int_kernels_vectors.rs, int_video_keyframe.rs, int_video_sota_keyframe.rs, and byte-exact's neural_keyframe_golden (the trap: it gains the check ranges, outputs equal; gate 2's duplicate test through ops::decode goes). - The pretrained synthesis-only and hyper-decoder-only goldens (tests/int_hyper_synth.rs) are also held through the lowering. - The conditional codec's direct guard (legacy's run_checked) is test-only since gate 6. run_net_checked, check_layer and igdn_check stay: their one production caller left is int_mlicpp (M5); run_net and decode stay for the world renderer (M6), and int_hyper_synth's kernel_equivalence with them, since their conv dispatch is still run_net's. Docs say so. - Doc references (int_video, int_video_golden, two tools) and CHANGELOG. Co-Authored-By: Claude Opus 5.5 <[email protected]>
68 lines
3.2 KiB
Rust
68 lines
3.2 KiB
Rust
//! `wai.video.int_hyper` on the full pretrained model — a real 256×256 clip whose
|
||
//! I-frame is the byte-exact `int_hyper` decode of the pretrained mbt2018_mean
|
||
//! (exported to integers), panned into P-frames by integer motion compensation.
|
||
//! Reads the int_hyper vector + the panned-clip bitstream from `WAI_SOTA_INT_DIR`
|
||
//! (default `/tmp/sota_int`), regenerated by `tools/wai_sota_vectors.sh` (the
|
||
//! model is too large to commit). CI (`wai-sota-vectors.yml`) regenerates them and
|
||
//! runs this with `WAI_REQUIRE_SOTA_VECTORS=1`, so an absent vector fails there;
|
||
//! locally it skips loudly. A `WAI_SOTA_INT_DIR` naming a directory that does not
|
||
//! exist, or one missing a file this test reads, fails either way. The committed
|
||
//! 16×16 `int_video_keyframe` test is the never-skip companion.
|
||
#![cfg(all(feature = "neural_int", feature = "video_int"))]
|
||
|
||
#[path = "support/require_vectors.rs"]
|
||
mod require_vectors;
|
||
|
||
use require_vectors::{env_dir, load_all};
|
||
|
||
use wai::int_hyper_synth::{decode_conditional_checked, CondBitstream, CondEntropy, IntModel};
|
||
use wai::int_video::{decode_pframes, fnv1a};
|
||
|
||
fn hex16(s: &str) -> [u8; 8] {
|
||
let mut o = [0u8; 8];
|
||
for (i, b) in o.iter_mut().enumerate() {
|
||
*b = u8::from_str_radix(&s[i * 2..i * 2 + 2], 16).unwrap();
|
||
}
|
||
o
|
||
}
|
||
|
||
#[test]
|
||
fn sota_int_hyper_keyframe_clip_decodes_byte_for_byte() {
|
||
const TEST: &str = "int_video_sota_keyframe::sota_int_hyper_keyframe_clip_decodes_byte_for_byte";
|
||
const PRODUCE: &str = "tools/wai_sota_vectors.sh <dir> (then WAI_SOTA_INT_DIR=<dir>, default /tmp/sota_int)";
|
||
let d = env_dir(TEST, "WAI_SOTA_INT_DIR", "/tmp/sota_int", PRODUCE);
|
||
let Some([g, hh, e, b, vb, conf]) = load_all(
|
||
TEST,
|
||
&d,
|
||
[
|
||
"int_synth_sota_model.json", "int_hs_model.json", "cond_entropy.json",
|
||
"cond_bitstream.json", "video_sota_bitstream.json", "video_sota.json",
|
||
],
|
||
PRODUCE,
|
||
) else {
|
||
return;
|
||
};
|
||
|
||
// frame 0: the int_hyper learned I-frame (byte-exact 256×256 photo).
|
||
let g_s = IntModel::from_json(&g);
|
||
let h_s = IntModel::from_json(&hh);
|
||
let ent = CondEntropy::from_value(&e);
|
||
let bs = CondBitstream::from_value(&b);
|
||
let (frame0, h, w) = decode_conditional_checked(&g_s, &h_s, &ent, &bs.stream()).expect("int_hyper I-frame");
|
||
|
||
// frames 1..N: integer motion-compensated P-frames panning the keyframe.
|
||
let clip = decode_pframes(&frame0, h, w, &vb).expect("p-frames");
|
||
let want = conf["frame_hashes"].as_array().unwrap();
|
||
assert_eq!(clip.frames.len(), want.len());
|
||
assert_eq!(format!("{:016x}", fnv1a(&frame0)), want[0].as_str().unwrap(), "I-frame = int_hyper decode");
|
||
|
||
let mut all = Vec::new();
|
||
for (i, frame) in clip.frames.iter().enumerate() {
|
||
let got = format!("{:016x}", fnv1a(frame));
|
||
assert_eq!(got, want[i].as_str().unwrap(), "frame {i} byte-for-byte");
|
||
all.extend_from_slice(&hex16(&got));
|
||
}
|
||
assert_eq!(format!("{:016x}", fnv1a(&all)), conf["clip_hash"].as_str().unwrap(), "clip hash");
|
||
println!("int_hyper-keyframe video (pretrained model): {} frames {h}x{w}, I-frame={} (learned), clip {}",
|
||
clip.frames.len(), &want[0].as_str().unwrap()[..8], conf["clip_hash"].as_str().unwrap());
|
||
}
|