cuda.tile.static_exception#
- cuda.tile.static_exception(exc, /)#
Marks an exception as compile-time.
Can only be used to wrap the exception of a raise statement:
raise ct.static_exception(...)
The surrounded expression is evaluated at compile time, using the same rules as
static_eval(): it can reference global and local variables, and use the full Python syntax, but must not perform any run-time operations.The expression must return an exception object. The returned exception is then wrapped in
StaticExceptionand raised at compile time.raise ct.static_exception(ValueError("test"))
import cuda.tile as ct import torch @ct.kernel def kernel(): raise ct.static_exception(ValueError("test")) torch.cuda.init() ct.launch(torch.cuda.current_stream(), (1,), kernel, ()) torch.cuda.synchronize()
Output
Traceback (most recent call last): ... StaticException: Exception was raised at compile time (ValueError: test)