macro_rules! debug_assert_shape {
($($tt:tt)*) => { ... };
}Expand description
Same as assert_shape!, but compiled out unless debug_assertions
is on.
Without .. the rank check is a type check and stays in every build; with .. the
minimum-rank check is a runtime assertion and is compiled out with the axis checks. Like
debug_assert!, neither the tensor expression nor the slot expressions are evaluated in
release builds.
use burn_tensor::{Tensor, debug_assert_shape};
let device = Default::default();
let hidden = Tensor::<3>::zeros([2, 5, 256], &device);
debug_assert_shape!(hidden, [2, _, 256]);With debug assertions on, a mismatch panics like assert_shape!:
ⓘ
use burn_tensor::{Tensor, debug_assert_shape};
let x = Tensor::<2>::zeros([2, 3], &Default::default());
debug_assert_shape!(x, [2, 99]);