pub struct Plan { /* private fields */ }Implementations§
Source§impl Plan
impl Plan
Sourcepub 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,
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.
Sourcepub 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<()>
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<()>
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.
Sourcepub fn permute<TA, TB, TScalar>(
&self,
alpha: &TScalar,
a: &DeviceMemory<TA>,
b: &mut DeviceMemory<TB>,
stream: &Stream,
) -> Result<()>
pub fn permute<TA, TB, TScalar>( &self, alpha: &TScalar, a: &DeviceMemory<TA>, b: &mut DeviceMemory<TB>, stream: &Stream, ) -> Result<()>
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:
AandBare multi-mode tensors of arbitrary data types.- $\Pi^A$ and $\Pi^B$ permute the modes of
AandB, 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.
Sourcepub 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,
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.
Sourcepub 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<()>
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<()>
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.
Sourcepub 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<()>where
TA: DataTypeLike,
TB: DataTypeLike,
TC: DataTypeLike,
TD: DataTypeLike,
TE: DataTypeLike,
TScalar: DataTypeLike,
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<()>where
TA: DataTypeLike,
TB: DataTypeLike,
TC: DataTypeLike,
TD: DataTypeLike,
TE: DataTypeLike,
TScalar: DataTypeLike,
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.
Sourcepub 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,
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
impl Plan
Sourcepub fn estimate_workspace_size(
ctx: &Context,
operation: &OperationDescriptor,
preference: &PlanPreference,
workspace_preference: WorkspacePreference,
) -> Result<u64>
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.
pub fn create( ctx: &Context, operation: &OperationDescriptor, preference: &PlanPreference, workspace_size_limit: u64, ) -> Result<Self>
Sourcepub unsafe fn from_raw(
handle: cutensorPlan_t,
ctx: &Context,
required_workspace_size: u64,
signature: OperationSignature,
) -> Self
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.
pub fn required_workspace_size(&self) -> u64
pub fn required_workspace_size_bytes(&self) -> Result<usize>
pub const fn as_raw(&self) -> cutensorPlan_t
Sourcepub fn into_raw(self) -> cutensorPlan_t
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.