network_contract#

cuquantum.bindings.cutensornet.network_contract(
intptr_t handle,
intptr_t network_desc,
int32_t accumulate_output,
intptr_t work_desc,
intptr_t slice_group,
intptr_t stream,
)[source]#

Performs the actual contraction of the tensor network.

Parameters:
  • handle (intptr_t) – Opaque handle holding cuTensorNet’s library context.

  • network_desc (intptr_t) – The network descriptor whose specifed slices (slice_group) will be contracted (see network_prepare_contraction() and network_autotune_contraction()). Some internal meta-data may be updated upon contraction.

  • accumulate_output (int32_t) – If 0, write the contraction result into output data buffer as provided by network_set_output_tensor_memory(); otherwise, accumulate the results.

  • work_desc (intptr_t) – Opaque structure describing the workspace. The provided CUTENSORNET_WORKSPACE_SCRATCH workspace must be valid (the workspace pointer must be device accessible, see cutensornetMemspace_t, and the workspace size must be the same as or larger than both the minimum needed and the value provided at contraction preparation). See network_prepare_contraction(), workspace_get_memory_size() & workspace_set_memory(). The provided CUTENSORNET_WORKSPACE_CACHE workspace must be device accessible, see cutensornetMemspace_t; it can be of any size, the larger the better, up to the size that can be queried with workspace_get_memory_size(). If a device memory handler is set (see cutensornetSetDeviceMemHandler()), then work_desc can be set to null, or the memory pointer in work_desc of either the workspace kinds can be set to null, and the workspace size can be set either to a negative value (in which case the “recommended” size is used, see CUTENSORNET_WORKSIZE_PREF_RECOMMENDED) or to a valid size. For a workspace of kind CUTENSORNET_WORKSPACE_SCRATCH, a memory buffer with the specified size will be drawn from the user’s mempool and released back once done. For a workspace of kind CUTENSORNET_WORKSPACE_CACHE, a memory buffer with the specified size will be drawn from the user’s mempool and released back once the work_desc is destroyed, if work_desc != NULL, otherwise, once the network_desc is destroyed, workspace_purge_cache() is called, or an alternative work_desc with a different memory address/size is provided in a subsequent network_contract() call.

  • slice_group (intptr_t) – Opaque object specifying the slices to be contracted (see create_slice_group_from_id_range() and cutensornetCreateSliceGroupFromIDs()). If set to null, all slices will be contracted..

  • stream (intptr_t) – The CUDA stream on which the computation is performed.