MTLTensor

Trait MTLTensor 

Source
pub unsafe trait MTLTensor: MTLResource {
    // Provided methods
    fn gpuResourceID(&self) -> MTLResourceID
       where Self: Sized + Message { ... }
    fn buffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>
       where Self: Sized + Message { ... }
    fn bufferOffset(&self) -> NSUInteger
       where Self: Sized + Message { ... }
    fn strides(&self) -> Option<Retained<MTLTensorExtents>>
       where Self: Sized + Message { ... }
    fn dimensions(&self) -> Retained<MTLTensorExtents>
       where Self: Sized + Message { ... }
    fn dataType(&self) -> MTLTensorDataType
       where Self: Sized + Message { ... }
    fn usage(&self) -> MTLTensorUsage
       where Self: Sized + Message { ... }
    unsafe fn replaceSliceOrigin_sliceDimensions_withBytes_strides(
        &self,
        slice_origin: &MTLTensorExtents,
        slice_dimensions: &MTLTensorExtents,
        bytes: NonNull<c_void>,
        strides: &MTLTensorExtents,
    )
       where Self: Sized + Message { ... }
    unsafe fn getBytes_strides_fromSliceOrigin_sliceDimensions(
        &self,
        bytes: NonNull<c_void>,
        strides: &MTLTensorExtents,
        slice_origin: &MTLTensorExtents,
        slice_dimensions: &MTLTensorExtents,
    )
       where Self: Sized + Message { ... }
}
Available on crate features MTLAllocation and MTLResource and MTLTensor only.
Expand description

A resource representing a multi-dimensional array that you can use with machine learning workloads.

See also Apple’s documentation

Provided Methods§

Source

fn gpuResourceID(&self) -> MTLResourceID
where Self: Sized + Message,

Available on crate feature MTLTypes only.

A handle that represents the GPU resource, which you can store in an argument buffer.

Source

fn buffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>
where Self: Sized + Message,

Available on crate feature MTLBuffer only.

A buffer instance this tensor shares its storage with or nil if this tensor does not wrap an underlying buffer.

Source

fn bufferOffset(&self) -> NSUInteger
where Self: Sized + Message,

An offset, in bytes, into the buffer instance this tensor shares its storage with, or zero if this tensor does not wrap an underlying buffer.

Source

fn strides(&self) -> Option<Retained<MTLTensorExtents>>
where Self: Sized + Message,

An array of strides, in elements, one for each dimension of this tensor.

This property only applies if this tensor shares its storage with a buffer, otherwise it’s nil.

Source

fn dimensions(&self) -> Retained<MTLTensorExtents>
where Self: Sized + Message,

An array of sizes, in elements, one for each dimension of this tensor.

Source

fn dataType(&self) -> MTLTensorDataType
where Self: Sized + Message,

An underlying data format of this tensor.

Source

fn usage(&self) -> MTLTensorUsage
where Self: Sized + Message,

A set of contexts in which you can use this tensor.

Source

unsafe fn replaceSliceOrigin_sliceDimensions_withBytes_strides( &self, slice_origin: &MTLTensorExtents, slice_dimensions: &MTLTensorExtents, bytes: NonNull<c_void>, strides: &MTLTensorExtents, )
where Self: Sized + Message,

Replaces the contents of a slice of this tensor with data you provide.

  • Parameters:
  • sliceOrigin: An array of offsets, in elements, to the first element of the slice that this method writes data to.
  • sliceDimensions: An array of sizes, in elements, of the slice this method writes data to.
  • bytes: A pointer to bytes of data that this method copies into the slice you specify with sliceOrigin and sliceDimensions.
  • strides: An array of strides, in elements, that describes the layout of the data in bytes. You are responsible for ensuring strides meets the following requirements:
  • Elements of stridesare in monotonically non-decreasing order.
  • For any i larger than zero, strides[i] is greater than or equal to strides[i-1] * dimensions[i-1].
§Safety

bytes must be a valid pointer.

Source

unsafe fn getBytes_strides_fromSliceOrigin_sliceDimensions( &self, bytes: NonNull<c_void>, strides: &MTLTensorExtents, slice_origin: &MTLTensorExtents, slice_dimensions: &MTLTensorExtents, )
where Self: Sized + Message,

Copies the data corresponding to a slice of this tensor into a pointer you provide.

  • Parameters:
  • bytes: A pointer to bytes of data that this method copies into the slice you specify with sliceOrigin and sliceDimensions.
  • strides: An array of strides, in elements, that describes the layout of the data in bytes. You are responsible for ensuring strides meets the following requirements:
  • Elements of stridesare in monotonically non-decreasing order.
  • For any i larger than zero, strides[i] is greater than or equal to strides[i-1] * dimensions[i-1].
  • sliceOrigin: An array of offsets, in elements, to the first element of the slice that this method reads data from.
  • sliceDimensions: An array of sizes, in elements, of the slice this method reads data from.
§Safety

bytes must be a valid pointer.

Trait Implementations§

Source§

impl ProtocolType for dyn MTLTensor

Source§

const NAME: &'static str = "MTLTensor"

The name of the Objective-C protocol that this type represents. Read more
Source§

fn protocol() -> Option<&'static AnyProtocol>

Get a reference to the Objective-C protocol object that this type represents. Read more
Source§

impl<T> ImplementedBy<T> for dyn MTLTensor
where T: ?Sized + Message + MTLTensor,

Implementations on Foreign Types§

Source§

impl<T> MTLTensor for ProtocolObject<T>
where T: ?Sized + MTLTensor,

Implementors§