Skip to main content

Plan

Struct Plan 

Source
pub struct Plan { /* private fields */ }

Implementations§

Source§

impl Plan

Source

pub fn elementwise_trinary<TA, TB, TC, TD, TScalar>( &self, alpha: &TScalar, a: &DeviceMemory<TA>, beta: &TScalar, b: &DeviceMemory<TB>, gamma: &TScalar, c: &DeviceMemory<TC>, d: &mut DeviceMemory<TD>, stream: &Stream, ) -> Result<()>
where TA: DataTypeLike, TB: DataTypeLike, TC: DataTypeLike, TD: DataTypeLike, TScalar: DataTypeLike,

Performs the three-input element-wise tensor operation encoded by this plan.

The operation has the form:

$$ D_{\Pi^C(i_0,i_1,…,i_n)} = \Phi_{ABC}(\Phi_{AB}(\alpha op_A(A_{\Pi^A(i_0,i_1,…,i_n)}), \beta op_B(B_{\Pi^B(i_0,i_1,…,i_n)})), \gamma op_C(C_{\Pi^C(i_0,i_1,…,i_n)})) $$

See OperationDescriptor::elementwise_trinary for details.

The call enqueues asynchronous CUDA work on stream. cuTENSOR treats this operation as thread-safe but not reentrant.

§Errors

Returns an error if stream belongs to a different CUDA context, scalar or tensor types do not match the plan, tensor dimensions or modes are invalid, a data type or operation combination is unsupported, or cuTENSOR rejects the operation.

Source

pub fn elementwise_binary<TA, TC, TD, TScalar>( &self, alpha: &TScalar, a: &DeviceMemory<TA>, gamma: &TScalar, c: &DeviceMemory<TC>, d: &mut DeviceMemory<TD>, stream: &Stream, ) -> Result<()>
where TA: DataTypeLike, TC: DataTypeLike, TD: DataTypeLike, TScalar: DataTypeLike,

Performs the two-input element-wise tensor operation encoded by this plan.

The operation has the form:

$$ D_{\Pi^C(i_0,i_1,…,i_n)} = \Phi_{AC}(\alpha op_A(A_{\Pi^A(i_0,i_1,…,i_n)}), \gamma op_C(C_{\Pi^C(i_0,i_1,…,i_n)})) $$

See OperationDescriptor::elementwise_binary for details.

The call enqueues asynchronous CUDA work on stream. cuTENSOR treats this operation as thread-safe but not reentrant.

§Errors

Returns an error if stream belongs to a different CUDA context, scalar or tensor types do not match the plan, tensor dimensions or modes are invalid, a data type or operation combination is unsupported, or cuTENSOR rejects the operation.

Source

pub fn permute<TA, TB, TScalar>( &self, alpha: &TScalar, a: &DeviceMemory<TA>, b: &mut DeviceMemory<TB>, stream: &Stream, ) -> Result<()>
where TA: DataTypeLike, TB: DataTypeLike, TScalar: DataTypeLike,

Performs the tensor permutation encoded by this plan.

The operation has the form:

$$ B_{\Pi^B(i_0,i_1,…,i_n)} = \alpha op_A(A_{\Pi^A(i_0,i_1,…,i_n)}) $$

Consequently, this performs an out-of-place tensor permutation.

Where:

  • A and B are multi-mode tensors of arbitrary data types.
  • $\Pi^A$ and $\Pi^B$ permute the modes of A and B, respectively.
  • $op_A$ is the unary element-wise operator specified when creating the operation descriptor with OperationDescriptor::permutation.

The call enqueues asynchronous CUDA work on stream. cuTENSOR treats this operation as thread-safe but not reentrant.

§Errors

Returns an error if stream belongs to a different CUDA context, scalar or tensor types do not match the plan, tensor dimensions or modes are invalid, a data type or operation combination is unsupported, or cuTENSOR rejects the operation.

Source

pub fn contract<TA, TB, TC, TD, TScalar>( &self, alpha: &TScalar, a: &DeviceMemory<TA>, b: &DeviceMemory<TB>, beta: &TScalar, c: &DeviceMemory<TC>, d: &mut DeviceMemory<TD>, workspace: Option<&mut DeviceMemory<u8>>, stream: &Stream, ) -> Result<()>
where TA: DataTypeLike, TB: DataTypeLike, TC: DataTypeLike, TD: DataTypeLike, TScalar: DataTypeLike,

Computes the tensor contraction $D = alpha \cdot A \cdot B + beta \cdot C$.

$$ \mathcal{D}_{{modes}_\mathcal{D}} \gets \alpha \cdot \mathcal{A}_{{modes}_\mathcal{A}} B_{{modes}_\mathcal{B}} + \beta \mathcal{C}_{{modes}_\mathcal{C}} $$

The active CUDA device must match the CUDA device that was active when the plan was created.

See NVIDIA/CUDALibrarySamples for a concrete example.

§Errors

Returns an error if stream belongs to a different CUDA context, scalar or tensor types do not match the plan, the active device does not match the plan, the provided workspace is smaller than Plan::required_workspace_size, the CUDA driver is insufficient, or cuTENSOR rejects or fails the operation.

Source

pub fn reduce<TA, TC, TD, TScalar>( &self, alpha: &TScalar, a: &DeviceMemory<TA>, beta: &TScalar, c: &DeviceMemory<TC>, d: &mut DeviceMemory<TD>, workspace: Option<&mut DeviceMemory<u8>>, stream: &Stream, ) -> Result<()>
where TA: DataTypeLike, TC: DataTypeLike, TD: DataTypeLike, TScalar: DataTypeLike,

Performs the tensor reduction that is encoded by this plan.

See OperationDescriptor::reduction for details. The call enqueues asynchronous CUDA work on stream. The provided workspace, when required by the plan, must remain valid until the queued work has completed.

§Errors

Returns an error if stream belongs to a different CUDA context, the scalar and tensor types do not match the plan, the provided workspace is smaller than Plan::required_workspace_size, or cuTENSOR rejects the operation.

Source

pub fn contract_trinary<TA, TB, TC, TD, TE, TScalar>( &self, alpha: &TScalar, a: &DeviceMemory<TA>, b: &DeviceMemory<TB>, c: &DeviceMemory<TC>, beta: &TScalar, d: &DeviceMemory<TD>, e: &mut DeviceMemory<TE>, workspace: Option<&mut DeviceMemory<u8>>, stream: &Stream, ) -> Result<()>

Computes the tensor contraction $E = alpha \cdot A \cdot B \cdot C + beta \cdot D$.

$$ \mathcal{E}_{{modes}_\mathcal{E}} \gets \alpha \cdot \mathcal{A}_{{modes}_\mathcal{A}} \mathcal{B}_{{modes}_\mathcal{B}} \mathcal{C}_{{modes}_\mathcal{C}} + \beta \mathcal{D}_{{modes}_\mathcal{D}} $$

The active CUDA device must match the CUDA device that was active when the plan was created.

See NVIDIA/CUDALibrarySamples for a concrete example.

§Errors

Returns an error if stream belongs to a different CUDA context, scalar or tensor types do not match the plan, the active device does not match the plan, the provided workspace is smaller than Plan::required_workspace_size, the CUDA driver is insufficient, or cuTENSOR rejects or fails the operation.

Source

pub fn block_sparse_contract<TScalar>( &self, alpha: &TScalar, a: &[DevicePtr], b: &[DevicePtr], beta: &TScalar, c: &[DevicePtr], d: &mut [DevicePtr], workspace: Option<&mut DeviceMemory<u8>>, stream: &Stream, ) -> Result<()>
where TScalar: DataTypeLike,

Computes the block-sparse tensor contraction $D = alpha \cdot A \cdot B + beta \cdot C$.

$$ \mathcal{D}_{{modes}_\mathcal{D}} \gets \alpha \cdot \mathcal{A}_{{modes}_\mathcal{A}} B_{{modes}_\mathcal{B}} + \beta \mathcal{C}_{{modes}_\mathcal{C}} $$

The active CUDA device must match the CUDA device that was active when the plan was created.

The array parameters A, B, C, and D are host arrays containing pointers to GPU-accessible memory. For example, A is a host array whose size equals the number of non-zero blocks in tensor $\mathcal{A}$. A\[i\] is a pointer to the GPU-accessible memory location of block number i of $\mathcal{A}$. The blocks are numbered in the same way as in the construction of $\mathcal{A}$’s block-sparse tensor descriptor. The same applies to the other array parameters B, C, and D.

§Errors

Returns an error if stream belongs to a different CUDA context, the pointer slices do not match the block counts encoded in the plan, the active device does not match the plan, the provided workspace is smaller than Plan::required_workspace_size, the CUDA driver is insufficient, or cuTENSOR rejects or fails the operation.

Source§

impl Plan

Source

pub fn estimate_workspace_size( ctx: &Context, operation: &OperationDescriptor, preference: &PlanPreference, workspace_preference: WorkspacePreference, ) -> Result<u64>

Determines the required workspace size for the given operation encoded by operation.

§Errors

Returns an error if the context cannot be bound, operation and preference do not belong to a compatible context, cuTENSOR rejects the workspace preference, or cuTENSOR cannot estimate the workspace size.

Source

pub fn create( ctx: &Context, operation: &OperationDescriptor, preference: &PlanPreference, workspace_size_limit: u64, ) -> Result<Self>

Source

pub unsafe fn from_raw( handle: cutensorPlan_t, ctx: &Context, required_workspace_size: u64, signature: OperationSignature, ) -> Self

Wraps an existing cuTENSOR plan handle and takes ownership of it.

§Safety

handle must be a valid cuTENSOR plan handle associated with ctx and compatible with signature. required_workspace_size must match the plan’s required workspace size. Ownership of handle is transferred to the returned plan, and the handle must not be destroyed elsewhere after calling this function.

Source

pub fn required_workspace_size(&self) -> u64

Source

pub fn required_workspace_size_bytes(&self) -> Result<usize>

Source

pub const fn as_raw(&self) -> cutensorPlan_t

Source

pub fn into_raw(self) -> cutensorPlan_t

Consumes the plan and returns the raw cuTENSOR plan handle without destroying it.

The caller becomes responsible for eventually destroying the returned handle with cuTENSOR.

Trait Implementations§

Source§

impl Debug for Plan

Source§

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

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

impl Drop for Plan

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for Plan

Auto Trait Implementations§

§

impl !Sync for Plan

§

impl Freeze for Plan

§

impl RefUnwindSafe for Plan

§

impl Unpin for Plan

§

impl UnsafeUnpin for Plan

§

impl UnwindSafe for Plan

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.