xla

Struct PjRtBuffer

Source
pub struct PjRtBuffer { /* private fields */ }
Expand description

A buffer represents a view on a memory slice hosted on a device.

Implementations§

Source§

impl PjRtBuffer

Source

pub fn client(&self) -> &PjRtClient

The client that owns this buffer.

Source

pub fn copy_to_device(&self, device: PjRtDevice<'_>) -> Result<PjRtBuffer>

Copy the buffer to a different device.

Source

pub fn to_literal_sync(&self) -> Result<Literal>

Copy the buffer back to the host as a literal.

Source

pub fn on_device_shape(&self) -> Result<Shape>

Retrieve the shape used by this buffer.

Source

pub fn copy_raw_to_host_sync<T: ArrayElement>( &self, dst: &mut [T], offset: usize, ) -> Result<()>

Copy the data stored in a buffer to host memory in a blocking way.

Trait Implementations§

Source§

impl Drop for PjRtBuffer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl FromRawBytes for PjRtBuffer

Source§

type Context = PjRtClient

Source§

fn from_raw_bytes( client: &Self::Context, ty: ElementType, dims: &[usize], bytes: &[u8], ) -> Result<Self>

Source§

fn read_npy<T: AsRef<Path>>(path: T, c: &Self::Context) -> Result<Self>

Reads a npy file and return the stored multi-dimensional array as a literal.
Source§

fn read_npz<T: AsRef<Path>>( path: T, c: &Self::Context, ) -> Result<Vec<(String, Self)>>

Reads a npz file and returns the stored multi-dimensional arrays together with their names.
Source§

fn read_npz_by_name<T: AsRef<Path>>( path: T, c: &Self::Context, names: &[&str], ) -> Result<Vec<Self>>

Reads a npz file and returns the stored multi-dimensional arrays for some specified names.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.