openxla

package module
v0.0.0-...-7e94837 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package openxla provides Go bindings for the OpenXLA PJRT C API.

PJRT (Platform Runtime) is OpenXLA's uniform device runtime interface used by JAX, TensorFlow, and PyTorch to execute computations across TPUs, GPUs, and CPUs.

PJRT plugins (such as libtpu.so for Cloud TPU, or pjrt_c_api_gpu.so for CUDA) expose the C entrypoint GetPjrtApi() returning an Api function table. This package provides high-level, idiomatic Go wrappers for managing clients, compiling StableHLO/HLO programs, transferring buffers, and executing computations on accelerator hardware without requiring CGO.

Example

Example demonstrates loading an OpenXLA PJRT plugin and querying platform info.

package main

import (
	"fmt"

	"github.com/tmc/lib/openxla"
)

func main() {
	plugin, err := openxla.OpenPlugin("/usr/lib/libtpu.so")
	if err != nil {
		fmt.Println("PJRT plugin unavailable:", err)
		return
	}

	api := plugin.Api()
	fmt.Printf("PJRT API Version: %d.%d\n", api.ApiVersion.Major_version, api.ApiVersion.Minor_version)

	client, err := plugin.NewClient()
	if err != nil {
		fmt.Println("NewClient:", err)
		return
	}
	defer client.Destroy()

	name, _ := client.PlatformName()
	ver, _ := client.PlatformVersion()
	fmt.Printf("Platform: %s (%s)\n", name, ver)
}

Index

Examples

Constants

View Source
const (
	BufferTypeInvalid = Buffer_Type_INVALID
	BufferTypePred    = Buffer_Type_PRED
	BufferTypeS8      = Buffer_Type_S8
	BufferTypeS16     = Buffer_Type_S16
	BufferTypeS32     = Buffer_Type_S32
	BufferTypeS64     = Buffer_Type_S64
	BufferTypeU8      = Buffer_Type_U8
	BufferTypeU16     = Buffer_Type_U16
	BufferTypeU32     = Buffer_Type_U32
	BufferTypeU64     = Buffer_Type_U64
	BufferTypeF16     = Buffer_Type_F16
	BufferTypeF32     = Buffer_Type_F32
	BufferTypeF64     = Buffer_Type_F64
	BufferTypeBf16    = Buffer_Type_BF16
	BufferTypeC64     = Buffer_Type_C64
	BufferTypeC128    = Buffer_Type_C128
)

Common Buffer types for convenience

View Source
const (
	PJRT_Api_Version_STRUCT_SIZE                                               uintptr = 24
	PJRT_AsyncHostToDeviceTransferManager_AddMetadata_Args_STRUCT_SIZE         uintptr = 40
	PJRT_AsyncHostToDeviceTransferManager_BufferCount_Args_STRUCT_SIZE         uintptr = 32
	PJRT_AsyncHostToDeviceTransferManager_BufferSize_Args_STRUCT_SIZE          uintptr = 40
	PJRT_AsyncHostToDeviceTransferManager_Destroy_Args_STRUCT_SIZE             uintptr = 24
	PJRT_AsyncHostToDeviceTransferManager_Device_Args_STRUCT_SIZE              uintptr = 32
	PJRT_AsyncHostToDeviceTransferManager_RetrieveBuffer_Args_STRUCT_SIZE      uintptr = 40
	PJRT_AsyncHostToDeviceTransferManager_SetBufferError_Args_STRUCT_SIZE      uintptr = 48
	PJRT_AsyncHostToDeviceTransferManager_TransferData_Args_STRUCT_SIZE        uintptr = 72
	PJRT_AsyncHostToDeviceTransferManager_TransferLiteral_Args_STRUCT_SIZE     uintptr = 80
	PJRT_AsyncTrackingEvent_Destroy_Args_STRUCT_SIZE                           uintptr = 24
	PJRT_Buffer_Bitcast_Args_STRUCT_SIZE                                       uintptr = 64
	PJRT_Buffer_CopyRawToHostFuture_Args_STRUCT_SIZE                           uintptr = 64
	PJRT_Buffer_CopyRawToHostFuture_Callback_Args_STRUCT_SIZE                  uintptr = 48
	PJRT_Buffer_CopyRawToHost_Args_STRUCT_SIZE                                 uintptr = 56
	PJRT_Buffer_CopyToDevice_Args_STRUCT_SIZE                                  uintptr = 40
	PJRT_Buffer_CopyToMemory_Args_STRUCT_SIZE                                  uintptr = 40
	PJRT_Buffer_DecreaseExternalReferenceCount_Args_STRUCT_SIZE                uintptr = 24
	PJRT_Buffer_Delete_Args_STRUCT_SIZE                                        uintptr = 24
	PJRT_Buffer_Destroy_Args_STRUCT_SIZE                                       uintptr = 24
	PJRT_Buffer_Device_Args_STRUCT_SIZE                                        uintptr = 32
	PJRT_Buffer_Dimensions_Args_STRUCT_SIZE                                    uintptr = 40
	PJRT_Buffer_DonateWithControlDependency_Args_STRUCT_SIZE                   uintptr = 48
	PJRT_Buffer_DonateWithControlDependency_Callback_Args_STRUCT_SIZE          uintptr = 40
	PJRT_Buffer_DynamicDimensionIndices_Args_STRUCT_SIZE                       uintptr = 40
	PJRT_Buffer_ElementType_Args_STRUCT_SIZE                                   uintptr = 28
	PJRT_Buffer_GetMemoryLayout_Args_STRUCT_SIZE                               uintptr = 104
	PJRT_Buffer_IncreaseExternalReferenceCount_Args_STRUCT_SIZE                uintptr = 24
	PJRT_Buffer_IsDeleted_Args_STRUCT_SIZE                                     uintptr = 25
	PJRT_Buffer_IsOnCpu_Args_STRUCT_SIZE                                       uintptr = 25
	PJRT_Buffer_MemoryLayout_STRUCT_SIZE                                       uintptr = 76
	PJRT_Buffer_MemoryLayout_Strides_STRUCT_SIZE                               uintptr = 32
	PJRT_Buffer_MemoryLayout_Tiled_STRUCT_SIZE                                 uintptr = 56
	PJRT_Buffer_Memory_Args_STRUCT_SIZE                                        uintptr = 32
	PJRT_Buffer_OnDeviceSizeInBytes_Args_STRUCT_SIZE                           uintptr = 32
	PJRT_Buffer_OpaqueDeviceMemoryDataPointer_Args_STRUCT_SIZE                 uintptr = 32
	PJRT_Buffer_ReadyEvent_Args_STRUCT_SIZE                                    uintptr = 32
	PJRT_Buffer_ToHostBuffer_Args_STRUCT_SIZE                                  uintptr = 56
	PJRT_Buffer_UnpaddedDimensions_Args_STRUCT_SIZE                            uintptr = 40
	PJRT_Buffer_UnsafePointer_Args_STRUCT_SIZE                                 uintptr = 32
	PJRT_Client_AddressableDevices_Args_STRUCT_SIZE                            uintptr = 40
	PJRT_Client_AddressableMemories_Args_STRUCT_SIZE                           uintptr = 40
	PJRT_Client_BufferFromHostBuffer_Args_STRUCT_SIZE                          uintptr = 120
	PJRT_Client_Compile_Args_STRUCT_SIZE                                       uintptr = 56
	PJRT_Client_CreateAliasBuffer_Args_STRUCT_SIZE                             uintptr = 80
	PJRT_Client_CreateBuffersForAsyncHostToDevice_Args_STRUCT_SIZE             uintptr = 72
	PJRT_Client_CreateErrorBuffer_Args_STRUCT_SIZE                             uintptr = 112
	PJRT_Client_CreateUninitializedBuffer_Args_STRUCT_SIZE                     uintptr = 80
	PJRT_Client_CreateViewOfDeviceBuffer_Args_STRUCT_SIZE                      uintptr = 112
	PJRT_Client_Create_Args_STRUCT_SIZE                                        uintptr = 88
	PJRT_Client_DefaultDeviceAssignment_Args_STRUCT_SIZE                       uintptr = 48
	PJRT_Client_Destroy_Args_STRUCT_SIZE                                       uintptr = 24
	PJRT_Client_Devices_Args_STRUCT_SIZE                                       uintptr = 40
	PJRT_Client_DmaMap_Args_STRUCT_SIZE                                        uintptr = 40
	PJRT_Client_DmaUnmap_Args_STRUCT_SIZE                                      uintptr = 32
	PJRT_Client_FulfillAliasBuffer_Args_STRUCT_SIZE                            uintptr = 64
	PJRT_Client_Load_Args_STRUCT_SIZE                                          uintptr = 56
	PJRT_Client_LookupAddressableDevice_Args_STRUCT_SIZE                       uintptr = 40
	PJRT_Client_LookupDevice_Args_STRUCT_SIZE                                  uintptr = 40
	PJRT_Client_PlatformName_Args_STRUCT_SIZE                                  uintptr = 40
	PJRT_Client_PlatformVersion_Args_STRUCT_SIZE                               uintptr = 40
	PJRT_Client_ProcessIndex_Args_STRUCT_SIZE                                  uintptr = 28
	PJRT_Client_TopologyDescription_Args_STRUCT_SIZE                           uintptr = 32
	PJRT_Client_UpdateGlobalProcessInfo_Args_STRUCT_SIZE                       uintptr = 40
	PJRT_Compile_Args_STRUCT_SIZE                                              uintptr = 64
	PJRT_CopyToDeviceStream_AddChunk_Args_STRUCT_SIZE                          uintptr = 40
	PJRT_CopyToDeviceStream_CurrentBytes_Args_STRUCT_SIZE                      uintptr = 32
	PJRT_CopyToDeviceStream_Destroy_Args_STRUCT_SIZE                           uintptr = 24
	PJRT_CopyToDeviceStream_GranuleSize_Args_STRUCT_SIZE                       uintptr = 32
	PJRT_CopyToDeviceStream_TotalBytes_Args_STRUCT_SIZE                        uintptr = 32
	PJRT_DeviceDescription_Attributes_Args_STRUCT_SIZE                         uintptr = 40
	PJRT_DeviceDescription_DebugString_Args_STRUCT_SIZE                        uintptr = 40
	PJRT_DeviceDescription_Id_Args_STRUCT_SIZE                                 uintptr = 28
	PJRT_DeviceDescription_Kind_Args_STRUCT_SIZE                               uintptr = 40
	PJRT_DeviceDescription_ProcessIndex_Args_STRUCT_SIZE                       uintptr = 28
	PJRT_DeviceDescription_ToString_Args_STRUCT_SIZE                           uintptr = 40
	PJRT_Device_AddressableMemories_Args_STRUCT_SIZE                           uintptr = 40
	PJRT_Device_ClearMemoryStats_Args_STRUCT_SIZE                              uintptr = 24
	PJRT_Device_CreateAsyncTrackingEvent_Args_STRUCT_SIZE                      uintptr = 48
	PJRT_Device_DefaultMemory_Args_STRUCT_SIZE                                 uintptr = 32
	PJRT_Device_GetAttributes_Args_STRUCT_SIZE                                 uintptr = 56
	PJRT_Device_GetDescription_Args_STRUCT_SIZE                                uintptr = 32
	PJRT_Device_IsAddressable_Args_STRUCT_SIZE                                 uintptr = 25
	PJRT_Device_LocalHardwareId_Args_STRUCT_SIZE                               uintptr = 28
	PJRT_Device_MemoryStats_Args_STRUCT_SIZE                                   uintptr = 201
	PJRT_Device_PoisonExecution_Args_STRUCT_SIZE                               uintptr = 72
	PJRT_Error_STRUCT_SIZE                                                     uintptr = 8
	PJRT_Error_Destroy_Args_STRUCT_SIZE                                        uintptr = 24
	PJRT_Error_ForEachPayload_Args_STRUCT_SIZE                                 uintptr = 40
	PJRT_Error_GetCode_Args_STRUCT_SIZE                                        uintptr = 28
	PJRT_Error_Message_Args_STRUCT_SIZE                                        uintptr = 40
	PJRT_Event_Await_Args_STRUCT_SIZE                                          uintptr = 24
	PJRT_Event_Create_Args_STRUCT_SIZE                                         uintptr = 24
	PJRT_Event_Destroy_Args_STRUCT_SIZE                                        uintptr = 24
	PJRT_Event_Error_Args_STRUCT_SIZE                                          uintptr = 24
	PJRT_Event_IsReady_Args_STRUCT_SIZE                                        uintptr = 25
	PJRT_Event_OnReady_Args_STRUCT_SIZE                                        uintptr = 40
	PJRT_Event_Set_Args_STRUCT_SIZE                                            uintptr = 48
	PJRT_Executable_DeserializeAndLoad_Args_STRUCT_SIZE                        uintptr = 72
	PJRT_Executable_Destroy_Args_STRUCT_SIZE                                   uintptr = 24
	PJRT_Executable_Fingerprint_Args_STRUCT_SIZE                               uintptr = 40
	PJRT_Executable_GetCompileOptions_Args_STRUCT_SIZE                         uintptr = 56
	PJRT_Executable_GetCompiledMemoryStats_Args_STRUCT_SIZE                    uintptr = 144
	PJRT_Executable_GetCostAnalysis_Args_STRUCT_SIZE                           uintptr = 40
	PJRT_Executable_Name_Args_STRUCT_SIZE                                      uintptr = 40
	PJRT_Executable_NumOutputs_Args_STRUCT_SIZE                                uintptr = 32
	PJRT_Executable_NumPartitions_Args_STRUCT_SIZE                             uintptr = 32
	PJRT_Executable_NumReplicas_Args_STRUCT_SIZE                               uintptr = 32
	PJRT_Executable_OptimizedProgram_Args_STRUCT_SIZE                          uintptr = 32
	PJRT_Executable_OutputDimensions_Args_STRUCT_SIZE                          uintptr = 48
	PJRT_Executable_OutputElementTypes_Args_STRUCT_SIZE                        uintptr = 40
	PJRT_Executable_OutputMemoryKinds_Args_STRUCT_SIZE                         uintptr = 48
	PJRT_Executable_ParameterMemoryKinds_Args_STRUCT_SIZE                      uintptr = 48
	PJRT_Executable_Serialize_Args_STRUCT_SIZE                                 uintptr = 56
	PJRT_Executable_SizeOfGeneratedCodeInBytes_Args_STRUCT_SIZE                uintptr = 32
	PJRT_ExecuteContext_Create_Args_STRUCT_SIZE                                uintptr = 24
	PJRT_ExecuteContext_Destroy_Args_STRUCT_SIZE                               uintptr = 24
	PJRT_ExecuteOptions_STRUCT_SIZE                                            uintptr = 144
	PJRT_Extension_Base_STRUCT_SIZE                                            uintptr = 24
	PJRT_HloOutputCallbackInfo_STRUCT_SIZE                                     uintptr = 32
	PJRT_KeyValueGetCallback_Args_STRUCT_SIZE                                  uintptr = 80
	PJRT_KeyValuePutCallback_Args_STRUCT_SIZE                                  uintptr = 64
	PJRT_KeyValueTryGetCallback_Args_STRUCT_SIZE                               uintptr = 72
	PJRT_LoadOptions_STRUCT_SIZE                                               uintptr = 32
	PJRT_LoadedExecutable_AddressableDeviceLogicalIds_Args_STRUCT_SIZE         uintptr = 40
	PJRT_LoadedExecutable_AddressableDevices_Args_STRUCT_SIZE                  uintptr = 40
	PJRT_LoadedExecutable_Delete_Args_STRUCT_SIZE                              uintptr = 24
	PJRT_LoadedExecutable_Destroy_Args_STRUCT_SIZE                             uintptr = 24
	PJRT_LoadedExecutable_Execute_Args_STRUCT_SIZE                             uintptr = 80
	PJRT_LoadedExecutable_Fingerprint_Args_STRUCT_SIZE                         uintptr = 40
	PJRT_LoadedExecutable_GetDeviceAssignment_Args_STRUCT_SIZE                 uintptr = 56
	PJRT_LoadedExecutable_GetExecutable_Args_STRUCT_SIZE                       uintptr = 32
	PJRT_LoadedExecutable_IsDeleted_Args_STRUCT_SIZE                           uintptr = 25
	PJRT_Memory_STRUCT_SIZE                                                    uintptr = 8
	PJRT_Memory_AddressableByDevices_Args_STRUCT_SIZE                          uintptr = 40
	PJRT_Memory_DebugString_Args_STRUCT_SIZE                                   uintptr = 40
	PJRT_Memory_Id_Args_STRUCT_SIZE                                            uintptr = 28
	PJRT_Memory_Kind_Args_STRUCT_SIZE                                          uintptr = 40
	PJRT_Memory_Kind_Id_Args_STRUCT_SIZE                                       uintptr = 28
	PJRT_Memory_ToString_Args_STRUCT_SIZE                                      uintptr = 40
	PJRT_NamedValue_STRUCT_SIZE                                                uintptr = 56
	PJRT_Plugin_Attributes_Args_STRUCT_SIZE                                    uintptr = 32
	PJRT_Plugin_Initialize_Args_STRUCT_SIZE                                    uintptr = 16
	PJRT_ProcessInfo_STRUCT_SIZE                                               uintptr = 48
	PJRT_Program_STRUCT_SIZE                                                   uintptr = 48
	PJRT_RecvCallbackInfo_STRUCT_SIZE                                          uintptr = 24
	PJRT_SendCallbackInfo_STRUCT_SIZE                                          uintptr = 24
	PJRT_ShapeSpec_STRUCT_SIZE                                                 uintptr = 36
	PJRT_TopologyDescription_Attributes_Args_STRUCT_SIZE                       uintptr = 40
	PJRT_TopologyDescription_Create_Args_STRUCT_SIZE                           uintptr = 56
	PJRT_TopologyDescription_Deserialize_Args_STRUCT_SIZE                      uintptr = 40
	PJRT_TopologyDescription_Destroy_Args_STRUCT_SIZE                          uintptr = 24
	PJRT_TopologyDescription_Fingerprint_Args_STRUCT_SIZE                      uintptr = 32
	PJRT_TopologyDescription_GetDeviceDescriptions_Args_STRUCT_SIZE            uintptr = 40
	PJRT_TopologyDescription_GetMemorySpaceKindIds_Args_STRUCT_SIZE            uintptr = 40
	PJRT_TopologyDescription_MakeCanonicalShapeForMemorySpace_Args_STRUCT_SIZE uintptr = 88
	PJRT_TopologyDescription_PlatformName_Args_STRUCT_SIZE                     uintptr = 40
	PJRT_TopologyDescription_PlatformVersion_Args_STRUCT_SIZE                  uintptr = 40
	PJRT_TopologyDescription_Serialize_Args_STRUCT_SIZE                        uintptr = 56
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {
	StructSize     uintptr
	ExtensionStart unsafe.Pointer
	ApiVersion     Api_Version
	// Frees `error`. `error` can be nullptr.
	Error_Destroy uintptr
	// Gets the human-readable reason for `error`. `message` has the lifetime of
	// `error`.
	Error_Message uintptr
	Error_GetCode uintptr
	// One-time plugin setup. Must be called before any other functions are called.
	Plugin_Initialize uintptr
	// Returns an array of plugin attributes which are key-value pairs. Common keys
	// include `xla_version`, `stablehlo_current_version`, and
	// `stablehlo_minimum_version`.
	Plugin_Attributes uintptr
	// Frees `event`. `event` can be `nullptr`.
	Event_Destroy uintptr
	// Returns true if this PJRT_Event has completed, including if an error has
	// occurred.
	Event_IsReady uintptr
	// Should only be called if PJRT_Event_IsReady returns true.
	// Returns `nullptr` if there is no error.
	// The returned error should be freed with `PJRT_Error_Destroy`.
	//
	// If `PJRT_Event_Await` has been called, this will return a pointer to an
	// identical error status as that call, as will subsequent calls to
	// `PJRT_Event_Error`. However, each of these `PJRT_Error *` pointers are
	// independent of `PJRT_Error *`s returned by other function calls, so they must
	// each be freed separately using `PJRT_Error_Destroy`.
	Event_Error uintptr
	// Blocks the calling thread until `event` is ready, then returns the error
	// status (with `nullptr` indicating no error). The returned status should be
	// freed with `PJRT_Error_Destroy`.
	Event_Await uintptr
	// Registers `callback` to be called once `event` is ready, with `event`'s
	// error status and a pointer to an object of the caller's choice as arguments.
	Event_OnReady uintptr
	// Creates and initializes a new PJRT_Client and returns in `client`.
	Client_Create uintptr
	// Shuts down and frees `client`. `client` can be nullptr.
	Client_Destroy uintptr
	// Returns a string that identifies the platform (e.g. "cpu", "gpu", "tpu").
	Client_PlatformName uintptr
	// Return the process index of this client. Always 0 in single-process
	// settings.
	Client_ProcessIndex uintptr
	// Returns a string containing human-readable, platform-specific version info
	// (e.g. the CUDA version on GPU or libtpu version on Cloud TPU).
	Client_PlatformVersion uintptr
	// Returns a list of all devices visible to the runtime, including addressable
	// and non-addressable devices.
	Client_Devices uintptr
	// Returns a list of devices that are addressable from the client.
	// Addressable devices are those that the client can issue commands to.
	// All devices are addressable in a single-process environment.
	Client_AddressableDevices uintptr
	// Returns a PJRT_Device* with the specified ID as returned by
	// PJRT_DeviceDescription_Id.
	Client_LookupDevice uintptr
	// Returns an addressable PJRT_Device* with the specified ID as returned by
	// PJRT_DeviceDescription_LocalHardwareId.
	Client_LookupAddressableDevice uintptr
	// Returns a list of memories that are addressable from the client. Addressable
	// memories are those that the client can directly transfer data to and from.
	// All memories are addressable in a single-process environment.
	Client_AddressableMemories uintptr
	// Compiles a program in specified format (such as MLIR or HLO) with given
	// `options`.
	Client_Compile                 uintptr
	Client_DefaultDeviceAssignment uintptr
	// Asynchronously copies a buffer stored on host to device memory.
	Client_BufferFromHostBuffer uintptr
	// The ID of this device. IDs are unique among devices of this type
	// (e.g. CPUs, GPUs). On multi-host platforms, this will be unique across all
	// hosts' devices.
	DeviceDescription_Id uintptr
	// The index of the process that this device belongs to, i.e. is addressable
	// from. This is not always identical to PJRT_Client_ProcessIndex in a
	// multi-process setting, where each client can see devices from all
	// processes, but only a subset of them are addressable and have the same
	// process_index as the client.
	DeviceDescription_ProcessIndex uintptr
	// Returns an array of device specific attributes with attribute name, value
	// and value type.
	DeviceDescription_Attributes uintptr
	// A vendor-dependent string that uniquely identifies the kind of device,
	// e.g., "Tesla V100-SXM2-16GB".
	DeviceDescription_Kind uintptr
	// Debug string suitable for logging when errors occur. Should be verbose
	// enough to describe the current device unambiguously.
	DeviceDescription_DebugString uintptr
	// Debug string suitable for reading by end users, should be reasonably terse,
	// for example: "CpuDevice(id=0)".
	DeviceDescription_ToString uintptr
	// Fetch the DeviceDescription associated with this device.
	Device_GetDescription uintptr
	// Whether client can issue command to this device.
	Device_IsAddressable uintptr
	// Opaque hardware ID, e.g., the CUDA device number. In general, not guaranteed
	// to be dense, and -1 if undefined.
	Device_LocalHardwareId uintptr
	// Returns the memories that a device can address.
	Device_AddressableMemories uintptr
	// Returns the default memory of a device, i.e. which memory data processed by
	// this device should be stored in by default.
	Device_DefaultMemory uintptr
	// Device memory/allocator statistics. All returned stats except `bytes_in_use`
	// are optional and may not be returned by all platforms. Implementations may
	// also return PJRT_Error_Code_UNIMPLEMENTED. Intended for diagnostic purposes.
	Device_MemoryStats uintptr
	// The ID of this memory. IDs are unique among memories of this type.
	Memory_Id uintptr
	// A platform-dependent string that uniquely identifies the kind of the memory.
	Memory_Kind uintptr
	// Debug string suitable for logging when errors occur. Should be verbose
	// enough to describe the current memory unambiguously.
	Memory_DebugString uintptr
	// Debug string suitable for reading by end users, should be reasonably terse.
	Memory_ToString uintptr
	// Returns the devices that can address this memory.
	Memory_AddressableByDevices uintptr
	// Frees `executable`. `executable` can be nullptr.
	Executable_Destroy uintptr
	// Returns a string that identifies the executable.
	Executable_Name uintptr
	// Returns the number of replicas of the executable.
	Executable_NumReplicas uintptr
	// Returns the number of partitions of the executable.
	Executable_NumPartitions uintptr
	// Gets the number of outputs per device produced by `executable`.
	Executable_NumOutputs                 uintptr
	Executable_SizeOfGeneratedCodeInBytes uintptr
	// Get the cost properties for the executable. Different platforms may return
	// different properties; for example, some platforms may return the number of
	// operations, or memory size of the input/output of the executable, based on
	// program analysis.
	Executable_GetCostAnalysis uintptr
	// Returns a list of memory kind strings for outputs.
	Executable_OutputMemoryKinds uintptr
	// Retrieves the optimized program for a given PJRT_Executable (SPMD).
	// The caller should populate `program->format` and `format_size`.
	//
	// The implementation will set `program->format` and `program->format_size`
	// to inform callers of the format of the optimized program returned.
	// These members are owned by the implementation.
	//
	// If called with nullptr as `program->code`, `PJRT_Executable_OptimizedProgram`
	// will populate `program->code_size` as an output indicating the number of
	// bytes the string `program->code` requires.
	//
	// If `program->code` is not null, `PJRT_Executable_OptimizedProgram` will fill
	// the buffer pointed to by `program->code` with the serialization of the
	// optimized HLO program. `program->code` must point to a client-owned buffer of
	// size >= `program->code_size`, which must be at large enough to hold the
	// serialization of the optimized program.
	//
	// Callers should generally call this function twice with the same `args`.
	// In the first call, `program->code` must be nullptr. This call will populate
	// `program->code_size`. Clients should then allocate a buffer `code_buff` of at
	// least `code_size` bytes. Before the second call, callers should set
	// `program->code = code_buff`. The second call will then write the serialized
	// program to `code_buff`.
	Executable_OptimizedProgram uintptr
	// Returns a platform-specific serialization of `executable`. The serialization
	// is not guaranteed to be stable over time.
	Executable_Serialize uintptr
	// Frees `executable` and deletes the underlying runtime object as if
	// `PJRT_LoadedExecutable_Delete` were called. `executable` can be nullptr.
	LoadedExecutable_Destroy uintptr
	// Constructs a PJRT_Executable from a PJRT_LoadedExecutable. The returned
	// executable should be freed by the caller with PJRT_Executable_Destroy.
	LoadedExecutable_GetExecutable uintptr
	// Returns a list of devices this executable will run on.
	LoadedExecutable_AddressableDevices uintptr
	// Drops `executable`'s reference to the internal runtime object and
	// associated resources, without freeing the `executable` object itself.
	// `executable` can only be used with PJRT_LoadedExecutable_IsDeleted and
	// PJRT_LoadedExecutable_Destroy after calling this method. The internal runtime
	// executable will be freed after the last execution completes.
	LoadedExecutable_Delete uintptr
	// True if and only if PJRT_LoadedExecutable_Delete has previously been called.
	LoadedExecutable_IsDeleted uintptr
	// Executes on devices addressable by the client.
	LoadedExecutable_Execute uintptr
	// Deserializes an executable serialized by `PJRT_Executable_Serialize`.
	// `serialized_executable` must have been produced by the same platform and
	// library version as this one.
	Executable_DeserializeAndLoad uintptr
	// DEPRECATED. Will be removed in PJRT version 2.0. Please use
	// PJRT_Executable_Fingerprint instead. A unique fingerprint for `executable`.
	// Two executables that were produced by compiling with identical inputs (same
	// program, compile options, compiler version, etc.) should have the same
	// fingerprint. May not be implemented by all platforms.
	LoadedExecutable_Fingerprint uintptr
	// Deletes the underlying runtime objects as if 'PJRT_Buffer_Delete' were
	// called and frees `buffer`. `buffer` can be nullptr.
	Buffer_Destroy uintptr
	// Returns the type of the array elements of a buffer.
	Buffer_ElementType uintptr
	// Returns the array shape of `buffer`, i.e. the size of each dimension.
	Buffer_Dimensions uintptr
	// Returns the unpadded array shape of `buffer`. This usually is equivalent to
	// PJRT_Buffer_Dimensions, but for implementations that support
	// dynamically-sized dimensions via padding to a fixed size, any dynamic
	// dimensions may have a smaller unpadded size than the padded size reported by
	// PJRT_Buffer_Dimensions. ("Dynamic" dimensions are those whose length is
	// only known at runtime, vs. "static" dimensions whose size is fixed at compile
	// time.)
	Buffer_UnpaddedDimensions uintptr
	// Returns the indices of dynamically-sized dimensions, or an empty list if all
	// dimensions are static. ("Dynamic" dimensions are those whose length is
	// only known at runtime, vs. "static" dimensions whose size is fixed at compile
	// time.)
	Buffer_DynamicDimensionIndices uintptr
	// DEPRECATED. Please use layout extension instead.
	// https://github.com/openxla/xla/blob/main/xla/pjrt/c/pjrt_c_api_layouts_extension.h
	// Returns the memory layout of the data in this buffer.
	Buffer_GetMemoryLayout uintptr
	// Gets the number of bytes of the buffer storage on the device
	Buffer_OnDeviceSizeInBytes uintptr
	// Returns this buffer's storage device.
	Buffer_Device uintptr
	// Returns this buffer's storage memory.
	Buffer_Memory uintptr
	// Drop the buffer's reference to its associated device memory, without freeing
	// the `buffer` object itself. `buffer` can only be used with
	// PJRT_Buffer_IsDeleted and PJRT_Buffer_Destroy after calling this method. The
	// device memory will be freed when all async operations using the buffer have
	// completed, according to the allocation semantics of the underlying platform.
	Buffer_Delete uintptr
	// True if and only if PJRT_Buffer_Delete has previously been called.
	Buffer_IsDeleted uintptr
	// Copies the buffer to device `dst_device` within the same client. Caller is
	// responsible for freeing returned `dst_buffer` with PJRT_Buffer_Destroy.
	// Returns an error if the buffer is already on `dst_device`.
	Buffer_CopyToDevice uintptr
	// Asynchronously copies the buffer's value into a preallocated host buffer.
	Buffer_ToHostBuffer uintptr
	// Whether this buffer is on CPU and thus allows for certain optimizations.
	Buffer_IsOnCpu uintptr
	// Returns an event that is triggered when either of the following happens:
	// * the data in the PJRT_Buffer becomes ready, or
	// * an error has occurred.
	//
	// TODO(b/241967811): change these weird semantics
	// If the buffer has been deleted or donated, the returned event will
	// immediately indicate an error. However, if PJRT_Buffer_ReadyEvent() is
	// called on the buffer before PJRT_Buffer_Delete() is, the returned event will
	// not transition to an error state after PJRT_Buffer_Delete() is called.
	Buffer_ReadyEvent uintptr
	// Returns platform-dependent address for the given buffer that is often but
	// not guaranteed to be the physical/device address.
	Buffer_UnsafePointer uintptr
	// Increments the reference count for the buffer. The reference count indicates
	// the raw buffer data is being shared with another framework (e.g. NumPy,
	// dlpack) and should not be deleted or moved by the PJRT implementation (e.g.
	// for memory compaction). TODO(b/295230663): document more API contract
	// details, e.g. does this block, can the buffer be modified in-place.
	Buffer_IncreaseExternalReferenceCount uintptr
	// Decrements the reference count for the buffer. Returns an error if the
	// reference count is zero (i.e. PJRT_Buffer_IncreaseExternalReferenceCount is
	// not called beforehand).
	Buffer_DecreaseExternalReferenceCount uintptr
	// Returns the opaque device memory data pointer of the buffer. The returned
	// data pointer may become invalid at any point unless the external reference
	// count is greater than 0 via PJRT_Buffer_IncreaseExternalReferenceCount.
	Buffer_OpaqueDeviceMemoryDataPointer uintptr
	// Frees `stream`. `stream` can be nullptr.
	CopyToDeviceStream_Destroy uintptr
	// Emplaces a new chunk of data to copy to the device. The transfer is started
	// immediately, and the returned event is triggered when the transfer completes
	// or fails.
	//
	// The returned event will indicate an error if the chunk's size causes the
	// amount of transferred data to exceed the total bytes, if the stream is
	// already complete, or if the chunk is not a multiple of the granule size.
	CopyToDeviceStream_AddChunk uintptr
	// Returns the total amount of data the stream expects to be transferred.
	CopyToDeviceStream_TotalBytes uintptr
	// Returns the granule size in bytes. The size of the chunk added to this stream
	// must be a multiple of this number.
	CopyToDeviceStream_GranuleSize uintptr
	// Returns the amount of data the stream currently has either transferred or has
	// buffered to transfer.
	CopyToDeviceStream_CurrentBytes uintptr
	// Creates and initializes a new PJRT_TopologyDescription and returns in
	// `topology`.
	TopologyDescription_Create uintptr
	// Frees `topology`. `topology` can be nullptr.
	TopologyDescription_Destroy uintptr
	// Returns a string that identifies the platform (e.g. "cpu", "gpu", "tpu").
	TopologyDescription_PlatformName uintptr
	// Returns a string containing human-readable, platform-specific version info
	// (e.g. the CUDA version on GPU or libtpu version on Cloud TPU).
	TopologyDescription_PlatformVersion uintptr
	// Returns descriptions for all devices in this topology. The device
	// descriptions can be returned in any order, but will be in the same order
	// across calls within a process.
	TopologyDescription_GetDeviceDescriptions uintptr
	// Serializes the TopologyDescription to a string for use in cache keys.
	TopologyDescription_Serialize uintptr
	// Returns platform-specific topology attributes.
	TopologyDescription_Attributes uintptr
	// Compiles a program in specified format (such as MLIR or HLO) with given
	// `options`. The returned executable must be loaded by a compatible
	// PJRT_Client before execution.
	Compile uintptr
	// Returns a list of element types for outputs.
	Executable_OutputElementTypes uintptr
	// Returns a list of dimensions for outputs. Each output has an array shape,
	// which is represented by a list of dimensions. The array shapes of all outputs
	// are concatenated into a single list of dimensions.
	Executable_OutputDimensions uintptr
	// Copies the buffer to memory `dst_memory` within the same client. Caller is
	// responsible for freeing returned `dst_buffer` with PJRT_Buffer_Destroy.
	// Returns an error if the buffer is already on `dst_memory`.
	Buffer_CopyToMemory uintptr
	// Creates a PJRT buffer that is a non-owned view of an on-device buffer
	// (typically allocated by another library). The buffer may be mutated,
	// for example, if the buffer is donated to an Execute operation. This method is
	// not required on all hardware platforms.
	Client_CreateViewOfDeviceBuffer uintptr
	// A unique fingerprint for `executable`. Two executables that were produced by
	// compiling with identical inputs (same program, compile options, compiler
	// version, etc.) should have the same fingerprint. May not be implemented by
	// all platforms.
	Executable_Fingerprint uintptr
	// Returns the topology description of the runtime topology. The returned
	// topology is owned by the client and should not be deleted by the caller.
	Client_TopologyDescription uintptr
	// Return memory stats that allow callers to estimate memory usage when running
	// this executable. The memory stats could contain usage info from different
	// memory spaces, like default memory (e.g., HBM for GPU/TPU) and host memory.
	Executable_GetCompiledMemoryStats uintptr
	// A platform-dependent ID that uniquely identifies the kind of the memory.
	Memory_Kind_Id uintptr
	// Creates an execute context.
	ExecuteContext_Create uintptr
	// Frees an execute context. `context` can be nullptr.
	ExecuteContext_Destroy uintptr
	Buffer_CopyRawToHost   uintptr
	// Frees `transfer_manager`. `transfer_manager` can be nullptr.
	AsyncHostToDeviceTransferManager_Destroy        uintptr
	AsyncHostToDeviceTransferManager_TransferData   uintptr
	Client_CreateBuffersForAsyncHostToDevice        uintptr
	AsyncHostToDeviceTransferManager_RetrieveBuffer uintptr
	AsyncHostToDeviceTransferManager_Device         uintptr
	AsyncHostToDeviceTransferManager_BufferCount    uintptr
	AsyncHostToDeviceTransferManager_BufferSize     uintptr
	AsyncHostToDeviceTransferManager_SetBufferError uintptr
	AsyncHostToDeviceTransferManager_AddMetadata    uintptr
	Client_DmaMap                                   uintptr
	Client_DmaUnmap                                 uintptr
	Client_CreateUninitializedBuffer                uintptr
	// Updates the PjRt client with information about all global processes.
	//
	// Recall that a distributed program may consist of multiple PjRt clients
	// spanning multiple machines. These clients perform collective operations, like
	// AllGather, to execute a distributed program. UpdateGlobalProcessInfo updates
	// a PjRt client with information about all processes.
	Client_UpdateGlobalProcessInfo  uintptr
	TopologyDescription_Deserialize uintptr
	Client_CreateAliasBuffer        uintptr
	Client_FulfillAliasBuffer       uintptr
	// Retrieves the serialized DeviceAssignmentProto for a given
	// PJRT_LoadedExecutable. The implementation allocates the serialized data,
	// which is valid as long as `serialized_device_assignment` is alive. The
	// caller must call `serialized_device_assignment_deleter` to free the
	// backing memory.
	LoadedExecutable_GetDeviceAssignment uintptr
	// Creates a buffer in the given memory space that carries an error future
	// without allocating memory. If this buffer is passed to an Execute call, the
	// execution will fail with the given error code and message.
	Client_CreateErrorBuffer uintptr
	// Asynchronously copies a host literal to a buffer managed by a transfer
	// manager.
	AsyncHostToDeviceTransferManager_TransferLiteral uintptr
	// Similar to PJRT_Buffer_CopyRawToHost, but the transfer will not happen until
	// `future_ready_callback` is invoked.
	Buffer_CopyRawToHostFuture uintptr
	// Poisons the earliest execution on this device with given launch_id if it's
	// not finished yet, i.e. makes its output buffers error.
	Device_PoisonExecution uintptr
	// Creates an async tracking event. The caller is responsible for destroying the
	// event.
	Device_CreateAsyncTrackingEvent uintptr
	// Destroys the async tracking event.
	AsyncTrackingEvent_Destroy uintptr
	// Returns the CompileOptions that were used to compile this executable.
	Executable_GetCompileOptions       uintptr
	Buffer_DonateWithControlDependency uintptr
	// Creates a new PJRT_Event.
	Event_Create uintptr
	// Sets the PJRT_Event as completed with the given error code and message.
	Event_Set uintptr
	// Returns an array of device attributes.
	Device_GetAttributes uintptr
	// Loads a PJRT_Executable.
	Client_Load uintptr
	// Returns a list of logical device ids this executable will run on.
	LoadedExecutable_AddressableDeviceLogicalIds uintptr
	// Bitcasts the buffer to a new type, dimensions, and layout.
	Buffer_Bitcast uintptr
	// Iterates over the stored payloads and calls the `visitor`
	// callable for each one.
	Error_ForEachPayload            uintptr
	TopologyDescription_Fingerprint uintptr
	// Returns a list of memory kind strings for parameters.
	Executable_ParameterMemoryKinds                      uintptr
	Device_ClearMemoryStats                              uintptr
	TopologyDescription_MakeCanonicalShapeForMemorySpace uintptr
	TopologyDescription_GetMemorySpaceKindIds            uintptr
}

Api represents the PJRT_Api function table.

type Api_Version

type Api_Version struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Major_version   int32
	Minor_version   int32
}

The plugin should set the major_version and minor_version of PJRT_Api.pjrt_api_version to be the `PJRT_API_MAJOR` and `PJRT_API_MINOR` in this header that the implementation was compiled with.

type AsyncHostToDeviceTransferManager

type AsyncHostToDeviceTransferManager struct{}

AsyncHostToDeviceTransferManager is an opaque PJRT handle.

type AsyncHostToDeviceTransferManager_AddMetadata_Args

type AsyncHostToDeviceTransferManager_AddMetadata_Args struct {
	Struct_size       uintptr
	Extension_start   *Extension_Base
	Transfer_manager  *AsyncHostToDeviceTransferManager
	Transfer_metadata *NamedValue
	Num_metadata      uintptr
}

AsyncHostToDeviceTransferManager_AddMetadata_Args represents PJRT_AsyncHostToDeviceTransferManager_AddMetadata_Args.

type AsyncHostToDeviceTransferManager_BufferCount_Args

type AsyncHostToDeviceTransferManager_BufferCount_Args struct {
	Struct_size      uintptr
	Extension_start  *Extension_Base
	Transfer_manager *AsyncHostToDeviceTransferManager
	Buffer_count     uintptr
}

AsyncHostToDeviceTransferManager_BufferCount_Args represents PJRT_AsyncHostToDeviceTransferManager_BufferCount_Args.

type AsyncHostToDeviceTransferManager_BufferSize_Args

type AsyncHostToDeviceTransferManager_BufferSize_Args struct {
	Struct_size      uintptr
	Extension_start  *Extension_Base
	Transfer_manager *AsyncHostToDeviceTransferManager
	Buffer_index     int32
	Buffer_size      uintptr
}

AsyncHostToDeviceTransferManager_BufferSize_Args represents PJRT_AsyncHostToDeviceTransferManager_BufferSize_Args.

type AsyncHostToDeviceTransferManager_Destroy_Args

type AsyncHostToDeviceTransferManager_Destroy_Args struct {
	Struct_size      uintptr
	Extension_start  *Extension_Base
	Transfer_manager *AsyncHostToDeviceTransferManager
}

AsyncHostToDeviceTransferManager_Destroy_Args represents PJRT_AsyncHostToDeviceTransferManager_Destroy_Args.

type AsyncHostToDeviceTransferManager_Device_Args

type AsyncHostToDeviceTransferManager_Device_Args struct {
	Struct_size      uintptr
	Extension_start  *Extension_Base
	Transfer_manager *AsyncHostToDeviceTransferManager
	Device_out       *Device
}

AsyncHostToDeviceTransferManager_Device_Args represents PJRT_AsyncHostToDeviceTransferManager_Device_Args.

type AsyncHostToDeviceTransferManager_RetrieveBuffer_Args

type AsyncHostToDeviceTransferManager_RetrieveBuffer_Args struct {
	Struct_size      uintptr
	Extension_start  *Extension_Base
	Transfer_manager *AsyncHostToDeviceTransferManager
	Buffer_index     int32
	Buffer_out       *Buffer
}

AsyncHostToDeviceTransferManager_RetrieveBuffer_Args represents PJRT_AsyncHostToDeviceTransferManager_RetrieveBuffer_Args.

type AsyncHostToDeviceTransferManager_SetBufferError_Args

type AsyncHostToDeviceTransferManager_SetBufferError_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Transfer_manager   *AsyncHostToDeviceTransferManager
	Buffer_index       int32
	Error_code         Error_Code
	Error_message      *byte
	Error_message_size uintptr
}

AsyncHostToDeviceTransferManager_SetBufferError_Args represents PJRT_AsyncHostToDeviceTransferManager_SetBufferError_Args.

type AsyncHostToDeviceTransferManager_TransferData_Args

type AsyncHostToDeviceTransferManager_TransferData_Args struct {
	Struct_size            uintptr
	Extension_start        *Extension_Base
	Transfer_manager       *AsyncHostToDeviceTransferManager
	Buffer_index           int32
	Data                   unsafe.Pointer
	Offset                 int64
	Transfer_size          int64
	Is_last_transfer       bool
	Done_with_h2d_transfer *Event
}

AsyncHostToDeviceTransferManager_TransferData_Args represents PJRT_AsyncHostToDeviceTransferManager_TransferData_Args.

type AsyncHostToDeviceTransferManager_TransferLiteral_Args

type AsyncHostToDeviceTransferManager_TransferLiteral_Args struct {
	Struct_size            uintptr
	Extension_start        *Extension_Base
	Transfer_manager       *AsyncHostToDeviceTransferManager
	Buffer_index           int32
	Data                   unsafe.Pointer
	Shape_dims             *int64
	Shape_num_dims         uintptr
	Shape_element_type     Buffer_Type
	Shape_layout           *Buffer_MemoryLayout
	Done_with_h2d_transfer *Event
}

AsyncHostToDeviceTransferManager_TransferLiteral_Args represents PJRT_AsyncHostToDeviceTransferManager_TransferLiteral_Args.

type AsyncTrackingEvent

type AsyncTrackingEvent struct{}

AsyncTrackingEvent is an opaque PJRT handle.

type AsyncTrackingEvent_Destroy_Args

type AsyncTrackingEvent_Destroy_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Event           *AsyncTrackingEvent
}

AsyncTrackingEvent_Destroy_Args represents PJRT_AsyncTrackingEvent_Destroy_Args.

type Buffer

type Buffer struct{}

Buffer is an opaque PJRT handle.

type BufferWrapper

type BufferWrapper struct {
	// contains filtered or unexported fields
}

BufferWrapper wraps an on-device PJRT Buffer.

func (*BufferWrapper) DecreaseExternalReferenceCount

func (b *BufferWrapper) DecreaseExternalReferenceCount() error

DecreaseExternalReferenceCount releases one reference previously acquired by IncreaseExternalReferenceCount. The buffer must remain open until this returns.

Example
package main

import (
	"fmt"
	"github.com/tmc/lib/openxla"
)

func main() {
	var buffer openxla.BufferWrapper
	fmt.Println(buffer.DecreaseExternalReferenceCount())
}
Output:
openxla: buffer is closed

func (*BufferWrapper) Destroy

func (b *BufferWrapper) Destroy() error

Destroy destroys the on-device buffer.

func (*BufferWrapper) Device

func (b *BufferWrapper) Device() (*Device, error)

Device returns the device on which the buffer resides.

Example
package main

import (
	"fmt"

	"github.com/tmc/lib/openxla"
)

func main() {
	var b openxla.BufferWrapper
	_, err := b.Device()
	fmt.Println(err)
}
Output:
openxla: buffer is closed

func (*BufferWrapper) IncreaseExternalReferenceCount

func (b *BufferWrapper) IncreaseExternalReferenceCount() error

IncreaseExternalReferenceCount prevents PJRT from moving or deleting the buffer's storage until the matching DecreaseExternalReferenceCount call. The buffer and client must remain open, and callers must serialize reference operations with each other and with Destroy. This does not wait for readiness.

Example
package main

import (
	"fmt"
	"github.com/tmc/lib/openxla"
)

func main() {
	var buffer openxla.BufferWrapper
	fmt.Println(buffer.IncreaseExternalReferenceCount())
}
Output:
openxla: buffer is closed

func (*BufferWrapper) IsDenseRowMajor

func (b *BufferWrapper) IsDenseRowMajor() (bool, error)

IsDenseRowMajor reports whether the buffer has an untiled, dense row-major layout. Other layout representations return false. This query uses the legacy PJRT layout API and does not establish CPU accessibility or readiness.

Example
package main

import (
	"fmt"
	"github.com/tmc/lib/openxla"
)

func main() {
	var buffer openxla.BufferWrapper
	_, err := buffer.IsDenseRowMajor()
	fmt.Println(err)
}
Output:
openxla: buffer is closed

func (*BufferWrapper) IsOnCPU

func (b *BufferWrapper) IsOnCPU() (bool, error)

IsOnCPU reports whether PJRT stores this buffer on the CPU. It does not establish that its address may be exposed to Go.

Example
package main

import (
	"fmt"
	"github.com/tmc/lib/openxla"
)

func main() {
	var buffer openxla.BufferWrapper
	_, err := buffer.IsOnCPU()
	fmt.Println(err)
}
Output:
openxla: buffer is closed

func (*BufferWrapper) OnDeviceSizeInBytes

func (b *BufferWrapper) OnDeviceSizeInBytes() (uint64, error)

OnDeviceSizeInBytes reports the size of this buffer's device storage.

Example
package main

import (
	"fmt"
	"github.com/tmc/lib/openxla"
)

func main() {
	var buffer openxla.BufferWrapper
	_, err := buffer.OnDeviceSizeInBytes()
	fmt.Println(err)
}
Output:
openxla: buffer is closed

func (*BufferWrapper) OpaqueDeviceMemoryDataPointer

func (b *BufferWrapper) OpaqueDeviceMemoryDataPointer() (unsafe.Pointer, error)

OpaqueDeviceMemoryDataPointer returns a plugin-specific device memory pointer. The caller must hold a positive external reference count for the entire use of the pointer. This method does not establish CPU accessibility, readiness, element layout, or permission to mutate memory. A nil pointer may describe an empty allocation; the caller must check its expected storage size.

Example
package main

import (
	"fmt"
	"github.com/tmc/lib/openxla"
)

func main() {
	var buffer openxla.BufferWrapper
	_, err := buffer.OpaqueDeviceMemoryDataPointer()
	fmt.Println(err)
}
Output:
openxla: buffer is closed

func (*BufferWrapper) Shape

func (b *BufferWrapper) Shape() (Buffer_Type, []int64, error)

Shape returns the buffer's element type and a copy of its dimensions.

Example
package main

import (
	"fmt"

	"github.com/tmc/lib/openxla"
)

func main() {
	// A zero buffer has no native resource to query.
	var buffer openxla.BufferWrapper
	_, _, err := buffer.Shape()
	fmt.Println(err)
}
Output:
openxla: buffer is closed

func (*BufferWrapper) ToHost

func (b *BufferWrapper) ToHost(dst unsafe.Pointer, dstSize uintptr) error

ToHost copies on-device buffer data to host memory synchronously. The caller must not access dst until the call returns. Go allocations are pinned until the completion event has been awaited and destroyed.

func (*BufferWrapper) WaitReady

func (b *BufferWrapper) WaitReady() error

WaitReady waits for this buffer's producer to finish.

Example
package main

import (
	"fmt"
	"github.com/tmc/lib/openxla"
)

func main() {
	var buffer openxla.BufferWrapper
	fmt.Println(buffer.WaitReady())
}
Output:
openxla: buffer is closed

type Buffer_Bitcast_Args

type Buffer_Bitcast_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Element_type    Buffer_Type
	Dims            *int64
	Num_dims        uintptr
	Device_layout   *Buffer_MemoryLayout
	Out_buffer      *Buffer
}

Buffer_Bitcast_Args represents PJRT_Buffer_Bitcast_Args.

type Buffer_CopyRawToHostFuture_Args

type Buffer_CopyRawToHostFuture_Args struct {
	Struct_size           uintptr
	Extension_start       *Extension_Base
	Buffer                *Buffer
	Offset                int64
	Transfer_size         int64
	Event                 *Event
	Callback_data         unsafe.Pointer
	Future_ready_callback uintptr
}

Buffer_CopyRawToHostFuture_Args represents PJRT_Buffer_CopyRawToHostFuture_Args.

type Buffer_CopyRawToHostFuture_Callback_Args

type Buffer_CopyRawToHostFuture_Callback_Args struct {
	Struct_size        uintptr
	Callback_data      unsafe.Pointer
	Error_code         Error_Code
	Error_message      *byte
	Error_message_size uintptr
	Dst                unsafe.Pointer
}

Buffer_CopyRawToHostFuture_Callback_Args represents PJRT_Buffer_CopyRawToHostFuture_Callback_Args.

type Buffer_CopyRawToHost_Args

type Buffer_CopyRawToHost_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Dst             unsafe.Pointer
	Offset          int64
	Transfer_size   int64
	Event           *Event
}

Buffer_CopyRawToHost_Args represents PJRT_Buffer_CopyRawToHost_Args.

type Buffer_CopyToDevice_Args

type Buffer_CopyToDevice_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Dst_device      *Device
	Dst_buffer      *Buffer
}

Buffer_CopyToDevice_Args represents PJRT_Buffer_CopyToDevice_Args.

type Buffer_CopyToMemory_Args

type Buffer_CopyToMemory_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Dst_memory      *Memory
	Dst_buffer      *Buffer
}

Buffer_CopyToMemory_Args represents PJRT_Buffer_CopyToMemory_Args.

type Buffer_DecreaseExternalReferenceCount_Args

type Buffer_DecreaseExternalReferenceCount_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
}

Buffer_DecreaseExternalReferenceCount_Args represents PJRT_Buffer_DecreaseExternalReferenceCount_Args.

type Buffer_Delete_Args

type Buffer_Delete_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
}

Buffer_Delete_Args represents PJRT_Buffer_Delete_Args.

type Buffer_Destroy_Args

type Buffer_Destroy_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
}

---------------------------------- Buffers ----------------------------------

type Buffer_Device_Args

type Buffer_Device_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Device          *Device
}

Buffer_Device_Args represents PJRT_Buffer_Device_Args.

type Buffer_Dimensions_Args

type Buffer_Dimensions_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Dims            *int64
	Num_dims        uintptr
}

Buffer_Dimensions_Args represents PJRT_Buffer_Dimensions_Args.

type Buffer_DonateWithControlDependency_Args

type Buffer_DonateWithControlDependency_Args struct {
	Struct_size               uintptr
	Extension_start           *Extension_Base
	Buffer                    *Buffer
	Callback_data             unsafe.Pointer
	Dependency_ready_callback uintptr
	Out_buffer                *Buffer
}

Buffer_DonateWithControlDependency_Args represents PJRT_Buffer_DonateWithControlDependency_Args.

type Buffer_DonateWithControlDependency_Callback_Args

type Buffer_DonateWithControlDependency_Callback_Args struct {
	Struct_size        uintptr
	Callback_data      unsafe.Pointer
	Error_code         Error_Code
	Error_message      *byte
	Error_message_size uintptr
}

Buffer_DonateWithControlDependency_Callback_Args represents PJRT_Buffer_DonateWithControlDependency_Callback_Args.

type Buffer_DynamicDimensionIndices_Args

type Buffer_DynamicDimensionIndices_Args struct {
	Struct_size         uintptr
	Extension_start     *Extension_Base
	Buffer              *Buffer
	Dynamic_dim_indices *uintptr
	Num_dynamic_dims    uintptr
}

Buffer_DynamicDimensionIndices_Args represents PJRT_Buffer_DynamicDimensionIndices_Args.

type Buffer_ElementType_Args

type Buffer_ElementType_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Type            Buffer_Type
}

Buffer_ElementType_Args represents PJRT_Buffer_ElementType_Args.

type Buffer_GetMemoryLayout_Args

type Buffer_GetMemoryLayout_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Layout          Buffer_MemoryLayout
}

Buffer_GetMemoryLayout_Args represents PJRT_Buffer_GetMemoryLayout_Args.

type Buffer_IncreaseExternalReferenceCount_Args

type Buffer_IncreaseExternalReferenceCount_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
}

Buffer_IncreaseExternalReferenceCount_Args represents PJRT_Buffer_IncreaseExternalReferenceCount_Args.

type Buffer_IsDeleted_Args

type Buffer_IsDeleted_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Is_deleted      bool
}

Buffer_IsDeleted_Args represents PJRT_Buffer_IsDeleted_Args.

type Buffer_IsOnCpu_Args

type Buffer_IsOnCpu_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Is_on_cpu       bool
}

Buffer_IsOnCpu_Args represents PJRT_Buffer_IsOnCpu_Args.

type Buffer_MemoryLayout

type Buffer_MemoryLayout struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Union_pad       Buffer_MemoryLayout_Tiled
	Type            Buffer_MemoryLayout_Type
}

Describe the memory layout. It can be (1) a list of minor-to-major order and optional tilings (each tile is a list of dimensions), or (2) a list of strides.

type Buffer_MemoryLayout_Strides

type Buffer_MemoryLayout_Strides struct {
	Struct_size      uintptr
	Extension_start  *Extension_Base
	Byte_strides     *int64
	Num_byte_strides uintptr
}

Buffer_MemoryLayout_Strides represents PJRT_Buffer_MemoryLayout_Strides.

type Buffer_MemoryLayout_Tiled

type Buffer_MemoryLayout_Tiled struct {
	Struct_size         uintptr
	Extension_start     *Extension_Base
	Minor_to_major      *int64
	Minor_to_major_size uintptr
	Tile_dims           *int64
	Tile_dim_sizes      *uintptr
	Num_tiles           uintptr
}

Buffer_MemoryLayout_Tiled represents PJRT_Buffer_MemoryLayout_Tiled.

type Buffer_MemoryLayout_Type

type Buffer_MemoryLayout_Type int32

Buffer_MemoryLayout_Type represents PJRT_Buffer_MemoryLayout_Type.

const (
	Buffer_MemoryLayout_Type_Tiled   Buffer_MemoryLayout_Type = 0
	Buffer_MemoryLayout_Type_Strides Buffer_MemoryLayout_Type = 1
)

type Buffer_Memory_Args

type Buffer_Memory_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Memory          *Memory
}

Buffer_Memory_Args represents PJRT_Buffer_Memory_Args.

type Buffer_OnDeviceSizeInBytes_Args

type Buffer_OnDeviceSizeInBytes_Args struct {
	Struct_size             uintptr
	Extension_start         *Extension_Base
	Buffer                  *Buffer
	On_device_size_in_bytes uintptr
}

Buffer_OnDeviceSizeInBytes_Args represents PJRT_Buffer_OnDeviceSizeInBytes_Args.

type Buffer_OpaqueDeviceMemoryDataPointer_Args

type Buffer_OpaqueDeviceMemoryDataPointer_Args struct {
	Struct_size       uintptr
	Extension_start   *Extension_Base
	Buffer            *Buffer
	Device_memory_ptr unsafe.Pointer
}

Buffer_OpaqueDeviceMemoryDataPointer_Args represents PJRT_Buffer_OpaqueDeviceMemoryDataPointer_Args.

type Buffer_ReadyEvent_Args

type Buffer_ReadyEvent_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Event           *Event
}

Buffer_ReadyEvent_Args represents PJRT_Buffer_ReadyEvent_Args.

type Buffer_ToHostBuffer_Args

type Buffer_ToHostBuffer_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Src             *Buffer
	Host_layout     *Buffer_MemoryLayout
	Dst             unsafe.Pointer
	Dst_size        uintptr
	Event           *Event
}

Buffer_ToHostBuffer_Args represents PJRT_Buffer_ToHostBuffer_Args.

type Buffer_Type

type Buffer_Type int32

Buffer_Type represents PJRT_Buffer_Type.

const (
	Buffer_Type_INVALID       Buffer_Type = 0
	Buffer_Type_PRED          Buffer_Type = 1
	Buffer_Type_S8            Buffer_Type = 2
	Buffer_Type_S16           Buffer_Type = 3
	Buffer_Type_S32           Buffer_Type = 4
	Buffer_Type_S64           Buffer_Type = 5
	Buffer_Type_U8            Buffer_Type = 6
	Buffer_Type_U16           Buffer_Type = 7
	Buffer_Type_U32           Buffer_Type = 8
	Buffer_Type_U64           Buffer_Type = 9
	Buffer_Type_F16           Buffer_Type = 10
	Buffer_Type_F32           Buffer_Type = 11
	Buffer_Type_F64           Buffer_Type = 12
	Buffer_Type_BF16          Buffer_Type = 13
	Buffer_Type_C64           Buffer_Type = 14
	Buffer_Type_C128          Buffer_Type = 15
	Buffer_Type_F8E5M2        Buffer_Type = 16
	Buffer_Type_F8E4M3FN      Buffer_Type = 17
	Buffer_Type_F8E4M3B11FNUZ Buffer_Type = 18
	Buffer_Type_F8E5M2FNUZ    Buffer_Type = 19
	Buffer_Type_F8E4M3FNUZ    Buffer_Type = 20
	Buffer_Type_S4            Buffer_Type = 21
	Buffer_Type_U4            Buffer_Type = 22
	Buffer_Type_TOKEN         Buffer_Type = 23
	Buffer_Type_S2            Buffer_Type = 24
	Buffer_Type_U2            Buffer_Type = 25
	Buffer_Type_F8E4M3        Buffer_Type = 26
	Buffer_Type_F8E3M4        Buffer_Type = 27
	Buffer_Type_F8E8M0FNU     Buffer_Type = 28
	Buffer_Type_F4E2M1FN      Buffer_Type = 29
	Buffer_Type_S1            Buffer_Type = 30
	Buffer_Type_U1            Buffer_Type = 31
	Buffer_Type_F6E2M3FN      Buffer_Type = 32
	Buffer_Type_F6E3M2FN      Buffer_Type = 33
)

type Buffer_UnpaddedDimensions_Args

type Buffer_UnpaddedDimensions_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Unpadded_dims   *int64
	Num_dims        uintptr
}

Buffer_UnpaddedDimensions_Args represents PJRT_Buffer_UnpaddedDimensions_Args.

type Buffer_UnsafePointer_Args

type Buffer_UnsafePointer_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Buffer          *Buffer
	Buffer_pointer  uintptr
}

Buffer_UnsafePointer_Args represents PJRT_Buffer_UnsafePointer_Args.

type CallbackError

type CallbackError struct{}

CallbackError is an opaque PJRT handle.

type Chunk

type Chunk struct {
	Data        unsafe.Pointer
	Size        uintptr
	Deleter     uintptr
	Deleter_arg unsafe.Pointer
}

Chunk represents PJRT_Chunk.

type Client

type Client struct{}

Client is an opaque PJRT handle.

type ClientWrapper

type ClientWrapper struct {
	// contains filtered or unexported fields
}

ClientWrapper provides idiomatic Go access to PJRT Client operations.

func NewClientFromAPI

func NewClientFromAPI(rawApi *Api) (*ClientWrapper, error)

NewClientFromAPI creates a ClientWrapper from an Api function table. Tables returned by OpenPlugin share its initialization state. Other tables are borrowed, are never registered globally, and are initialized on each call; their owner must ensure this is valid and keep the library loaded until all clients and their resources have been destroyed. API tables must not be mutated concurrently with calls into this package.

func (*ClientWrapper) AddressableDevices

func (c *ClientWrapper) AddressableDevices() ([]*Device, error)

AddressableDevices returns the devices that are locally addressable from this process.

func (*ClientWrapper) BufferFromHost

func (c *ClientWrapper) BufferFromHost(data unsafe.Pointer, bufType Buffer_Type, dims []int64, dev *Device) (*BufferWrapper, error)

BufferFromHost creates an on-device PJRT Buffer from host memory. The caller must supply enough data for bufType and dims and must not modify it during the call. Go allocations are pinned until the transfer returns. dev must be a non-nil device belonging to this client.

func (*ClientWrapper) Compile

func (c *ClientWrapper) Compile(programCode []byte, format string, compileOptions []byte) (*ExecutableWrapper, error)

Compile compiles a program (HLO, StableHLO, or MLIR bytecode) for execution on the client. Empty compileOptions selects one replica and one partition; otherwise the caller supplies a serialized XLA CompileOptionsProto.

func (*ClientWrapper) CreateViewOfDeviceBuffer

func (c *ClientWrapper) CreateViewOfDeviceBuffer(data unsafe.Pointer, typ Buffer_Type, dims []int64, layout *Buffer_MemoryLayout, dev *Device, onDelete uintptr, onDeleteArg unsafe.Pointer) (*BufferWrapper, error)

CreateViewOfDeviceBuffer creates a non-owning view of device memory. The caller must keep data and onDeleteArg valid until the plugin no longer uses them. Supply onDelete to observe this boundary; closing the returned buffer alone does not establish it. Go storage must remain pinned for that lifetime. On failure, the caller retains ownership. Layout and all memory it references must remain valid and pinned, when backed by Go storage, during this call. A nil layout selects the plugin default. The device must belong to this client. Support is plugin-dependent.

Example
package main

import (
	"fmt"
	"github.com/tmc/lib/openxla"
)

func main() {
	// A live client and caller-owned device allocation are required.
	var client openxla.ClientWrapper
	_, err := client.CreateViewOfDeviceBuffer(nil, openxla.Buffer_Type_U8, nil, nil, nil, 0, nil)
	fmt.Println(err)
}
Output:
openxla: client is closed

func (*ClientWrapper) DefaultDeviceAssignment

func (c *ClientWrapper) DefaultDeviceAssignment(replicas, partitions int) ([]int32, error)

DefaultDeviceAssignment returns the runtime's default device IDs for the requested replica and partition counts. Both counts must be positive and fit a C int. The caller owns the returned slice.

Example
var client ClientWrapper
_, err := client.DefaultDeviceAssignment(0, 1)
fmt.Println(err)
Output:
openxla: replica and partition counts must be positive C ints

func (*ClientWrapper) Destroy

func (c *ClientWrapper) Destroy() error

Destroy frees the client and shuts down connections.

func (*ClientWrapper) Devices

func (c *ClientWrapper) Devices() ([]*Device, error)

Devices returns all devices visible to the client runtime.

func (*ClientWrapper) MemoryStats

func (c *ClientWrapper) MemoryStats(device *Device) (DeviceMemoryStats, error)

MemoryStats returns native allocator counters for device, which must belong to this client and remain alive during the call. Plugins may not implement it. Returned values are owned by Go and remain valid after the client is closed.

Example
var client *ClientWrapper
_, err := client.MemoryStats(nil)
fmt.Println(err)
Output:
openxla: client is closed

func (*ClientWrapper) PlatformName

func (c *ClientWrapper) PlatformName() (string, error)

PlatformName returns the name of the PJRT platform (e.g. "tpu", "cuda").

func (*ClientWrapper) PlatformVersion

func (c *ClientWrapper) PlatformVersion() (string, error)

PlatformVersion returns human-readable version info for the platform.

type Client_AddressableDevices_Args

type Client_AddressableDevices_Args struct {
	Struct_size             uintptr
	Extension_start         *Extension_Base
	Client                  *Client
	Addressable_devices     *Device
	Num_addressable_devices uintptr
}

Client_AddressableDevices_Args represents PJRT_Client_AddressableDevices_Args.

type Client_AddressableMemories_Args

type Client_AddressableMemories_Args struct {
	Struct_size              uintptr
	Extension_start          *Extension_Base
	Client                   *Client
	Addressable_memories     *Memory
	Num_addressable_memories uintptr
}

Client_AddressableMemories_Args represents PJRT_Client_AddressableMemories_Args.

type Client_BufferFromHostBuffer_Args

type Client_BufferFromHostBuffer_Args struct {
	Struct_size           uintptr
	Extension_start       *Extension_Base
	Client                *Client
	Data                  unsafe.Pointer
	Type                  Buffer_Type
	Dims                  *int64
	Num_dims              uintptr
	Byte_strides          *int64
	Num_byte_strides      uintptr
	Host_buffer_semantics HostBufferSemantics
	Device                *Device
	Memory                *Memory
	Device_layout         *Buffer_MemoryLayout
	Done_with_host_buffer *Event
	Buffer                *Buffer
}

Client_BufferFromHostBuffer_Args represents PJRT_Client_BufferFromHostBuffer_Args.

type Client_Compile_Args

type Client_Compile_Args struct {
	Struct_size          uintptr
	Extension_start      *Extension_Base
	Client               *Client
	Program              *Program
	Compile_options      *byte
	Compile_options_size uintptr
	Executable           *LoadedExecutable
}

Client_Compile_Args represents PJRT_Client_Compile_Args.

type Client_CreateAliasBuffer_Args

type Client_CreateAliasBuffer_Args struct {
	Struct_size             uintptr
	Extension_start         *Extension_Base
	Client                  *Client
	Memory                  *Memory
	Shape_dims              *int64
	Shape_num_dims          uintptr
	Shape_element_type      Buffer_Type
	Shape_layout            *Buffer_MemoryLayout
	Alias_buffer            *Buffer
	Fulfill_alias_buffer_cb *FulfillAliasBufferCallback
}

Client_CreateAliasBuffer_Args represents PJRT_Client_CreateAliasBuffer_Args.

type Client_CreateBuffersForAsyncHostToDevice_Args

type Client_CreateBuffersForAsyncHostToDevice_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Client             *Client
	Shape_specs        *ShapeSpec
	Num_shape_specs    uintptr
	Device_layouts     unsafe.Pointer
	Num_device_layouts uintptr
	Memory             *Memory
	Transfer_manager   *AsyncHostToDeviceTransferManager
}

Client_CreateBuffersForAsyncHostToDevice_Args represents PJRT_Client_CreateBuffersForAsyncHostToDevice_Args.

type Client_CreateErrorBuffer_Args

type Client_CreateErrorBuffer_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Client             *Client
	Error_code         Error_Code
	Error_message      *byte
	Error_message_size uintptr
	Shape_dims         *int64
	Shape_num_dims     uintptr
	Shape_element_type Buffer_Type
	Shape_layout       *Buffer_MemoryLayout
	Memory             *Memory
	Buffer             *Buffer
	Payload            *NamedValue
	Num_payload        uintptr
}

Client_CreateErrorBuffer_Args represents PJRT_Client_CreateErrorBuffer_Args.

type Client_CreateUninitializedBuffer_Args

type Client_CreateUninitializedBuffer_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Client             *Client
	Shape_dims         *int64
	Shape_num_dims     uintptr
	Shape_element_type Buffer_Type
	Shape_layout       *Buffer_MemoryLayout
	Device             *Device
	Memory             *Memory
	Buffer             *Buffer
}

Client_CreateUninitializedBuffer_Args represents PJRT_Client_CreateUninitializedBuffer_Args.

type Client_CreateViewOfDeviceBuffer_Args

type Client_CreateViewOfDeviceBuffer_Args struct {
	Struct_size            uintptr
	Extension_start        *Extension_Base
	Client                 *Client
	Device_buffer_ptr      unsafe.Pointer
	Dims                   *int64
	Num_dims               uintptr
	Element_type           Buffer_Type
	Layout                 *Buffer_MemoryLayout
	Device                 *Device
	On_delete_callback     uintptr
	On_delete_callback_arg unsafe.Pointer
	Stream                 uintptr
	Buffer                 *Buffer
	Memory                 *Memory
}

Client_CreateViewOfDeviceBuffer_Args represents PJRT_Client_CreateViewOfDeviceBuffer_Args.

type Client_Create_Args

type Client_Create_Args struct {
	Struct_size         uintptr
	Extension_start     *Extension_Base
	Create_options      *NamedValue
	Num_options         uintptr
	Kv_get_callback     uintptr
	Kv_get_user_arg     unsafe.Pointer
	Kv_put_callback     uintptr
	Kv_put_user_arg     unsafe.Pointer
	Client              *Client
	Kv_try_get_callback uintptr
	Kv_try_get_user_arg unsafe.Pointer
}

Client_Create_Args represents PJRT_Client_Create_Args.

type Client_DefaultDeviceAssignment_Args

type Client_DefaultDeviceAssignment_Args struct {
	Struct_size             uintptr
	Extension_start         *Extension_Base
	Client                  *Client
	Num_replicas            int32
	Num_partitions          int32
	Default_assignment_size uintptr
	Default_assignment      *int32
}

Client_DefaultDeviceAssignment_Args represents PJRT_Client_DefaultDeviceAssignment_Args.

type Client_Destroy_Args

type Client_Destroy_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Client          *Client
}

Client_Destroy_Args represents PJRT_Client_Destroy_Args.

type Client_Devices_Args

type Client_Devices_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Client          *Client
	Devices         *Device
	Num_devices     uintptr
}

Client_Devices_Args represents PJRT_Client_Devices_Args.

type Client_DmaMap_Args

type Client_DmaMap_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Client          *Client
	Data            unsafe.Pointer
	Size            uintptr
}

Client_DmaMap_Args represents PJRT_Client_DmaMap_Args.

type Client_DmaUnmap_Args

type Client_DmaUnmap_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Client          *Client
	Data            unsafe.Pointer
}

Client_DmaUnmap_Args represents PJRT_Client_DmaUnmap_Args.

type Client_FulfillAliasBuffer_Args

type Client_FulfillAliasBuffer_Args struct {
	Struct_size             uintptr
	Extension_start         *Extension_Base
	Client                  *Client
	Buffer                  *Buffer
	Status_code             Error_Code
	Error_message           *byte
	Error_message_size      uintptr
	Fulfill_alias_buffer_cb *FulfillAliasBufferCallback
}

Client_FulfillAliasBuffer_Args represents PJRT_Client_FulfillAliasBuffer_Args.

type Client_Load_Args

type Client_Load_Args struct {
	Struct_size          uintptr
	Extension_start      *Extension_Base
	Client               *Client
	Executable           *Executable
	Compile_options      *byte
	Compile_options_size uintptr
	Loaded_executable    *LoadedExecutable
}

Client_Load_Args represents PJRT_Client_Load_Args.

type Client_LookupAddressableDevice_Args

type Client_LookupAddressableDevice_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Client             *Client
	Local_hardware_id  int32
	Addressable_device *Device
}

Client_LookupAddressableDevice_Args represents PJRT_Client_LookupAddressableDevice_Args.

type Client_LookupDevice_Args

type Client_LookupDevice_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Client          *Client
	Id              int32
	Device          *Device
}

Client_LookupDevice_Args represents PJRT_Client_LookupDevice_Args.

type Client_PlatformName_Args

type Client_PlatformName_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Client             *Client
	Platform_name      *byte
	Platform_name_size uintptr
}

Client_PlatformName_Args represents PJRT_Client_PlatformName_Args.

type Client_PlatformVersion_Args

type Client_PlatformVersion_Args struct {
	Struct_size           uintptr
	Extension_start       *Extension_Base
	Client                *Client
	Platform_version      *byte
	Platform_version_size uintptr
}

Client_PlatformVersion_Args represents PJRT_Client_PlatformVersion_Args.

type Client_ProcessIndex_Args

type Client_ProcessIndex_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Client          *Client
	Process_index   int32
}

Client_ProcessIndex_Args represents PJRT_Client_ProcessIndex_Args.

type Client_TopologyDescription_Args

type Client_TopologyDescription_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Client          *Client
	Topology        *TopologyDescription
}

Client_TopologyDescription_Args represents PJRT_Client_TopologyDescription_Args.

type Client_UpdateGlobalProcessInfo_Args

type Client_UpdateGlobalProcessInfo_Args struct {
	Struct_size       uintptr
	Extension_start   *Extension_Base
	Client            *Client
	Process_infos     *ProcessInfo
	Num_process_infos uintptr
}

Client_UpdateGlobalProcessInfo_Args represents PJRT_Client_UpdateGlobalProcessInfo_Args.

type Compile_Args

type Compile_Args struct {
	Struct_size          uintptr
	Extension_start      *Extension_Base
	Topology             *TopologyDescription
	Program              *Program
	Compile_options      *byte
	Compile_options_size uintptr
	Client               *Client
	Executable           *Executable
}

Compile_Args represents PJRT_Compile_Args.

type CompiledMemoryStats

type CompiledMemoryStats struct {
	GeneratedCodeBytes     int64
	ArgumentBytes          int64
	OutputBytes            int64
	AliasBytes             int64
	TempBytes              int64
	HostGeneratedCodeBytes int64
	HostArgumentBytes      int64
	HostOutputBytes        int64
	HostAliasBytes         int64
	HostTempBytes          int64
	PeakMemoryBytes        int64
	TotalBytes             int64
	TotalAllocationBytes   int64
	IndefiniteAllocations  int64
	PeakUnpaddedHeapBytes  int64
}

CompiledMemoryStats contains compiler-reported memory estimates for an executable. These are not live allocation counters. Values and availability depend on the plugin; the PJRT API does not distinguish an omitted value from zero. Host-prefixed fields describe host memory; other fields describe the device's default memory space. AliasBytes describes argument storage reused for outputs. Fields ending in Bytes are measured in bytes.

Example
stats := CompiledMemoryStats{ArgumentBytes: 64, OutputBytes: 32}
fmt.Println(stats.ArgumentBytes, stats.OutputBytes)
Output:
64 32

type CopyToDeviceStream

type CopyToDeviceStream struct{}

CopyToDeviceStream is an opaque PJRT handle.

type CopyToDeviceStream_AddChunk_Args

type CopyToDeviceStream_AddChunk_Args struct {
	Struct_size       uintptr
	Extension_start   *Extension_Base
	Stream            *CopyToDeviceStream
	Chunk             *Chunk
	Transfer_complete *Event
}

CopyToDeviceStream_AddChunk_Args represents PJRT_CopyToDeviceStream_AddChunk_Args.

type CopyToDeviceStream_CurrentBytes_Args

type CopyToDeviceStream_CurrentBytes_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Stream          *CopyToDeviceStream
	Current_bytes   int64
}

CopyToDeviceStream_CurrentBytes_Args represents PJRT_CopyToDeviceStream_CurrentBytes_Args.

type CopyToDeviceStream_Destroy_Args

type CopyToDeviceStream_Destroy_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Stream          *CopyToDeviceStream
}

---------------------------- CopyToDeviceStream -----------------------------

type CopyToDeviceStream_GranuleSize_Args

type CopyToDeviceStream_GranuleSize_Args struct {
	Struct_size           uintptr
	Extension_start       *Extension_Base
	Stream                *CopyToDeviceStream
	Granule_size_in_bytes int64
}

CopyToDeviceStream_GranuleSize_Args represents PJRT_CopyToDeviceStream_GranuleSize_Args.

type CopyToDeviceStream_TotalBytes_Args

type CopyToDeviceStream_TotalBytes_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Stream          *CopyToDeviceStream
	Total_bytes     int64
}

CopyToDeviceStream_TotalBytes_Args represents PJRT_CopyToDeviceStream_TotalBytes_Args.

type Device

type Device struct{}

Device is an opaque PJRT handle.

type DeviceAssignmentSerialized

type DeviceAssignmentSerialized struct{}

DeviceAssignmentSerialized is an opaque PJRT handle.

type DeviceDescription

type DeviceDescription struct{}

DeviceDescription is an opaque PJRT handle.

type DeviceDescription_Attributes_Args

type DeviceDescription_Attributes_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Device_description *DeviceDescription
	Num_attributes     uintptr
	Attributes         *NamedValue
}

DeviceDescription_Attributes_Args represents PJRT_DeviceDescription_Attributes_Args.

type DeviceDescription_DebugString_Args

type DeviceDescription_DebugString_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Device_description *DeviceDescription
	Debug_string       *byte
	Debug_string_size  uintptr
}

DeviceDescription_DebugString_Args represents PJRT_DeviceDescription_DebugString_Args.

type DeviceDescription_Id_Args

type DeviceDescription_Id_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Device_description *DeviceDescription
	Id                 int32
}

Device descriptions may be associated with an actual device (via PJRT_Device_GetDescription), but they can also be used to describe a device that isn't currently available to the plugin. This is useful for compiling executables without hardware available, which can then be serialized and written somewhere durable, and then loaded and run on actual hardware later.

type DeviceDescription_Kind_Args

type DeviceDescription_Kind_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Device_description *DeviceDescription
	Device_kind        *byte
	Device_kind_size   uintptr
}

DeviceDescription_Kind_Args represents PJRT_DeviceDescription_Kind_Args.

type DeviceDescription_ProcessIndex_Args

type DeviceDescription_ProcessIndex_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Device_description *DeviceDescription
	Process_index      int32
}

DeviceDescription_ProcessIndex_Args represents PJRT_DeviceDescription_ProcessIndex_Args.

type DeviceDescription_ToString_Args

type DeviceDescription_ToString_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Device_description *DeviceDescription
	To_string          *byte
	To_string_size     uintptr
}

DeviceDescription_ToString_Args represents PJRT_DeviceDescription_ToString_Args.

type DeviceMemoryStats

type DeviceMemoryStats struct {
	BytesInUse            int64
	PeakBytesInUse        *int64
	NumAllocs             *int64
	LargestAllocSize      *int64
	BytesLimit            *int64
	BytesReserved         *int64
	PeakBytesReserved     *int64
	BytesReservableLimit  *int64
	LargestFreeBlockBytes *int64
	PoolBytes             *int64
	PeakPoolBytes         *int64
	PeakAllocatedBytes    *int64
}

DeviceMemoryStats contains a diagnostic snapshot from the native allocator. Optional counters are nil when the plugin does not report them. A non-nil pointer to zero is a reported zero. These counters do not describe Go memory.

Example
zero := int64(0)
stats := DeviceMemoryStats{BytesInUse: 1024, NumAllocs: &zero}
fmt.Println(stats.BytesInUse, *stats.NumAllocs, stats.BytesLimit == nil)
Output:
1024 0 true

type Device_AddressableMemories_Args

type Device_AddressableMemories_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Device          *Device
	Memories        *Memory
	Num_memories    uintptr
}

Device_AddressableMemories_Args represents PJRT_Device_AddressableMemories_Args.

type Device_Attributes

type Device_Attributes struct{}

Device_Attributes is an opaque PJRT handle.

type Device_ClearMemoryStats_Args

type Device_ClearMemoryStats_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Device          *Device
}

Device_ClearMemoryStats_Args represents PJRT_Device_ClearMemoryStats_Args.

type Device_CreateAsyncTrackingEvent_Args

type Device_CreateAsyncTrackingEvent_Args struct {
	Struct_size      uintptr
	Extension_start  *Extension_Base
	Device           *Device
	Description      *byte
	Description_size uintptr
	Event            *AsyncTrackingEvent
}

Device_CreateAsyncTrackingEvent_Args represents PJRT_Device_CreateAsyncTrackingEvent_Args.

type Device_DefaultMemory_Args

type Device_DefaultMemory_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Device          *Device
	Memory          *Memory
}

Device_DefaultMemory_Args represents PJRT_Device_DefaultMemory_Args.

type Device_GetAttributes_Args

type Device_GetAttributes_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Device             *Device
	Attributes         *NamedValue
	Num_attributes     uintptr
	Device_attributes  *Device_Attributes
	Attributes_deleter uintptr
}

Device_GetAttributes_Args represents PJRT_Device_GetAttributes_Args.

type Device_GetDescription_Args

type Device_GetDescription_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Device             *Device
	Device_description *DeviceDescription
}

--------------------------------- Devices -----------------------------------

type Device_IsAddressable_Args

type Device_IsAddressable_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Device          *Device
	Is_addressable  bool
}

Device_IsAddressable_Args represents PJRT_Device_IsAddressable_Args.

type Device_LocalHardwareId_Args

type Device_LocalHardwareId_Args struct {
	Struct_size       uintptr
	Extension_start   *Extension_Base
	Device            *Device
	Local_hardware_id int32
}

Device_LocalHardwareId_Args represents PJRT_Device_LocalHardwareId_Args.

type Device_MemoryStats_Args

type Device_MemoryStats_Args struct {
	Struct_size                     uintptr
	Extension_start                 *Extension_Base
	Device                          *Device
	Bytes_in_use                    int64
	Peak_bytes_in_use               int64
	Peak_bytes_in_use_is_set        bool
	Num_allocs                      int64
	Num_allocs_is_set               bool
	Largest_alloc_size              int64
	Largest_alloc_size_is_set       bool
	Bytes_limit                     int64
	Bytes_limit_is_set              bool
	Bytes_reserved                  int64
	Bytes_reserved_is_set           bool
	Peak_bytes_reserved             int64
	Peak_bytes_reserved_is_set      bool
	Bytes_reservable_limit          int64
	Bytes_reservable_limit_is_set   bool
	Largest_free_block_bytes        int64
	Largest_free_block_bytes_is_set bool
	Pool_bytes                      int64
	Pool_bytes_is_set               bool
	Peak_pool_bytes                 int64
	Peak_pool_bytes_is_set          bool
	Peak_allocated_bytes            int64
	Peak_allocated_bytes_is_set     bool
}

Device_MemoryStats_Args represents PJRT_Device_MemoryStats_Args.

type Device_PoisonExecution_Args

type Device_PoisonExecution_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Device             *Device
	Launch_id          int32
	Error_code         Error_Code
	Error_message      *byte
	Error_message_size uintptr
	Poisoned           bool
	Payload            *NamedValue
	Num_payload        uintptr
}

Device_PoisonExecution_Args represents PJRT_Device_PoisonExecution_Args.

type ErrorHandle

type ErrorHandle struct{}

ErrorHandle is an opaque PJRT_Error handle, not a Go error. Its message and lifetime are managed through the PJRT API table.

type Error_Code

type Error_Code int32

Codes are based on https://abseil.io/docs/cpp/guides/status-codes

const (
	Error_Code_OK                  Error_Code = 0
	Error_Code_CANCELLED           Error_Code = 1
	Error_Code_UNKNOWN             Error_Code = 2
	Error_Code_INVALID_ARGUMENT    Error_Code = 3
	Error_Code_DEADLINE_EXCEEDED   Error_Code = 4
	Error_Code_NOT_FOUND           Error_Code = 5
	Error_Code_ALREADY_EXISTS      Error_Code = 6
	Error_Code_PERMISSION_DENIED   Error_Code = 7
	Error_Code_RESOURCE_EXHAUSTED  Error_Code = 8
	Error_Code_FAILED_PRECONDITION Error_Code = 9
	Error_Code_ABORTED             Error_Code = 10
	Error_Code_OUT_OF_RANGE        Error_Code = 11
	Error_Code_UNIMPLEMENTED       Error_Code = 12
	Error_Code_INTERNAL            Error_Code = 13
	Error_Code_UNAVAILABLE         Error_Code = 14
	Error_Code_DATA_LOSS           Error_Code = 15
	Error_Code_UNAUTHENTICATED     Error_Code = 16
)

type Error_Destroy_Args

type Error_Destroy_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Error           *ErrorHandle
}

Error_Destroy_Args represents PJRT_Error_Destroy_Args.

type Error_ForEachPayload_Args

type Error_ForEachPayload_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Error           *ErrorHandle
	Visitor         uintptr
	User_arg        unsafe.Pointer
}

Error_ForEachPayload_Args represents PJRT_Error_ForEachPayload_Args.

type Error_FunctionTable

type Error_FunctionTable struct {
	Struct_size      uintptr
	Instance_size    uintptr
	Extension_start  *Extension_Base
	Destroy          uintptr
	Message          uintptr
	Get_code         uintptr
	For_each_payload uintptr
}

Error_FunctionTable represents PJRT_Error_FunctionTable.

type Error_GetCode_Args

type Error_GetCode_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Error           *ErrorHandle
	Code            Error_Code
}

Error_GetCode_Args represents PJRT_Error_GetCode_Args.

type Error_Message_Args

type Error_Message_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Error           *ErrorHandle
	Message         *byte
	Message_size    uintptr
}

Error_Message_Args represents PJRT_Error_Message_Args.

type Event

type Event struct{}

Event is an opaque PJRT handle.

type Event_Await_Args

type Event_Await_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Event           *Event
}

Event_Await_Args represents PJRT_Event_Await_Args.

type Event_Create_Args

type Event_Create_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Event           *Event
}

Event_Create_Args represents PJRT_Event_Create_Args.

type Event_Destroy_Args

type Event_Destroy_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Event           *Event
}

Event_Destroy_Args represents PJRT_Event_Destroy_Args.

type Event_Error_Args

type Event_Error_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Event           *Event
}

Event_Error_Args represents PJRT_Event_Error_Args.

type Event_IsReady_Args

type Event_IsReady_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Event           *Event
	Is_ready        bool
}

Event_IsReady_Args represents PJRT_Event_IsReady_Args.

type Event_OnReady_Args

type Event_OnReady_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Event           *Event
	Callback        uintptr
	User_arg        unsafe.Pointer
}

Event_OnReady_Args represents PJRT_Event_OnReady_Args.

type Event_Set_Args

type Event_Set_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Event              *Event
	Error_code         Error_Code
	Error_message      *byte
	Error_message_size uintptr
}

Event_Set_Args represents PJRT_Event_Set_Args.

type Executable

type Executable struct{}

Executable is an opaque PJRT handle.

type ExecutableWrapper

type ExecutableWrapper struct {
	// contains filtered or unexported fields
}

ExecutableWrapper wraps a PJRT LoadedExecutable.

func (*ExecutableWrapper) CompiledMemoryStats

func (e *ExecutableWrapper) CompiledMemoryStats() (stats CompiledMemoryStats, err error)

CompiledMemoryStats returns compiler-reported estimates, releasing the temporary executable handle before returning. The loaded executable remains owned by the caller. A query or cleanup error returns no statistics.

Example
var executable *ExecutableWrapper
_, err := executable.CompiledMemoryStats()
fmt.Println(err)
Output:
openxla: executable is closed

func (*ExecutableWrapper) Destroy

func (e *ExecutableWrapper) Destroy() error

Destroy destroys the loaded executable on device.

func (*ExecutableWrapper) Execute

func (e *ExecutableWrapper) Execute(inputLists [][]*BufferWrapper) ([][]*BufferWrapper, error)

Execute runs the loaded executable across devices with the given input buffers.

func (*ExecutableWrapper) ExecuteWithNonDonatableInputs

func (e *ExecutableWrapper) ExecuteWithNonDonatableInputs(inputLists [][]*BufferWrapper, indices []int64) ([][]*BufferWrapper, error)

ExecuteWithNonDonatableInputs runs the executable while preventing donation of the indexed inputs on every device. Indices are zero-based argument positions, not device IDs. The caller must not modify indices during the call.

Example
package main

import (
	"fmt"
	"github.com/tmc/lib/openxla"
)

func main() {
	var executable openxla.ExecutableWrapper
	_, err := executable.ExecuteWithNonDonatableInputs(nil, []int64{0})
	fmt.Println(err)
}
Output:
openxla: executable is closed

func (*ExecutableWrapper) NumOutputs

func (e *ExecutableWrapper) NumOutputs() (count int, err error)

NumOutputs returns the number of output buffers produced by the executable per device.

func (*ExecutableWrapper) SerializedDeviceAssignment

func (e *ExecutableWrapper) SerializedDeviceAssignment() ([]byte, error)

SerializedDeviceAssignment returns an owned copy of the executable's serialized XLA DeviceAssignmentProto. The runtime must supply a backing allocation and its deleter. Once that pair is validated, the deleter runs before this method returns, including on malformed byte output.

Example
var executable ExecutableWrapper
_, err := executable.SerializedDeviceAssignment()
fmt.Println(err)
Output:
openxla: executable is closed

type Executable_DeserializeAndLoad_Args

type Executable_DeserializeAndLoad_Args struct {
	Struct_size                                uintptr
	Extension_start                            *Extension_Base
	Client                                     *Client
	Serialized_executable                      *byte
	Serialized_executable_size                 uintptr
	Loaded_executable                          *LoadedExecutable
	Overridden_serialized_compile_options      *byte
	Overridden_serialized_compile_options_size uintptr
	Load_options                               *LoadOptions
}

Executable_DeserializeAndLoad_Args represents PJRT_Executable_DeserializeAndLoad_Args.

type Executable_Destroy_Args

type Executable_Destroy_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Executable      *Executable
}

------------------------------- Executables ---------------------------------

type Executable_Fingerprint_Args

type Executable_Fingerprint_Args struct {
	Struct_size                 uintptr
	Extension_start             *Extension_Base
	Executable                  *Executable
	Executable_fingerprint      *byte
	Executable_fingerprint_size uintptr
}

Executable_Fingerprint_Args represents PJRT_Executable_Fingerprint_Args.

type Executable_GetCompileOptions_Args

type Executable_GetCompileOptions_Args struct {
	Struct_size                        uintptr
	Extension_start                    *Extension_Base
	Executable                         *Executable
	Serialized_bytes                   *byte
	Serialized_bytes_size              uintptr
	Serialized_compile_options         *SerializedCompileOptions
	Serialized_compile_options_deleter uintptr
}

Executable_GetCompileOptions_Args represents PJRT_Executable_GetCompileOptions_Args.

type Executable_GetCompiledMemoryStats_Args

type Executable_GetCompiledMemoryStats_Args struct {
	Struct_size                       uintptr
	Extension_start                   *Extension_Base
	Executable                        *Executable
	Generated_code_size_in_bytes      int64
	Argument_size_in_bytes            int64
	Output_size_in_bytes              int64
	Alias_size_in_bytes               int64
	Temp_size_in_bytes                int64
	Host_generated_code_size_in_bytes int64
	Host_argument_size_in_bytes       int64
	Host_output_size_in_bytes         int64
	Host_alias_size_in_bytes          int64
	Host_temp_size_in_bytes           int64
	Peak_memory_in_bytes              int64
	Total_size_in_bytes               int64
	Total_allocation_bytes            int64
	Indefinite_allocations            int64
	Peak_unpadded_heap_bytes          int64
}

Executable_GetCompiledMemoryStats_Args represents PJRT_Executable_GetCompiledMemoryStats_Args.

type Executable_GetCostAnalysis_Args

type Executable_GetCostAnalysis_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Executable      *Executable
	Num_properties  uintptr
	Properties      *NamedValue
}

Executable_GetCostAnalysis_Args represents PJRT_Executable_GetCostAnalysis_Args.

type Executable_Name_Args

type Executable_Name_Args struct {
	Struct_size          uintptr
	Extension_start      *Extension_Base
	Executable           *Executable
	Executable_name      *byte
	Executable_name_size uintptr
}

Executable_Name_Args represents PJRT_Executable_Name_Args.

type Executable_NumOutputs_Args

type Executable_NumOutputs_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Executable      *Executable
	Num_outputs     uintptr
}

Executable_NumOutputs_Args represents PJRT_Executable_NumOutputs_Args.

type Executable_NumPartitions_Args

type Executable_NumPartitions_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Executable      *Executable
	Num_partitions  uintptr
}

Executable_NumPartitions_Args represents PJRT_Executable_NumPartitions_Args.

type Executable_NumReplicas_Args

type Executable_NumReplicas_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Executable      *Executable
	Num_replicas    uintptr
}

TODO(b/269178731): Revisit whether num_replicas is needed.

type Executable_OptimizedProgram_Args

type Executable_OptimizedProgram_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Executable      *Executable
	Program         *Program
}

Executable_OptimizedProgram_Args represents PJRT_Executable_OptimizedProgram_Args.

type Executable_OutputDimensions_Args

type Executable_OutputDimensions_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Executable      *Executable
	Num_outputs     uintptr
	Dims            *int64
	Dim_sizes       *uintptr
}

Executable_OutputDimensions_Args represents PJRT_Executable_OutputDimensions_Args.

type Executable_OutputElementTypes_Args

type Executable_OutputElementTypes_Args struct {
	Struct_size      uintptr
	Extension_start  *Extension_Base
	Executable       *Executable
	Output_types     *Buffer_Type
	Num_output_types uintptr
}

Executable_OutputElementTypes_Args represents PJRT_Executable_OutputElementTypes_Args.

type Executable_OutputMemoryKinds_Args

type Executable_OutputMemoryKinds_Args struct {
	Struct_size       uintptr
	Extension_start   *Extension_Base
	Executable        *Executable
	Num_outputs       uintptr
	Memory_kinds      *byte
	Memory_kind_sizes *uintptr
}

Executable_OutputMemoryKinds_Args represents PJRT_Executable_OutputMemoryKinds_Args.

type Executable_ParameterMemoryKinds_Args

type Executable_ParameterMemoryKinds_Args struct {
	Struct_size       uintptr
	Extension_start   *Extension_Base
	Executable        *Executable
	Num_parameters    uintptr
	Memory_kinds      *byte
	Memory_kind_sizes *uintptr
}

Executable_ParameterMemoryKinds_Args represents PJRT_Executable_ParameterMemoryKinds_Args.

type Executable_Serialize_Args

type Executable_Serialize_Args struct {
	Struct_size                   uintptr
	Extension_start               *Extension_Base
	Executable                    *Executable
	Serialized_bytes              *byte
	Serialized_bytes_size         uintptr
	Serialized_executable         *SerializedExecutable
	Serialized_executable_deleter uintptr
}

Executable_Serialize_Args represents PJRT_Executable_Serialize_Args.

type Executable_SizeOfGeneratedCodeInBytes_Args

type Executable_SizeOfGeneratedCodeInBytes_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Executable      *Executable
	Size_in_bytes   int64
}

Executable_SizeOfGeneratedCodeInBytes_Args represents PJRT_Executable_SizeOfGeneratedCodeInBytes_Args.

type ExecuteContext

type ExecuteContext struct{}

ExecuteContext is an opaque PJRT handle.

type ExecuteContext_Create_Args

type ExecuteContext_Create_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Context         *ExecuteContext
}

ExecuteContext_Create_Args represents PJRT_ExecuteContext_Create_Args.

type ExecuteContext_Destroy_Args

type ExecuteContext_Destroy_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Context         *ExecuteContext
}

ExecuteContext_Destroy_Args represents PJRT_ExecuteContext_Destroy_Args.

type ExecuteOptions

type ExecuteOptions struct {
	Struct_size                                  uintptr
	Extension_start                              *Extension_Base
	Send_callbacks                               unsafe.Pointer
	Recv_callbacks                               unsafe.Pointer
	Num_send_ops                                 uintptr
	Num_recv_ops                                 uintptr
	Launch_id                                    int32
	Non_donatable_input_indices                  *int64
	Num_non_donatable_input_indices              uintptr
	Context                                      *ExecuteContext
	Call_location                                *byte
	Num_tasks                                    uintptr
	Task_ids                                     *int32
	Incarnation_ids                              *int64
	Multi_slice_config                           *MultiSlice_Config
	Use_major_to_minor_data_layout_for_callbacks bool
	Hlo_output_callbacks                         *HloOutputCallbackInfo
	Num_hlo_output_callbacks                     uintptr
}

ExecuteOptions represents PJRT_ExecuteOptions.

type Extension_Base

type Extension_Base struct {
	Struct_size uintptr
	Type        Extension_Type
	Next        *Extension_Base
}

PJRT_Extension_Base contains a type and a pointer to next PJRT_Extension_Base. The framework can go through this chain to find an extension and identify it with the type.

type Extension_Type

type Extension_Type int32

------------------------------- Extensions ----------------------------------

const (
	Extension_Type_Gpu_Custom_Call     Extension_Type = 0
	Extension_Type_Profiler            Extension_Type = 1
	Extension_Type_Custom_Partitioner  Extension_Type = 2
	Extension_Type_Stream              Extension_Type = 3
	Extension_Type_Layouts             Extension_Type = 4
	Extension_Type_FFI                 Extension_Type = 5
	Extension_Type_MemoryDescriptions  Extension_Type = 6
	Extension_Type_Triton              Extension_Type = 7
	Extension_Type_RawBuffer           Extension_Type = 8
	Extension_Type_PhaseCompile        Extension_Type = 9
	Extension_Type_Example             Extension_Type = 10
	Extension_Type_Unknown             Extension_Type = 11
	Extension_Type_CrossHostTransfers  Extension_Type = 12
	Extension_Type_ExecutableMetadata  Extension_Type = 13
	Extension_Type_Callback            Extension_Type = 14
	Extension_Type_HostAllocator       Extension_Type = 15
	Extension_Type_TpuTopology         Extension_Type = 16
	Extension_Type_TpuExecutable       Extension_Type = 17
	Extension_Type_Megascale           Extension_Type = 18
	Extension_Type_Shardings           Extension_Type = 19
	Extension_Type_AbiVersion          Extension_Type = 20
	Extension_Type_Collectives         Extension_Type = 21
	Extension_Type_MultiSlice          Extension_Type = 22
	Extension_Type_HostMemoryAllocator Extension_Type = 23
	Extension_Type_XlaTransform        Extension_Type = 24
)

type FulfillAliasBufferCallback

type FulfillAliasBufferCallback struct{}

FulfillAliasBufferCallback is an opaque PJRT handle.

type HloOutputCallbackInfo

type HloOutputCallbackInfo struct {
	User_arg     unsafe.Pointer
	Callback     uintptr
	Callback_id  int64
	Num_operands uintptr
}

HloOutputCallbackInfo represents PJRT_HloOutputCallbackInfo.

type HostBufferSemantics

type HostBufferSemantics int32

HostBufferSemantics represents PJRT_HostBufferSemantics.

const (
	HostBufferSemantics_kImmutableOnlyDuringCall         HostBufferSemantics = 0
	HostBufferSemantics_kImmutableUntilTransferCompletes HostBufferSemantics = 1
	HostBufferSemantics_kImmutableZeroCopy               HostBufferSemantics = 2
	HostBufferSemantics_kMutableZeroCopy                 HostBufferSemantics = 3
)

type KeyValueGetCallback_Args

type KeyValueGetCallback_Args struct {
	Struct_size            uintptr
	Extension_start        *Extension_Base
	Key                    *byte
	Key_size               uintptr
	Timeout_in_ms          int32
	Callback_error         *CallbackError
	User_arg               unsafe.Pointer
	Value                  *byte
	Value_size             uintptr
	Value_deleter_callback uintptr
}

KeyValueGetCallback_Args represents PJRT_KeyValueGetCallback_Args.

type KeyValuePutCallback_Args

type KeyValuePutCallback_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Key             *byte
	Key_size        uintptr
	Value           *byte
	Value_size      uintptr
	Callback_error  *CallbackError
	User_arg        unsafe.Pointer
}

KeyValuePutCallback_Args represents PJRT_KeyValuePutCallback_Args.

type KeyValueTryGetCallback_Args

type KeyValueTryGetCallback_Args struct {
	Struct_size            uintptr
	Extension_start        *Extension_Base
	Key                    *byte
	Key_size               uintptr
	Callback_error         *CallbackError
	User_arg               unsafe.Pointer
	Value                  *byte
	Value_size             uintptr
	Value_deleter_callback uintptr
}

KeyValueTryGetCallback_Args represents PJRT_KeyValueTryGetCallback_Args.

type LoadOptions

type LoadOptions struct {
	Struct_size             uintptr
	Computation_origin      *int32
	Computation_origin_size uintptr
	Multi_slice_config      *MultiSlice_Config
}

LoadOptions represents PJRT_LoadOptions.

type LoadedExecutable

type LoadedExecutable struct{}

LoadedExecutable is an opaque PJRT handle.

type LoadedExecutable_AddressableDeviceLogicalIds_Args

type LoadedExecutable_AddressableDeviceLogicalIds_Args struct {
	Struct_size                        uintptr
	Extension_start                    *Extension_Base
	Executable                         *LoadedExecutable
	Addressable_device_logical_ids     *LogicalDeviceIds
	Num_addressable_device_logical_ids uintptr
}

LoadedExecutable_AddressableDeviceLogicalIds_Args represents PJRT_LoadedExecutable_AddressableDeviceLogicalIds_Args.

type LoadedExecutable_AddressableDevices_Args

type LoadedExecutable_AddressableDevices_Args struct {
	Struct_size             uintptr
	Extension_start         *Extension_Base
	Executable              *LoadedExecutable
	Addressable_devices     *Device
	Num_addressable_devices uintptr
}

LoadedExecutable_AddressableDevices_Args represents PJRT_LoadedExecutable_AddressableDevices_Args.

type LoadedExecutable_Delete_Args

type LoadedExecutable_Delete_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Executable      *LoadedExecutable
}

LoadedExecutable_Delete_Args represents PJRT_LoadedExecutable_Delete_Args.

type LoadedExecutable_Destroy_Args

type LoadedExecutable_Destroy_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Executable      *LoadedExecutable
}

LoadedExecutable_Destroy_Args represents PJRT_LoadedExecutable_Destroy_Args.

type LoadedExecutable_Execute_Args

type LoadedExecutable_Execute_Args struct {
	Struct_size            uintptr
	Extension_start        *Extension_Base
	Executable             *LoadedExecutable
	Options                *ExecuteOptions
	Argument_lists         unsafe.Pointer
	Num_devices            uintptr
	Num_args               uintptr
	Output_lists           unsafe.Pointer
	Device_complete_events unsafe.Pointer
	Execute_device         *Device
}

LoadedExecutable_Execute_Args represents PJRT_LoadedExecutable_Execute_Args.

type LoadedExecutable_Fingerprint_Args

type LoadedExecutable_Fingerprint_Args struct {
	Struct_size                 uintptr
	Extension_start             *Extension_Base
	Executable                  *LoadedExecutable
	Executable_fingerprint      *byte
	Executable_fingerprint_size uintptr
}

LoadedExecutable_Fingerprint_Args represents PJRT_LoadedExecutable_Fingerprint_Args.

type LoadedExecutable_GetDeviceAssignment_Args

type LoadedExecutable_GetDeviceAssignment_Args struct {
	Struct_size                          uintptr
	Extension_start                      *Extension_Base
	Executable                           *LoadedExecutable
	Serialized_bytes                     *byte
	Serialized_bytes_size                uintptr
	Serialized_device_assignment         *DeviceAssignmentSerialized
	Serialized_device_assignment_deleter uintptr
}

LoadedExecutable_GetDeviceAssignment_Args represents PJRT_LoadedExecutable_GetDeviceAssignment_Args.

type LoadedExecutable_GetExecutable_Args

type LoadedExecutable_GetExecutable_Args struct {
	Struct_size       uintptr
	Extension_start   *Extension_Base
	Loaded_executable *LoadedExecutable
	Executable        *Executable
}

LoadedExecutable_GetExecutable_Args represents PJRT_LoadedExecutable_GetExecutable_Args.

type LoadedExecutable_IsDeleted_Args

type LoadedExecutable_IsDeleted_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Executable      *LoadedExecutable
	Is_deleted      bool
}

LoadedExecutable_IsDeleted_Args represents PJRT_LoadedExecutable_IsDeleted_Args.

type LogicalDeviceIds

type LogicalDeviceIds struct {
	Replica   int32
	Partition int32
}

LogicalDeviceIds represents PJRT_LogicalDeviceIds.

type Memory

type Memory struct{}

Memory is an opaque PJRT handle.

type Memory_AddressableByDevices_Args

type Memory_AddressableByDevices_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Memory          *Memory
	Devices         *Device
	Num_devices     uintptr
}

Memory_AddressableByDevices_Args represents PJRT_Memory_AddressableByDevices_Args.

type Memory_DebugString_Args

type Memory_DebugString_Args struct {
	Struct_size       uintptr
	Extension_start   *Extension_Base
	Memory            *Memory
	Debug_string      *byte
	Debug_string_size uintptr
}

Memory_DebugString_Args represents PJRT_Memory_DebugString_Args.

type Memory_FunctionTable

type Memory_FunctionTable struct {
	Struct_size          uintptr
	Extension_start      *Extension_Base
	Instance_struct_size uintptr
	Get_user_data        uintptr
	Set_user_data        uintptr
}

Memory_FunctionTable represents PJRT_Memory_FunctionTable.

type Memory_Id_Args

type Memory_Id_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Memory          *Memory
	Id              int32
}

-------------------------------- Memory --------------------------------------

type Memory_Kind_Args

type Memory_Kind_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Memory          *Memory
	Kind            *byte
	Kind_size       uintptr
}

Memory_Kind_Args represents PJRT_Memory_Kind_Args.

type Memory_Kind_Id_Args

type Memory_Kind_Id_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Memory          *Memory
	Kind_id         int32
}

Memory_Kind_Id_Args represents PJRT_Memory_Kind_Id_Args.

type Memory_ToString_Args

type Memory_ToString_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Memory          *Memory
	To_string       *byte
	To_string_size  uintptr
}

Memory_ToString_Args represents PJRT_Memory_ToString_Args.

type MultiSlice_Config

type MultiSlice_Config struct{}

MultiSlice_Config is an opaque PJRT handle.

type NamedValue

type NamedValue struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Name            *byte
	Name_size       uintptr
	Type            NamedValue_Type
	Union_pad       int64
	Value_size      uintptr
}

Named value for key-value pairs.

type NamedValue_Type

type NamedValue_Type int32

---------------------------- Named Values -----------------------------------

const (
	NamedValue_kString    NamedValue_Type = 0
	NamedValue_kInt64     NamedValue_Type = 1
	NamedValue_kInt64List NamedValue_Type = 2
	NamedValue_kFloat     NamedValue_Type = 3
	NamedValue_kBool      NamedValue_Type = 4
)

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin represents an OpenXLA PJRT dynamic library plugin.

func OpenPlugin

func OpenPlugin(path string) (*Plugin, error)

OpenPlugin loads a PJRT plugin dynamic library (e.g. libtpu.so, pjrt_c_api_gpu.so). Successful loads retain the library for the lifetime of the process. Loads resolving to the same GetPjrtApi entry point share successful initialization. The returned API tables must remain valid and immutable for that lifetime.

func (*Plugin) Api

func (p *Plugin) Api() *Api

Api returns the raw PJRT Api function table.

func (*Plugin) NewClient

func (p *Plugin) NewClient() (*ClientWrapper, error)

NewClient initializes the plugin once successfully and creates a PJRT client. Concurrent calls share initialization. A failed initialization may be retried by a later call; a client creation failure does not repeat successful setup.

func (*Plugin) Path

func (p *Plugin) Path() string

Path returns the filesystem path of the loaded plugin.

type Plugin_Attributes_Args

type Plugin_Attributes_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Attributes      *NamedValue
	Num_attributes  uintptr
}

Plugin_Attributes_Args represents PJRT_Plugin_Attributes_Args.

type Plugin_Initialize_Args

type Plugin_Initialize_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
}

---------------------------------- Plugin -----------------------------------

type ProcessInfo

type ProcessInfo struct {
	Struct_size        uintptr
	Task_id            int32
	Incarnation_id     uint64
	State              ProcessState
	Error_code         int32
	Error_message      *byte
	Error_message_size uintptr
}

TODO: mwhittaker - Add the remaining fields from tensorflow::CoordinatedTaskStateInfo.

type ProcessState

type ProcessState int32

ProcessState represents PJRT_ProcessState.

const (
	ProcessState_kUnspecified   ProcessState = 0
	ProcessState_kUninitialized ProcessState = 1
	ProcessState_kDisconnected  ProcessState = 2
	ProcessState_kConnected     ProcessState = 3
	ProcessState_kError         ProcessState = 4
)

type Program

type Program struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Code            *byte
	Code_size       uintptr
	Format          *byte
	Format_size     uintptr
}

Program represents PJRT_Program.

type RecvCallbackInfo

type RecvCallbackInfo struct {
	Channel_id    int64
	User_arg      unsafe.Pointer
	Recv_callback uintptr
}

RecvCallbackInfo represents PJRT_RecvCallbackInfo.

type SendCallbackInfo

type SendCallbackInfo struct {
	Channel_id    int64
	User_arg      unsafe.Pointer
	Send_callback uintptr
}

SendCallbackInfo represents PJRT_SendCallbackInfo.

type SerializedCompileOptions

type SerializedCompileOptions struct{}

SerializedCompileOptions is an opaque PJRT handle.

type SerializedExecutable

type SerializedExecutable struct{}

SerializedExecutable is an opaque PJRT handle.

type SerializedTopology

type SerializedTopology struct{}

SerializedTopology is an opaque PJRT handle.

type ShapeSpec

type ShapeSpec struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Dims            *int64
	Num_dims        uintptr
	Element_type    Buffer_Type
}

ShapeSpec represents PJRT_ShapeSpec.

type TopologyDescription

type TopologyDescription struct{}

TopologyDescription is an opaque PJRT handle.

type TopologyDescription_Attributes_Args

type TopologyDescription_Attributes_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Topology        *TopologyDescription
	Attributes      *NamedValue
	Num_attributes  uintptr
}

TopologyDescription_Attributes_Args represents PJRT_TopologyDescription_Attributes_Args.

type TopologyDescription_Create_Args

type TopologyDescription_Create_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Topology_name      *byte
	Topology_name_size uintptr
	Create_options     *NamedValue
	Num_options        uintptr
	Topology           *TopologyDescription
}

------------------------------ Device Topology ------------------------------

type TopologyDescription_Deserialize_Args

type TopologyDescription_Deserialize_Args struct {
	Struct_size              uintptr
	Extension_start          *Extension_Base
	Serialized_topology      *byte
	Serialized_topology_size uintptr
	Topology                 *TopologyDescription
}

TopologyDescription_Deserialize_Args represents PJRT_TopologyDescription_Deserialize_Args.

type TopologyDescription_Destroy_Args

type TopologyDescription_Destroy_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Topology        *TopologyDescription
}

TopologyDescription_Destroy_Args represents PJRT_TopologyDescription_Destroy_Args.

type TopologyDescription_Fingerprint_Args

type TopologyDescription_Fingerprint_Args struct {
	Struct_size     uintptr
	Extension_start *Extension_Base
	Topology        *TopologyDescription
	Fingerprint     uint64
}

TopologyDescription_Fingerprint_Args represents PJRT_TopologyDescription_Fingerprint_Args.

type TopologyDescription_GetDeviceDescriptions_Args

type TopologyDescription_GetDeviceDescriptions_Args struct {
	Struct_size      uintptr
	Extension_start  *Extension_Base
	Topology         *TopologyDescription
	Descriptions     *DeviceDescription
	Num_descriptions uintptr
}

TopologyDescription_GetDeviceDescriptions_Args represents PJRT_TopologyDescription_GetDeviceDescriptions_Args.

type TopologyDescription_GetMemorySpaceKindIds_Args

type TopologyDescription_GetMemorySpaceKindIds_Args struct {
	Struct_size               uintptr
	Extension_start           *Extension_Base
	Topology                  *TopologyDescription
	Memory_space_kind_ids     *int32
	Num_memory_space_kind_ids uintptr
}

TopologyDescription_GetMemorySpaceKindIds_Args represents PJRT_TopologyDescription_GetMemorySpaceKindIds_Args.

type TopologyDescription_MakeCanonicalShapeForMemorySpace_Args

type TopologyDescription_MakeCanonicalShapeForMemorySpace_Args struct {
	Struct_size              uintptr
	Extension_start          *Extension_Base
	Topology                 *TopologyDescription
	Memory_space_kind_id     int32
	Dims                     *int64
	Num_dims                 uintptr
	Element_type             Buffer_Type
	Layout                   *Buffer_MemoryLayout
	Serialized_shape         *byte
	Serialized_shape_size    uintptr
	Serialized_shape_deleter uintptr
}

TopologyDescription_MakeCanonicalShapeForMemorySpace_Args represents PJRT_TopologyDescription_MakeCanonicalShapeForMemorySpace_Args.

type TopologyDescription_PlatformName_Args

type TopologyDescription_PlatformName_Args struct {
	Struct_size        uintptr
	Extension_start    *Extension_Base
	Topology           *TopologyDescription
	Platform_name      *byte
	Platform_name_size uintptr
}

TopologyDescription_PlatformName_Args represents PJRT_TopologyDescription_PlatformName_Args.

type TopologyDescription_PlatformVersion_Args

type TopologyDescription_PlatformVersion_Args struct {
	Struct_size           uintptr
	Extension_start       *Extension_Base
	Topology              *TopologyDescription
	Platform_version      *byte
	Platform_version_size uintptr
}

TopologyDescription_PlatformVersion_Args represents PJRT_TopologyDescription_PlatformVersion_Args.

type TopologyDescription_Serialize_Args

type TopologyDescription_Serialize_Args struct {
	Struct_size                 uintptr
	Extension_start             *Extension_Base
	Topology                    *TopologyDescription
	Serialized_bytes            *byte
	Serialized_bytes_size       uintptr
	Serialized_topology         *SerializedTopology
	Serialized_topology_deleter uintptr
}

TopologyDescription_Serialize_Args represents PJRT_TopologyDescription_Serialize_Args.

Directories

Path Synopsis
internal
pincheck
Package pincheck checks retained Go pointers using the cgo runtime checker.
Package pincheck checks retained Go pointers using the cgo runtime checker.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL