Skip to content

tenzr::HardwareManager

Owns the loaded PJRT plugin and client, exposing device enumeration and platform metadata.

#include <hardware_manager.h>

Public Classes

Name
struct DeviceMemoryStats
Device allocator statistics (from PJRT_Device_MemoryStats when the plugin supports it).

Public Functions

Name
HardwareManager & Instance()
Access the singleton hardware manager.
HardwareManager()
~HardwareManager()
Release the PJRT client and loaded plugin on teardown.
HardwareManager(const HardwareManager & ) =delete
HardwareManager & operator=(const HardwareManager & ) =delete
void Initialize(const std::string & preferred_plugin_path ="")
void Shutdown()
Tear down the client and unload the plugin.
bool IsInitialized() const
Whether a PJRT client has been initialized.
const PJRT_Api * Api() const
Underlying PJRT API table.
PJRT_Client * Client() const
Underlying PJRT client.
const std::string & PlatformName() const
Name of the loaded platform.
const std::string & PlatformVersion() const
Version of the loaded platform.
const std::string & LoadedPluginPath() const
Path of the loaded PJRT plugin.
const std::vector< DeviceInfo > & Devices() const
All discovered devices, in platform order.
PJRT_Device * DefaultDevice() const
The default device used for execution.
const PJRT_Extension_Base * Extension(PJRT_Extension_Type type) const
Cached plugin extension of the given type, or nullptr when the plugin lacks it.
DeviceMemoryStats MemoryStats(PJRT_Device * device =nullptr) const
Memory stats for a device (defaults to the default device); available is false when unsupported.

Public Functions Documentation

function Instance

static HardwareManager & Instance()

Access the singleton hardware manager.

Return: Reference to the singleton HardwareManager.

Get the process-wide hardware manager.

function HardwareManager

HardwareManager()

function ~HardwareManager

~HardwareManager()

Release the PJRT client and loaded plugin on teardown.

function HardwareManager

HardwareManager(
    const HardwareManager & 
) =delete

function operator=

HardwareManager & operator=(
    const HardwareManager & 
) =delete

function Initialize

void Initialize(
    const std::string & preferred_plugin_path =""
)

Parameters:

  • preferred_plugin_path Explicit plugin path, or auto-discovery when empty.
  • preferred_plugin_path Optional explicit plugin path; discovered when empty.

Load a PJRT plugin and initialize its client. Load the PJRT plugin, create a client, and query its platform and devices.

function Shutdown

void Shutdown()

Tear down the client and unload the plugin.

function IsInitialized

inline bool IsInitialized() const

Whether a PJRT client has been initialized.

function Api

inline const PJRT_Api * Api() const

Underlying PJRT API table.

function Client

inline PJRT_Client * Client() const

Underlying PJRT client.

function PlatformName

inline const std::string & PlatformName() const

Name of the loaded platform.

function PlatformVersion

inline const std::string & PlatformVersion() const

Version of the loaded platform.

function LoadedPluginPath

inline const std::string & LoadedPluginPath() const

Path of the loaded PJRT plugin.

function Devices

inline const std::vector< DeviceInfo > & Devices() const

All discovered devices, in platform order.

function DefaultDevice

PJRT_Device * DefaultDevice() const

The default device used for execution.

Return: Handle to the default device.

First addressable device discovered by the plugin.

function Extension

const PJRT_Extension_Base * Extension(
    PJRT_Extension_Type type
) const

Cached plugin extension of the given type, or nullptr when the plugin lacks it.

Drop the PJRT client, device list, and API pointer.

function MemoryStats

DeviceMemoryStats MemoryStats(
    PJRT_Device * device =nullptr
) const

Memory stats for a device (defaults to the default device); available is false when unsupported.