pub struct ModuleImage<'a> { /* private fields */ }Expand description
Borrowed or owned bytes containing CUDA device code.
Every image is nonempty and is either NUL-terminated PTX text or a self-describing binary image.
ModuleImage::from_ptx checks PTX text, compilers in this crate produce their images directly, and ModuleImage::from_bytes_unchecked takes binaries on the caller’s word.
Implementations§
Source§impl<'a> ModuleImage<'a>
impl<'a> ModuleImage<'a>
Sourcepub fn from_ptx(ptx: impl Into<Cow<'a, [u8]>>) -> Result<Self>
pub fn from_ptx(ptx: impl Into<Cow<'a, [u8]>>) -> Result<Self>
Creates an image from PTX text, appending a NUL terminator if ptx does not end with one.
Borrowed text that already ends with a NUL byte stays borrowed.
§Errors
Returns Error::Empty if ptx holds no text before its optional NUL terminator.
Returns Error::InteriorNul if the text contains a NUL byte before its end.
Sourcepub unsafe fn from_bytes_unchecked(data: impl Into<Cow<'a, [u8]>>) -> Self
pub unsafe fn from_bytes_unchecked(data: impl Into<Cow<'a, [u8]>>) -> Self
Creates an image from device-code bytes without checking them.
§Safety
data must be nonempty and must be a complete cubin, fatbin, ELF, or Tile IR image whose headers describe sizes and offsets within data, or PTX text ending in its only NUL byte.
CUDA’s loaders take no length and trust the image headers, so other bytes make them read out of bounds.