Analogous to https://github.com/inducer/pyopencl/issues/668. We probably want to restrict this checking to `__debug__` mode.