pub struct TensorDescMut<T: GpuFloat> {
pub ptr: CUdeviceptr,
pub dims: Vec<u32>,
pub strides: Vec<u32>,
pub layout: TensorLayout,
/* private fields */
}Expand description
Mutable tensor descriptor for output buffers.
Identical to TensorDesc but signals that the referenced memory will
be written to. Having a separate type prevents accidentally aliasing an
input and output tensor at the type level.
Fields§
§ptr: CUdeviceptrRaw device pointer to the first element (will be written).
dims: Vec<u32>Shape (one entry per dimension).
strides: Vec<u32>Strides (one entry per dimension, in elements).
layout: TensorLayoutMemory layout convention.
Implementations§
Source§impl<T: GpuFloat> TensorDescMut<T>
impl<T: GpuFloat> TensorDescMut<T>
Sourcepub fn nchw(
buf: &mut DeviceBuffer<T>,
n: u32,
c: u32,
h: u32,
w: u32,
) -> DnnResult<Self>
pub fn nchw( buf: &mut DeviceBuffer<T>, n: u32, c: u32, h: u32, w: u32, ) -> DnnResult<Self>
Creates a mutable NCHW tensor descriptor from a device buffer.
§Errors
Same validation as TensorDesc::nchw.
Sourcepub fn nhwc(
buf: &mut DeviceBuffer<T>,
n: u32,
c: u32,
h: u32,
w: u32,
) -> DnnResult<Self>
pub fn nhwc( buf: &mut DeviceBuffer<T>, n: u32, c: u32, h: u32, w: u32, ) -> DnnResult<Self>
Creates a mutable NHWC tensor descriptor from a device buffer.
§Errors
Same validation as TensorDesc::nhwc.
Sourcepub fn matrix(
buf: &mut DeviceBuffer<T>,
rows: u32,
cols: u32,
) -> DnnResult<Self>
pub fn matrix( buf: &mut DeviceBuffer<T>, rows: u32, cols: u32, ) -> DnnResult<Self>
Creates a mutable 2-D matrix descriptor (rows x cols, row-major).
§Errors
Same validation as TensorDesc::matrix.
Sourcepub fn from_raw(
ptr: CUdeviceptr,
dims: Vec<u32>,
strides: Vec<u32>,
layout: TensorLayout,
) -> DnnResult<Self>
pub fn from_raw( ptr: CUdeviceptr, dims: Vec<u32>, strides: Vec<u32>, layout: TensorLayout, ) -> DnnResult<Self>
Constructs a mutable descriptor from raw components.
Sourcepub fn as_immutable(&self) -> TensorDesc<T>
pub fn as_immutable(&self) -> TensorDesc<T>
Borrows this mutable descriptor as an immutable TensorDesc.