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

Function assert_close

cake-core/tests/unit_tests/test_backend_ops.rs:10–20  ·  view source on GitHub ↗
(a: &Tensor, b: &Tensor, tol: f32)

Source from the content-addressed store, hash-verified

8}
9
10fn assert_close(a: &Tensor, b: &Tensor, tol: f32) {
11 let diff = (a - b).unwrap().abs().unwrap();
12 let max_diff: f32 = diff
13 .flatten_all()
14 .unwrap()
15 .max(0)
16 .unwrap()
17 .to_scalar()
18 .unwrap();
19 assert!(max_diff < tol, "max diff {max_diff} exceeds tolerance {tol}");
20}
21
22// ── linear_forward ─────────────────────────────────────────────────────
23

Calls

no outgoing calls

Tested by

no test coverage detected