returnn.torch.util.assert_¶
Async device assertion utility.
- returnn.torch.util.assert_.assert_(cond: Tensor, message: str, *, stop: bool = True)[source]¶
Does a device-side assertion. For CPU, this will directly check the condition and raise an error if false. For CUDA devices, this runs asynchronously on a separate thread (to avoid pin_memory in the current thread), and non-blocking (does not trigger a CUDA sync).
- Parameters:
cond – A boolean tensor indicating the condition to assert.
message – The message to display if the assertion fails.
stop – Whether to stop execution on assertion failure