Skip to main content

cutensorContract

Function cutensorContract 

Source
pub unsafe extern "C" fn cutensorContract(
    handle: cutensorHandle_t,
    plan: cutensorPlan_t,
    alpha: *const c_void,
    A: *const c_void,
    B: *const c_void,
    beta: *const c_void,
    C: *const c_void,
    D: *mut c_void,
    workspace: *mut c_void,
    workspaceSize: u64,
    stream: cudaStream_t,
) -> cutensorStatus_t
Expand description

This routine computes the tensor contraction $D = alpha \* A \* B + beta \* C$. $$ \mathcal{D}{{modes}\mathcal{D}} \gets \alpha \* \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 at the time at which the plan was created.

[Example] : See NVIDIA/CUDALibrarySamples for a concrete example.

§Parameters

  • handle: Opaque handle holding cuTENSOR’s library context.
  • plan: Opaque handle holding the contraction execution plan (created by cutensorCreateContraction followed by cutensorCreatePlan).
  • alpha: Scaling for A*B. Its data type is determined by ‘descCompute’ (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE)). Pointer to the host memory.
  • A: Pointer to the data corresponding to A. Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to D.
  • B: Pointer to the data corresponding to B. Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to D.
  • beta: Scaling for C. Its data type is determined by ‘descCompute’ (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE)). Pointer to the host memory.
  • C: Pointer to the data corresponding to C. Pointer to the GPU-accessible memory.
  • D: Pointer to the data corresponding to D. Pointer to the GPU-accessible memory.
  • workspace: Optional parameter that may be NULL. This pointer provides additional workspace, in device memory, to the library for additional optimizations; the workspace must be aligned to 256 bytes (i.e., the default alignment of cudaMalloc).
  • workspaceSize: Size of the workspace array in bytes; please refer to cutensorEstimateWorkspaceSize to query the required workspace. While cutensorContract does not strictly require a workspace for the contraction, it is still recommended to provide some small workspace (e.g., 128 MB).
  • stream: The CUDA stream in which all the computation is performed.

§Return value