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 { ... }
}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§
Sourcefn gpuResourceID(&self) -> MTLResourceID
Available on crate feature MTLTypes only.
fn gpuResourceID(&self) -> MTLResourceID
MTLTypes only.A handle that represents the GPU resource, which you can store in an argument buffer.
Sourcefn buffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>
Available on crate feature MTLBuffer only.
fn buffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>
MTLBuffer only.A buffer instance this tensor shares its storage with or nil if this tensor does not wrap an underlying buffer.
Sourcefn bufferOffset(&self) -> NSUInteger
fn bufferOffset(&self) -> NSUInteger
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.
Sourcefn strides(&self) -> Option<Retained<MTLTensorExtents>>
fn strides(&self) -> Option<Retained<MTLTensorExtents>>
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.
Sourcefn dimensions(&self) -> Retained<MTLTensorExtents>
fn dimensions(&self) -> Retained<MTLTensorExtents>
An array of sizes, in elements, one for each dimension of this tensor.
Sourcefn dataType(&self) -> MTLTensorDataType
fn dataType(&self) -> MTLTensorDataType
An underlying data format of this tensor.
Sourcefn usage(&self) -> MTLTensorUsage
fn usage(&self) -> MTLTensorUsage
A set of contexts in which you can use this tensor.
Sourceunsafe fn replaceSliceOrigin_sliceDimensions_withBytes_strides(
&self,
slice_origin: &MTLTensorExtents,
slice_dimensions: &MTLTensorExtents,
bytes: NonNull<c_void>,
strides: &MTLTensorExtents,
)
unsafe fn replaceSliceOrigin_sliceDimensions_withBytes_strides( &self, slice_origin: &MTLTensorExtents, slice_dimensions: &MTLTensorExtents, bytes: NonNull<c_void>, strides: &MTLTensorExtents, )
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
sliceOriginandsliceDimensions. - strides: An array of strides, in elements, that describes the layout of the data in
bytes. You are responsible for ensuringstridesmeets the following requirements: - Elements of
stridesare in monotonically non-decreasing order. - For any
ilarger than zero,strides[i]is greater than or equal tostrides[i-1] * dimensions[i-1].
§Safety
bytes must be a valid pointer.
Sourceunsafe fn getBytes_strides_fromSliceOrigin_sliceDimensions(
&self,
bytes: NonNull<c_void>,
strides: &MTLTensorExtents,
slice_origin: &MTLTensorExtents,
slice_dimensions: &MTLTensorExtents,
)
unsafe fn getBytes_strides_fromSliceOrigin_sliceDimensions( &self, bytes: NonNull<c_void>, strides: &MTLTensorExtents, slice_origin: &MTLTensorExtents, slice_dimensions: &MTLTensorExtents, )
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
sliceOriginandsliceDimensions. - strides: An array of strides, in elements, that describes the layout of the data in
bytes. You are responsible for ensuringstridesmeets the following requirements: - Elements of
stridesare in monotonically non-decreasing order. - For any
ilarger than zero,strides[i]is greater than or equal tostrides[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.