pub struct Plugin { /* private fields */ }Expand description
A loaded PJRT plugin.
A plugin is a shared library that implements the PJRT C API for one kind
of hardware, such as libpjrt_cpu.so for CPUs or xla_cuda_plugin.so for
NVIDIA GPUs.
Plugins stay loaded until the process exits, because PJRT plugins do not
support being unloaded. Loading the same path twice returns the same
plugin, so Plugin is a cheap, copyable handle.
Implementations§
Source§impl Plugin
impl Plugin
Sourcepub fn register_ffi_handler(
self,
target_name: &str,
platform: &str,
handler: Handler,
) -> Result<()>
pub fn register_ffi_handler( self, target_name: &str, platform: &str, handler: Handler, ) -> Result<()>
Registers a handler for stablehlo.custom_call @target_name on
platform (such as "Host" for CPUs or "CUDA").
§Errors
Returns an error if the plugin has no FFI extension or rejects the handler.
Source§impl Plugin
impl Plugin
Sourcepub fn load(path: impl AsRef<Path>) -> Result<Self>
pub fn load(path: impl AsRef<Path>) -> Result<Self>
Loads the plugin at path and initializes it.
§Errors
Returns an error if the shared library cannot be loaded, if it does not
export GetPjrtApi, or if the plugin fails to initialize.
Sourcepub fn api_version(self) -> (i32, i32)
pub fn api_version(self) -> (i32, i32)
Returns the version of the PJRT C API the plugin implements, as
(major, minor).
Sourcepub fn client(self) -> Result<Client>
pub fn client(self) -> Result<Client>
Creates a client with the plugin’s default options.
§Errors
Returns an error if the plugin fails to create a client, for example because no device is available.
Sourcepub fn client_with_options(self, options: &[ClientOption<'_>]) -> Result<Client>
pub fn client_with_options(self, options: &[ClientOption<'_>]) -> Result<Client>
Creates a client with platform-specific options.
The available options depend on the plugin. For example, the CUDA
plugin accepts preallocate (a boolean) and memory_fraction (a
float).
§Errors
Returns an error if the plugin rejects an option or fails to create a client.