Skip to main content

TensorDevice

Struct TensorDevice 

Source
pub struct TensorDevice<B: Backend> { /* private fields */ }
Expand description

Execution context shared by both collective device interfaces.

Implementations§

Source§

impl<B: Backend> TensorDevice<B>

Source

pub fn reduction_kernel<T: TensorElement>( &self, operation: ReductionOperation, ) -> Result<ReductionOperation, TensorDeviceError>

Source

pub fn prepare<T: TensorElement>( &self, length: usize, destination_offset: usize, ) -> Result<TensorReductionLaunch, TensorDeviceError>

Source

pub fn reduce<T: TensorElement>( &self, operation: ReductionOperation, launch: &TensorReductionLaunch, source: &TensorBuffer<B, T>, destination: &TensorBuffer<B, T>, ) -> Result<(), TensorDeviceError>

Source§

impl<B: Backend> TensorDevice<B>

Source

pub fn allocate<T: TensorElement>( &self, length: usize, ) -> Result<TensorBuffer<B, T>, TensorDeviceError>

Source

pub fn write<T: TensorElement>( &self, buffer: &TensorBuffer<B, T>, values: &[T], ) -> Result<(), TensorDeviceError>

Source

pub fn write_at<T: TensorElement>( &self, buffer: &TensorBuffer<B, T>, offset: usize, values: &[T], ) -> Result<(), TensorDeviceError>

Source

pub fn download<T: TensorElement>( &self, buffer: &TensorBuffer<B, T>, ) -> Result<Vec<T>, TensorDeviceError>

Source

pub fn download_at<T: TensorElement>( &self, buffer: &TensorBuffer<B, T>, offset: usize, length: usize, ) -> Result<Vec<T>, TensorDeviceError>

Source§

impl<B: Backend> TensorDevice<B>

Source

pub fn new(device: B::Device) -> Self

Source

pub fn device(&self) -> &B::Device

Source

pub fn import_float<T: TensorElement>( &self, value: B::FloatTensorPrimitive, ) -> Result<TensorBuffer<B, T>, TensorDeviceError>

Import a rank-one floating tensor without downloading its values.

Source

pub fn import_int<T: TensorElement>( &self, value: B::IntTensorPrimitive, ) -> Result<TensorBuffer<B, T>, TensorDeviceError>

Import a rank-one integer tensor without downloading its values.

Source

pub fn upload<T: TensorElement>( &self, values: &[T], ) -> Result<TensorBuffer<B, T>, TensorDeviceError>

Source

pub fn synchronize(&self) -> Result<(), TensorDeviceError>

Wait for work already submitted to the selected tensor backend.

Trait Implementations§

Source§

impl<B: Clone + Backend> Clone for TensorDevice<B>
where B::Device: Clone,

Source§

fn clone(&self) -> TensorDevice<B>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<B: Debug + Backend> Debug for TensorDevice<B>
where B::Device: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<B: Backend, T: TensorElement> InProcessDevice<T> for TensorDevice<B>

Source§

const ELEMENT_SIZE: usize

Source§

type Context = TensorDevice<B>

Source§

type Buffer = TensorBuffer<B, T>

Source§

type Kernel = ReductionOperation

Source§

type ReductionLaunch = TensorReductionLaunch

Source§

type Error = TensorDeviceError

Source§

fn buffer_len(buffer: &Self::Buffer) -> usize

Source§

fn buffer_is_empty(buffer: &Self::Buffer) -> bool

Source§

fn alloc( context: &Self::Context, length: usize, ) -> Result<Self::Buffer, Self::Error>

Source§

fn copy_to_device( context: &Self::Context, buffer: &Self::Buffer, values: &[T], ) -> Result<(), Self::Error>

Source§

fn copy_to_device_at( context: &Self::Context, buffer: &Self::Buffer, offset: usize, values: &[T], ) -> Result<(), Self::Error>

Source§

fn copy_from_device( context: &Self::Context, buffer: &Self::Buffer, ) -> Result<Vec<T>, Self::Error>

Source§

fn copy_from_device_at( context: &Self::Context, buffer: &Self::Buffer, offset: usize, length: usize, ) -> Result<Vec<T>, Self::Error>

Source§

fn prepare_reduction( length: u32, destination_offset: u32, ) -> Self::ReductionLaunch

Source§

fn launch_reduction( context: &Self::Context, kernel: &Self::Kernel, launch: &Self::ReductionLaunch, source: &Self::Buffer, destination: &Self::Buffer, ) -> Result<(), Self::Error>

Source§

impl<B: Backend, T: TensorElement> RankDevice<T> for TensorDevice<B>

Source§

const ELEMENT_SIZE: usize

Source§

type Buffer = TensorBuffer<B, T>

Source§

type Kernel = ReductionOperation

Source§

type ReductionLaunch = TensorReductionLaunch

Source§

type Error = TensorDeviceError

Source§

fn buffer_len(&self, buffer: &Self::Buffer) -> usize

Source§

fn buffer_bytes(&self, buffer: &Self::Buffer) -> usize

Source§

fn encode(values: &[T]) -> Vec<u8>

Source§

fn decode(bytes: &[u8]) -> Result<Vec<T>, Self::Error>

Source§

fn alloc(&self, length: usize) -> Result<Self::Buffer, Self::Error>

Source§

fn copy_to_device( &self, buffer: &Self::Buffer, values: &[T], ) -> Result<(), Self::Error>

Source§

fn copy_from_device(&self, buffer: &Self::Buffer) -> Result<Vec<T>, Self::Error>

Source§

fn copy_from_device_at( &self, buffer: &Self::Buffer, element_offset: usize, length: usize, ) -> Result<Vec<T>, Self::Error>

Source§

fn copy_bytes_to_device_at( &self, buffer: &Self::Buffer, element_offset: usize, values: &[u8], ) -> Result<(), Self::Error>

Source§

fn copy_bytes_from_device_at( &self, buffer: &Self::Buffer, element_offset: usize, length: usize, ) -> Result<Vec<u8>, Self::Error>

Source§

fn prepare_reduction( &self, length: usize, destination_offset: usize, ) -> Result<Self::ReductionLaunch, Self::Error>

Source§

fn launch_reduction( &self, kernel: &Self::Kernel, launch: &Self::ReductionLaunch, source: &Self::Buffer, destination: &Self::Buffer, ) -> Result<(), Self::Error>

Auto Trait Implementations§

§

impl<B> Freeze for TensorDevice<B>
where <B as BackendTypes>::Device: Freeze,

§

impl<B> RefUnwindSafe for TensorDevice<B>

§

impl<B> Send for TensorDevice<B>
where <B as BackendTypes>::Device: Send,

§

impl<B> Sync for TensorDevice<B>
where <B as BackendTypes>::Device: Sync,

§

impl<B> Unpin for TensorDevice<B>
where <B as BackendTypes>::Device: Unpin,

§

impl<B> UnsafeUnpin for TensorDevice<B>

§

impl<B> UnwindSafe for TensorDevice<B>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more