Documentation
¶
Overview ¶
Package cutensornet provides lazy-loaded bindings for NVIDIA cuTensorNet, the tensor-network contraction library shipped with cuQuantum.
The contraction path is: create a Handle; describe the network with Handle.NewNetwork; find a contraction path with Handle.CreateContractionOptimizerConfig, Handle.CreateContractionOptimizerInfo and Handle.ContractionOptimize; size and fund a workspace with Handle.NewWorkspace; build a plan with Workspace.NewPlan; and execute it with Plan.Contract on a CUDA stream.
Tensors are strided, not packed. Every input and the output carries its own stride array in elements. A nil stride array means the library derives generalized column-major (Fortran) strides from the extents; passing an explicit array is the only way to describe any other layout, including a row-major one.
Ownership ¶
Mode, extent and stride arrays are borrowed for the duration of the descriptor call only; the library copies what it needs. Device buffers, the workspace, and the CUDA stream are caller-owned and must stay valid and unmodified until the stream work completes. A workspace buffer handed over with Handle.WorkspaceSetMemory is held by the descriptor across planning and every execution that uses it, so it must outlive the plan; Workspace is a Go-side owner that enforces that ordering, and Plan keeps both the workspace and the Network alive for as long as the library may read them. Cache-kind workspace additionally must not be modified between iterations that reuse it. Closing a workspace does not synchronize the stream: the caller must do that before any buffer is released. All handles must be destroyed in reverse order of creation.
This package does not allocate device memory. Pair it with a CUDA memory allocator such as github.com/tmc/lib/nvidia/driver.
Scope ¶
Tensor-network contraction and distributed MPI configuration are bound. Tensor decomposition and quantum state simulation remain outside this surface.
DistributedResetConfiguration requires an MPI_Comm_dup-created communicator dedicated to one Handle. Keep it alive until replaced by another reset. Set CUTENSORNET_COMM_LIB to a wrapper built against the same MPI implementation. Each rank must select the matching CUDA device before creating its Handle and execute the same sequence of collective calls. Synchronize local CUDA streams before DistributedSynchronize. Binding availability is not MPI runtime qualification.
cuTensorNet 2.13 deprecates the classic contraction entry points -- the ones this package's Network, Workspace and Plan are built on -- in favour of the cutensornetNetwork family, bound here as Handle.CreateNetwork, Handle.NetworkAppendTensor, Handle.NetworkSetOutputTensor, Handle.NetworkPrepareContraction and Handle.NetworkContract. Both families are present; the upstream Deprecated markers are carried through to the individual functions.
Verification status ¶
Nothing in this package has been run against a GPU. The struct layouts asserted by the generated tests were measured by the C compiler on the machine that ran the generator, so they are a check that the Go structs agree with the pinned header on that ABI, not evidence about the linux/x86_64 or linux/sbsa build of libcutensornet.
Execution ¶
Path optimization ¶
- Handle.ContractionAutotune.
- ContractionAutotunePreference.Attribute.
- ContractionAutotunePreference.SetAttribute.
- Handle.ContractionOptimize.
- ContractionOptimizerConfig.Attribute.
- ContractionOptimizerConfig.SetAttribute.
- ContractionOptimizerInfo.Attribute.
- ContractionOptimizerInfo.PackedSize.
- ContractionOptimizerInfo.PackData.
- ContractionOptimizerInfo.SetAttribute.
Descriptor lifecycle ¶
- Create.
- Handle.CreateContractionAutotunePreference.
- Handle.CreateContractionOptimizerConfig.
- Handle.CreateContractionOptimizerInfo.
- Handle.CreateContractionOptimizerInfoFromPackedData.
- Handle.CreateContractionPlan.
- Handle.CreateNetwork.
- Handle.CreateNetworkAutotunePreference.
- Handle.CreateNetworkDescriptor.
- Handle.CreateSliceGroupFromIDRange.
- Handle.CreateSliceGroupFromIDs.
- Handle.CreateTensorDescriptor.
- Handle.CreateWorkspaceDescriptor.
- Handle.Close.
- ContractionAutotunePreference.Close.
- ContractionOptimizerConfig.Close.
- ContractionOptimizerInfo.Close.
- ContractionPlan.Close.
- NetworkDescriptor.Destroy.
- NetworkAutotunePreference.Close.
- NetworkDescriptor.DestroyDescriptor.
- SliceGroup.Close.
- TensorDescriptor.Close.
- WorkspaceDescriptor.Close.
Library context ¶
- Handle.DistributedGetNumRanks.
- Handle.DistributedGetProcRank.
- Handle.DistributedResetConfiguration.
- Handle.DistributedSynchronize.
- Handle.NetworkAppendTensor.
- Handle.NetworkAutotuneContraction.
- NetworkAutotunePreference.Attribute.
- NetworkAutotunePreference.SetAttribute.
- Handle.NetworkContract.
- Handle.NetworkGetAttribute.
- Handle.NetworkPrepareContraction.
- Handle.NetworkSetAttribute.
- Handle.NetworkSetInputTensorMemory.
- Handle.NetworkSetOptimizerInfo.
- Handle.NetworkSetOutputTensor.
- Handle.NetworkSetOutputTensorMemory.
- Handle.UpdateContractionOptimizerInfoFromPackedData.
Queries ¶
- GetCudartVersion.
- Handle.OutputTensorDescriptor.
- Handle.OutputTensorDetails.
- Handle.TensorDetails.
- GetVersion.
Logging ¶
Workspace ¶
- Handle.WorkspaceComputeContractionSizes.
- Handle.WorkspaceGetMemory.
- Handle.WorkspaceGetMemorySize.
- Handle.WorkspacePurgeCache.
- Handle.WorkspaceSetMemory.
Example ¶
Example creates a cuTensorNet library handle and reports the loaded version. It returns early when libcutensornet is not available.
These examples have no Output comment, so they are compiled but not run: they need an NVIDIA GPU and a cuQuantum installation, and a machine without them would print a different thing.
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/cutensornet"
)
func main() {
h, err := cutensornet.Create()
if err != nil {
fmt.Println("cuTensorNet unavailable:", err)
return
}
defer h.Close()
version, err := cutensornet.GetVersion()
if err != nil {
fmt.Println("version:", err)
return
}
fmt.Println("cuTensorNet version:", version)
fmt.Println("loaded from:", cutensornet.Path())
}
Output:
Index ¶
- Variables
- func Close() error
- func ElementSize(d DataType) (int, bool)
- func GetCudartVersion() (uint, error)
- func GetVersion() (uint, error)
- func Has(symbol string) bool
- func HasContractSlices() bool
- func HasContractionAutotune() bool
- func HasContractionAutotunePreferenceGetAttribute() bool
- func HasContractionAutotunePreferenceSetAttribute() bool
- func HasContractionOptimize() bool
- func HasContractionOptimizerConfigGetAttribute() bool
- func HasContractionOptimizerConfigSetAttribute() bool
- func HasContractionOptimizerInfoGetAttribute() bool
- func HasContractionOptimizerInfoGetPackedSize() bool
- func HasContractionOptimizerInfoPackData() bool
- func HasContractionOptimizerInfoSetAttribute() bool
- func HasCreate() bool
- func HasCreateContractionAutotunePreference() bool
- func HasCreateContractionOptimizerConfig() bool
- func HasCreateContractionOptimizerInfo() bool
- func HasCreateContractionOptimizerInfoFromPackedData() bool
- func HasCreateContractionPlan() bool
- func HasCreateNetwork() bool
- func HasCreateNetworkAutotunePreference() bool
- func HasCreateNetworkDescriptor() bool
- func HasCreateSliceGroupFromIDRange() bool
- func HasCreateSliceGroupFromIDs() bool
- func HasCreateTensorDescriptor() bool
- func HasCreateWorkspaceDescriptor() bool
- func HasDestroy() bool
- func HasDestroyContractionAutotunePreference() bool
- func HasDestroyContractionOptimizerConfig() bool
- func HasDestroyContractionOptimizerInfo() bool
- func HasDestroyContractionPlan() bool
- func HasDestroyNetwork() bool
- func HasDestroyNetworkAutotunePreference() bool
- func HasDestroyNetworkDescriptor() bool
- func HasDestroySliceGroup() bool
- func HasDestroyTensorDescriptor() bool
- func HasDestroyWorkspaceDescriptor() bool
- func HasDistributedGetNumRanks() bool
- func HasDistributedGetProcRank() bool
- func HasDistributedResetConfiguration() bool
- func HasDistributedSynchronize() bool
- func HasGetCudartVersion() bool
- func HasGetErrorString() bool
- func HasGetOutputTensorDescriptor() bool
- func HasGetOutputTensorDetails() bool
- func HasGetTensorDetails() bool
- func HasGetVersion() bool
- func HasLoggerForceDisable() bool
- func HasLoggerOpenFile() bool
- func HasLoggerSetLevel() bool
- func HasLoggerSetMask() bool
- func HasNetworkAppendTensor() bool
- func HasNetworkAutotuneContraction() bool
- func HasNetworkAutotunePreferenceGetAttribute() bool
- func HasNetworkAutotunePreferenceSetAttribute() bool
- func HasNetworkContract() bool
- func HasNetworkGetAttribute() bool
- func HasNetworkPrepareContraction() bool
- func HasNetworkSetAttribute() bool
- func HasNetworkSetInputTensorMemory() bool
- func HasNetworkSetOptimizerInfo() bool
- func HasNetworkSetOutputTensor() bool
- func HasNetworkSetOutputTensorMemory() bool
- func HasUpdateContractionOptimizerInfoFromPackedData() bool
- func HasWorkspaceComputeContractionSizes() bool
- func HasWorkspaceGetMemory() bool
- func HasWorkspaceGetMemorySize() bool
- func HasWorkspacePurgeCache() bool
- func HasWorkspaceSetMemory() bool
- func Load(path string) error
- func Loaded() bool
- func LoggerForceDisable() error
- func LoggerOpenFile(logFile string) error
- func LoggerSetLevel(level int32) error
- func LoggerSetMask(mask int32) error
- func Path() string
- type BindFailure
- type CallError
- type ComputeType
- type ContractionAutotunePreference
- func (c ContractionAutotunePreference) Attribute(handle Handle, attr ContractionAutotunePreferenceAttributes, ...) errordeprecated
- func (c *ContractionAutotunePreference) Close() errordeprecated
- func (a ContractionAutotunePreference) Int32(handle Handle, attr ContractionAutotunePreferenceAttributes) (int32, error)
- func (c ContractionAutotunePreference) SetAttribute(handle Handle, attr ContractionAutotunePreferenceAttributes, ...) errordeprecated
- func (a ContractionAutotunePreference) SetInt32(handle Handle, attr ContractionAutotunePreferenceAttributes, v int32) error
- type ContractionAutotunePreferenceAttributesdeprecated
- type ContractionOptimizerConfig
- func (c ContractionOptimizerConfig) Attribute(handle Handle, attr ContractionOptimizerConfigAttributes, ...) error
- func (c *ContractionOptimizerConfig) Close() error
- func (c ContractionOptimizerConfig) Int32(handle Handle, attr ContractionOptimizerConfigAttributes) (int32, error)
- func (c ContractionOptimizerConfig) SetAttribute(handle Handle, attr ContractionOptimizerConfigAttributes, ...) error
- func (c ContractionOptimizerConfig) SetInt32(handle Handle, attr ContractionOptimizerConfigAttributes, v int32) error
- type ContractionOptimizerConfigAttributes
- type ContractionOptimizerInfo
- func (c ContractionOptimizerInfo) Attribute(handle Handle, attr ContractionOptimizerInfoAttributes, buffer unsafe.Pointer, ...) error
- func (c *ContractionOptimizerInfo) Close() error
- func (c ContractionOptimizerInfo) Float64(handle Handle, attr ContractionOptimizerInfoAttributes) (float64, error)
- func (c ContractionOptimizerInfo) Int32(handle Handle, attr ContractionOptimizerInfoAttributes) (int32, error)
- func (c ContractionOptimizerInfo) Int64(handle Handle, attr ContractionOptimizerInfoAttributes) (int64, error)
- func (c ContractionOptimizerInfo) PackData(handle Handle, buffer unsafe.Pointer, sizeInBytes uint) error
- func (c ContractionOptimizerInfo) PackedSize(handle Handle) (uint, error)
- func (c ContractionOptimizerInfo) SetAttribute(handle Handle, attr ContractionOptimizerInfoAttributes, buffer unsafe.Pointer, ...) error
- func (c ContractionOptimizerInfo) SetInt64(handle Handle, attr ContractionOptimizerInfoAttributes, v int64) error
- type ContractionOptimizerInfoAttributes
- type ContractionPath
- type ContractionPlan
- func (c *ContractionPlan) Close() errordeprecated
- type DataType
- type GraphAlgo
- type Handle
- func (h *Handle) Close() error
- func (h Handle) ContractSlices(plan ContractionPlan, rawDataIn *uintptr, rawDataOut uintptr, ...) errordeprecated
- func (h Handle) ContractionAutotune(plan ContractionPlan, rawDataIn *uintptr, rawDataOut uintptr, ...) errordeprecated
- func (h Handle) ContractionOptimize(networkDesc NetworkDescriptor, optimizerConfig ContractionOptimizerConfig, ...) error
- func (h Handle) CreateContractionAutotunePreference() (ContractionAutotunePreference, error)deprecated
- func (h Handle) CreateContractionOptimizerConfig() (ContractionOptimizerConfig, error)
- func (h Handle) CreateContractionOptimizerInfo(networkDesc NetworkDescriptor) (ContractionOptimizerInfo, error)
- func (h Handle) CreateContractionOptimizerInfoFromPackedData(networkDesc NetworkDescriptor, buffer unsafe.Pointer, sizeInBytes uint) (ContractionOptimizerInfo, error)
- func (h Handle) CreateContractionPlan(networkDesc NetworkDescriptor, optimizerInfo ContractionOptimizerInfo, ...) (ContractionPlan, error)deprecated
- func (h Handle) CreateNetwork() (NetworkDescriptor, error)
- func (h Handle) CreateNetworkAutotunePreference() (NetworkAutotunePreference, error)
- func (h Handle) CreateNetworkDescriptor(numInputs int32, numModesIn *int32, extentsIn []unsafe.Pointer, ...) (NetworkDescriptor, error)deprecated
- func (h Handle) CreateSliceGroupFromIDRange(sliceIdStart int64, sliceIdStop int64, sliceIdStep int64) (SliceGroup, error)
- func (h Handle) CreateSliceGroupFromIDs(beginIDSequence *int64, endIDSequence *int64) (SliceGroup, error)
- func (h Handle) CreateTensorDescriptor(numModes int32, extents *int64, strides *int64, modeLabels *int32, ...) (TensorDescriptor, error)
- func (h Handle) CreateWorkspaceDescriptor() (WorkspaceDescriptor, error)
- func (h Handle) DistributedGetNumRanks() (int32, error)
- func (h Handle) DistributedGetProcRank() (int32, error)
- func (h Handle) DistributedResetConfiguration(commPtr unsafe.Pointer, commSize uint) error
- func (h Handle) DistributedSynchronize() error
- func (h Handle) NetworkAppendTensor(networkDesc NetworkDescriptor, numModes int32, extents *int64, ...) (int64, error)
- func (h Handle) NetworkAutotuneContraction(networkDesc NetworkDescriptor, workDesc WorkspaceDescriptor, ...) error
- func (h Handle) NetworkContract(networkDesc NetworkDescriptor, accumulateOutput int32, ...) error
- func (h Handle) NetworkGetAttribute(networkDesc NetworkDescriptor, attr NetworkAttributes, buffer unsafe.Pointer, ...) error
- func (h Handle) NetworkPrepareContraction(networkDesc NetworkDescriptor, workDesc WorkspaceDescriptor) error
- func (h Handle) NetworkSetAttribute(networkDesc NetworkDescriptor, attr NetworkAttributes, buffer unsafe.Pointer, ...) error
- func (h Handle) NetworkSetInputTensorMemory(networkDesc NetworkDescriptor, tensorId int64, buffer uintptr, strides *int64) error
- func (h Handle) NetworkSetOptimizerInfo(networkDesc NetworkDescriptor, optimizerInfo ContractionOptimizerInfo) error
- func (h Handle) NetworkSetOutputTensor(networkDesc NetworkDescriptor, numModes int32, modeLabels *int32, ...) error
- func (h Handle) NetworkSetOutputTensorMemory(networkDesc NetworkDescriptor, buffer uintptr, strides *int64) error
- func (h Handle) NewNetwork(inputs []Tensor, output *Tensor, dataType DataType, computeType ComputeType) (*Network, error)
- func (h Handle) NewWorkspace() (*Workspace, error)
- func (h Handle) OutputTensorDescriptor(networkDesc NetworkDescriptor) (TensorDescriptor, error)
- func (h Handle) OutputTensorDetails(networkDesc NetworkDescriptor, numModes *int32, dataSize *uint, ...) errordeprecated
- func (h Handle) TensorDetails(tensorDesc TensorDescriptor, numModes *int32, dataSize *uint, ...) error
- func (h Handle) UpdateContractionOptimizerInfoFromPackedData(buffer unsafe.Pointer, sizeInBytes uint, ...) error
- func (h Handle) WorkspaceComputeContractionSizes(networkDesc NetworkDescriptor, optimizerInfo ContractionOptimizerInfo, ...) error
- func (h Handle) WorkspaceGetMemory(workDesc WorkspaceDescriptor, memSpace Memspace, workKind WorkspaceKind, ...) error
- func (h Handle) WorkspaceGetMemorySize(workDesc WorkspaceDescriptor, workPref WorksizePref, memSpace Memspace, ...) (int64, error)
- func (h Handle) WorkspacePurgeCache(workDesc WorkspaceDescriptor, memSpace Memspace) error
- func (h Handle) WorkspaceSetMemory(workDesc WorkspaceDescriptor, memSpace Memspace, workKind WorkspaceKind, ...) error
- type LibraryAttempt
- type LibraryConflictError
- type LibraryError
- type LoggerCallback
- type LoggerCallbackData
- type MemoryModel
- type Memspace
- type Network
- type NetworkAttributes
- type NetworkAutotunePreference
- func (n NetworkAutotunePreference) Attribute(handle Handle, attr NetworkAutotunePreferenceAttributes, buffer unsafe.Pointer, ...) error
- func (n *NetworkAutotunePreference) Close() error
- func (n NetworkAutotunePreference) Int32(handle Handle, attr NetworkAutotunePreferenceAttributes) (int32, error)
- func (n NetworkAutotunePreference) SetAttribute(handle Handle, attr NetworkAutotunePreferenceAttributes, buf unsafe.Pointer, ...) error
- func (n NetworkAutotunePreference) SetInt32(handle Handle, attr NetworkAutotunePreferenceAttributes, v int32) error
- type NetworkAutotunePreferenceAttributes
- type NetworkDescriptor
- type NetworkOperator
- type NodePair
- type OptimizerCost
- type Plan
- type Result
- type SliceGroup
- type SliceInfoPair
- type SlicingConfig
- type SmartOption
- type State
- type StateAccessor
- type StateExpectation
- type StateMarginal
- type StateProjectionMPS
- type StateSampler
- type SymbolError
- type Tensor
- type TensorDescriptor
- type TensorIDList
- type TensorQualifiers
- type TensorSVDConfig
- type TensorSVDInfo
- type WorksizePref
- type Workspace
- func (w *Workspace) Close() error
- func (w *Workspace) ComputeContractionSizes(net *Network, info ContractionOptimizerInfo) error
- func (w *Workspace) Descriptor() WorkspaceDescriptor
- func (w *Workspace) NewPlan(net *Network, info ContractionOptimizerInfo) (*Plan, error)
- func (w *Workspace) Provide(space Memspace, kind WorkspaceKind, ptr uintptr, size int64, free func()) error
- func (w *Workspace) PurgeCache(space Memspace) error
- func (w *Workspace) Size(pref WorksizePref, space Memspace, kind WorkspaceKind) (int64, error)
- type WorkspaceDescriptor
- type WorkspaceKind
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWorkspaceInUse reports an attempt to release a workspace, or the // memory behind it, while a plan that the library may still read it // through is live. ErrWorkspaceInUse = errors.New("cutensornet: workspace still referenced by a live plan") // ErrWorkspaceClosed reports use of a workspace after Close. ErrWorkspaceClosed = errors.New("cutensornet: workspace is closed") // ErrPlanClosed reports use of a plan after Close. ErrPlanClosed = errors.New("cutensornet: plan is closed") )
Errors reported by the workspace and plan ownership layer.
var ErrNetworkClosed = errors.New("cutensornet: network is closed")
ErrNetworkClosed reports use of a Network after Close.
var ErrNetworkInUse = errors.New("cutensornet: network still referenced by a live plan")
ErrNetworkInUse reports an attempt to release a Network while a Plan built from it is still live.
Functions ¶
func Close ¶
func Close() error
Close unloads the library and clears all bound function pointers.
The function pointers are package-level state, so Close must not be called concurrently with any other call into this package: doing so is a use-after-free. It is intended for test teardown, not for reclaiming a live library.
func ElementSize ¶
ElementSize returns the size in bytes of one element of type d, and reports whether d is a type whose size this package knows. Sub-byte types (the 4-bit and 6-bit formats) report false: their storage is packed and not addressable per element.
func GetCudartVersion ¶
GetCudartVersion wraps cutensornetGetCudartVersion. The error reports an unavailable library or symbol.
func GetVersion ¶
GetVersion wraps cutensornetGetVersion. The error reports an unavailable library or symbol.
func Has ¶
Has reports whether the named C symbol resolved in the loaded library, loading it first if necessary. It returns false if the library failed to load. Use it to gate on capabilities before calling into them.
func HasContractSlices ¶
func HasContractSlices() bool
HasContractSlices reports whether cutensornetContractSlices resolved in the loaded library.
func HasContractionAutotune ¶
func HasContractionAutotune() bool
HasContractionAutotune reports whether cutensornetContractionAutotune resolved in the loaded library.
func HasContractionAutotunePreferenceGetAttribute ¶
func HasContractionAutotunePreferenceGetAttribute() bool
HasContractionAutotunePreferenceGetAttribute reports whether cutensornetContractionAutotunePreferenceGetAttribute resolved in the loaded library.
func HasContractionAutotunePreferenceSetAttribute ¶
func HasContractionAutotunePreferenceSetAttribute() bool
HasContractionAutotunePreferenceSetAttribute reports whether cutensornetContractionAutotunePreferenceSetAttribute resolved in the loaded library.
func HasContractionOptimize ¶
func HasContractionOptimize() bool
HasContractionOptimize reports whether cutensornetContractionOptimize resolved in the loaded library.
func HasContractionOptimizerConfigGetAttribute ¶
func HasContractionOptimizerConfigGetAttribute() bool
HasContractionOptimizerConfigGetAttribute reports whether cutensornetContractionOptimizerConfigGetAttribute resolved in the loaded library.
func HasContractionOptimizerConfigSetAttribute ¶
func HasContractionOptimizerConfigSetAttribute() bool
HasContractionOptimizerConfigSetAttribute reports whether cutensornetContractionOptimizerConfigSetAttribute resolved in the loaded library.
func HasContractionOptimizerInfoGetAttribute ¶
func HasContractionOptimizerInfoGetAttribute() bool
HasContractionOptimizerInfoGetAttribute reports whether cutensornetContractionOptimizerInfoGetAttribute resolved in the loaded library.
func HasContractionOptimizerInfoGetPackedSize ¶
func HasContractionOptimizerInfoGetPackedSize() bool
HasContractionOptimizerInfoGetPackedSize reports whether cutensornetContractionOptimizerInfoGetPackedSize resolved in the loaded library.
func HasContractionOptimizerInfoPackData ¶
func HasContractionOptimizerInfoPackData() bool
HasContractionOptimizerInfoPackData reports whether cutensornetContractionOptimizerInfoPackData resolved in the loaded library.
func HasContractionOptimizerInfoSetAttribute ¶
func HasContractionOptimizerInfoSetAttribute() bool
HasContractionOptimizerInfoSetAttribute reports whether cutensornetContractionOptimizerInfoSetAttribute resolved in the loaded library.
func HasCreate ¶
func HasCreate() bool
HasCreate reports whether cutensornetCreate resolved in the loaded library.
func HasCreateContractionAutotunePreference ¶
func HasCreateContractionAutotunePreference() bool
HasCreateContractionAutotunePreference reports whether cutensornetCreateContractionAutotunePreference resolved in the loaded library.
func HasCreateContractionOptimizerConfig ¶
func HasCreateContractionOptimizerConfig() bool
HasCreateContractionOptimizerConfig reports whether cutensornetCreateContractionOptimizerConfig resolved in the loaded library.
func HasCreateContractionOptimizerInfo ¶
func HasCreateContractionOptimizerInfo() bool
HasCreateContractionOptimizerInfo reports whether cutensornetCreateContractionOptimizerInfo resolved in the loaded library.
func HasCreateContractionOptimizerInfoFromPackedData ¶
func HasCreateContractionOptimizerInfoFromPackedData() bool
HasCreateContractionOptimizerInfoFromPackedData reports whether cutensornetCreateContractionOptimizerInfoFromPackedData resolved in the loaded library.
func HasCreateContractionPlan ¶
func HasCreateContractionPlan() bool
HasCreateContractionPlan reports whether cutensornetCreateContractionPlan resolved in the loaded library.
func HasCreateNetwork ¶
func HasCreateNetwork() bool
HasCreateNetwork reports whether cutensornetCreateNetwork resolved in the loaded library.
func HasCreateNetworkAutotunePreference ¶
func HasCreateNetworkAutotunePreference() bool
HasCreateNetworkAutotunePreference reports whether cutensornetCreateNetworkAutotunePreference resolved in the loaded library.
func HasCreateNetworkDescriptor ¶
func HasCreateNetworkDescriptor() bool
HasCreateNetworkDescriptor reports whether cutensornetCreateNetworkDescriptor resolved in the loaded library.
func HasCreateSliceGroupFromIDRange ¶
func HasCreateSliceGroupFromIDRange() bool
HasCreateSliceGroupFromIDRange reports whether cutensornetCreateSliceGroupFromIDRange resolved in the loaded library.
func HasCreateSliceGroupFromIDs ¶
func HasCreateSliceGroupFromIDs() bool
HasCreateSliceGroupFromIDs reports whether cutensornetCreateSliceGroupFromIDs resolved in the loaded library.
func HasCreateTensorDescriptor ¶
func HasCreateTensorDescriptor() bool
HasCreateTensorDescriptor reports whether cutensornetCreateTensorDescriptor resolved in the loaded library.
func HasCreateWorkspaceDescriptor ¶
func HasCreateWorkspaceDescriptor() bool
HasCreateWorkspaceDescriptor reports whether cutensornetCreateWorkspaceDescriptor resolved in the loaded library.
func HasDestroy ¶
func HasDestroy() bool
HasDestroy reports whether cutensornetDestroy resolved in the loaded library.
func HasDestroyContractionAutotunePreference ¶
func HasDestroyContractionAutotunePreference() bool
HasDestroyContractionAutotunePreference reports whether cutensornetDestroyContractionAutotunePreference resolved in the loaded library.
func HasDestroyContractionOptimizerConfig ¶
func HasDestroyContractionOptimizerConfig() bool
HasDestroyContractionOptimizerConfig reports whether cutensornetDestroyContractionOptimizerConfig resolved in the loaded library.
func HasDestroyContractionOptimizerInfo ¶
func HasDestroyContractionOptimizerInfo() bool
HasDestroyContractionOptimizerInfo reports whether cutensornetDestroyContractionOptimizerInfo resolved in the loaded library.
func HasDestroyContractionPlan ¶
func HasDestroyContractionPlan() bool
HasDestroyContractionPlan reports whether cutensornetDestroyContractionPlan resolved in the loaded library.
func HasDestroyNetwork ¶
func HasDestroyNetwork() bool
HasDestroyNetwork reports whether cutensornetDestroyNetwork resolved in the loaded library.
func HasDestroyNetworkAutotunePreference ¶
func HasDestroyNetworkAutotunePreference() bool
HasDestroyNetworkAutotunePreference reports whether cutensornetDestroyNetworkAutotunePreference resolved in the loaded library.
func HasDestroyNetworkDescriptor ¶
func HasDestroyNetworkDescriptor() bool
HasDestroyNetworkDescriptor reports whether cutensornetDestroyNetworkDescriptor resolved in the loaded library.
func HasDestroySliceGroup ¶
func HasDestroySliceGroup() bool
HasDestroySliceGroup reports whether cutensornetDestroySliceGroup resolved in the loaded library.
func HasDestroyTensorDescriptor ¶
func HasDestroyTensorDescriptor() bool
HasDestroyTensorDescriptor reports whether cutensornetDestroyTensorDescriptor resolved in the loaded library.
func HasDestroyWorkspaceDescriptor ¶
func HasDestroyWorkspaceDescriptor() bool
HasDestroyWorkspaceDescriptor reports whether cutensornetDestroyWorkspaceDescriptor resolved in the loaded library.
func HasDistributedGetNumRanks ¶
func HasDistributedGetNumRanks() bool
HasDistributedGetNumRanks reports whether cutensornetDistributedGetNumRanks resolved in the loaded library.
func HasDistributedGetProcRank ¶
func HasDistributedGetProcRank() bool
HasDistributedGetProcRank reports whether cutensornetDistributedGetProcRank resolved in the loaded library.
func HasDistributedResetConfiguration ¶
func HasDistributedResetConfiguration() bool
HasDistributedResetConfiguration reports whether cutensornetDistributedResetConfiguration resolved in the loaded library.
func HasDistributedSynchronize ¶
func HasDistributedSynchronize() bool
HasDistributedSynchronize reports whether cutensornetDistributedSynchronize resolved in the loaded library.
func HasGetCudartVersion ¶
func HasGetCudartVersion() bool
HasGetCudartVersion reports whether cutensornetGetCudartVersion resolved in the loaded library.
func HasGetErrorString ¶
func HasGetErrorString() bool
HasGetErrorString reports whether cutensornetGetErrorString resolved in the loaded library.
func HasGetOutputTensorDescriptor ¶
func HasGetOutputTensorDescriptor() bool
HasGetOutputTensorDescriptor reports whether cutensornetGetOutputTensorDescriptor resolved in the loaded library.
func HasGetOutputTensorDetails ¶
func HasGetOutputTensorDetails() bool
HasGetOutputTensorDetails reports whether cutensornetGetOutputTensorDetails resolved in the loaded library.
func HasGetTensorDetails ¶
func HasGetTensorDetails() bool
HasGetTensorDetails reports whether cutensornetGetTensorDetails resolved in the loaded library.
func HasGetVersion ¶
func HasGetVersion() bool
HasGetVersion reports whether cutensornetGetVersion resolved in the loaded library.
func HasLoggerForceDisable ¶
func HasLoggerForceDisable() bool
HasLoggerForceDisable reports whether cutensornetLoggerForceDisable resolved in the loaded library.
func HasLoggerOpenFile ¶
func HasLoggerOpenFile() bool
HasLoggerOpenFile reports whether cutensornetLoggerOpenFile resolved in the loaded library.
func HasLoggerSetLevel ¶
func HasLoggerSetLevel() bool
HasLoggerSetLevel reports whether cutensornetLoggerSetLevel resolved in the loaded library.
func HasLoggerSetMask ¶
func HasLoggerSetMask() bool
HasLoggerSetMask reports whether cutensornetLoggerSetMask resolved in the loaded library.
func HasNetworkAppendTensor ¶
func HasNetworkAppendTensor() bool
HasNetworkAppendTensor reports whether cutensornetNetworkAppendTensor resolved in the loaded library.
func HasNetworkAutotuneContraction ¶
func HasNetworkAutotuneContraction() bool
HasNetworkAutotuneContraction reports whether cutensornetNetworkAutotuneContraction resolved in the loaded library.
func HasNetworkAutotunePreferenceGetAttribute ¶
func HasNetworkAutotunePreferenceGetAttribute() bool
HasNetworkAutotunePreferenceGetAttribute reports whether cutensornetNetworkAutotunePreferenceGetAttribute resolved in the loaded library.
func HasNetworkAutotunePreferenceSetAttribute ¶
func HasNetworkAutotunePreferenceSetAttribute() bool
HasNetworkAutotunePreferenceSetAttribute reports whether cutensornetNetworkAutotunePreferenceSetAttribute resolved in the loaded library.
func HasNetworkContract ¶
func HasNetworkContract() bool
HasNetworkContract reports whether cutensornetNetworkContract resolved in the loaded library.
func HasNetworkGetAttribute ¶
func HasNetworkGetAttribute() bool
HasNetworkGetAttribute reports whether cutensornetNetworkGetAttribute resolved in the loaded library.
func HasNetworkPrepareContraction ¶
func HasNetworkPrepareContraction() bool
HasNetworkPrepareContraction reports whether cutensornetNetworkPrepareContraction resolved in the loaded library.
func HasNetworkSetAttribute ¶
func HasNetworkSetAttribute() bool
HasNetworkSetAttribute reports whether cutensornetNetworkSetAttribute resolved in the loaded library.
func HasNetworkSetInputTensorMemory ¶
func HasNetworkSetInputTensorMemory() bool
HasNetworkSetInputTensorMemory reports whether cutensornetNetworkSetInputTensorMemory resolved in the loaded library.
func HasNetworkSetOptimizerInfo ¶
func HasNetworkSetOptimizerInfo() bool
HasNetworkSetOptimizerInfo reports whether cutensornetNetworkSetOptimizerInfo resolved in the loaded library.
func HasNetworkSetOutputTensor ¶
func HasNetworkSetOutputTensor() bool
HasNetworkSetOutputTensor reports whether cutensornetNetworkSetOutputTensor resolved in the loaded library.
func HasNetworkSetOutputTensorMemory ¶
func HasNetworkSetOutputTensorMemory() bool
HasNetworkSetOutputTensorMemory reports whether cutensornetNetworkSetOutputTensorMemory resolved in the loaded library.
func HasUpdateContractionOptimizerInfoFromPackedData ¶
func HasUpdateContractionOptimizerInfoFromPackedData() bool
HasUpdateContractionOptimizerInfoFromPackedData reports whether cutensornetUpdateContractionOptimizerInfoFromPackedData resolved in the loaded library.
func HasWorkspaceComputeContractionSizes ¶
func HasWorkspaceComputeContractionSizes() bool
HasWorkspaceComputeContractionSizes reports whether cutensornetWorkspaceComputeContractionSizes resolved in the loaded library.
func HasWorkspaceGetMemory ¶
func HasWorkspaceGetMemory() bool
HasWorkspaceGetMemory reports whether cutensornetWorkspaceGetMemory resolved in the loaded library.
func HasWorkspaceGetMemorySize ¶
func HasWorkspaceGetMemorySize() bool
HasWorkspaceGetMemorySize reports whether cutensornetWorkspaceGetMemorySize resolved in the loaded library.
func HasWorkspacePurgeCache ¶
func HasWorkspacePurgeCache() bool
HasWorkspacePurgeCache reports whether cutensornetWorkspacePurgeCache resolved in the loaded library.
func HasWorkspaceSetMemory ¶
func HasWorkspaceSetMemory() bool
HasWorkspaceSetMemory reports whether cutensornetWorkspaceSetMemory resolved in the loaded library.
func Load ¶
Load opens the shared library from path, or from the default search list when path is empty, and binds all symbols. Callers that need to direct loading should call Load before any other function; otherwise the first call loads from the default search list.
Load is idempotent: calling it again with the same path, or with an empty path, returns nil. Calling it with a different path after a successful load returns *LibraryConflictError rather than replacing the library. After a failed load, Load retries.
func Loaded ¶
func Loaded() bool
Loaded reports whether the library is currently loaded. It does not trigger a load.
func LoggerForceDisable ¶
func LoggerForceDisable() error
LoggerForceDisable wraps cutensornetLoggerForceDisable.
func LoggerOpenFile ¶
LoggerOpenFile wraps cutensornetLoggerOpenFile.
func LoggerSetLevel ¶
LoggerSetLevel wraps cutensornetLoggerSetLevel.
func LoggerSetMask ¶
LoggerSetMask wraps cutensornetLoggerSetMask.
Types ¶
type BindFailure ¶
BindFailure names a symbol the loaded library exports but that could not be bound, and why.
func BindFailures ¶
func BindFailures() []BindFailure
BindFailures returns the symbols the loaded library exports that could not be bound, sorted by symbol name, or nil if every exported symbol bound. Calling one of these reports *SymbolError with the same Err.
A load that reports no error can still leave symbols unbound: the library is fine and the signatures are not representable here. Call this after Load to find that out at once rather than one call site at a time. It does not trigger a load, and returns nil if none has happened.
type CallError ¶
CallError reports that a library call returned a failure result.
Unwrap returns Result, so errors.Is(err, c) reports whether the call returned the Result constant c, and errors.As(err, &r) with r of type Result recovers the code.
type ComputeType ¶
type ComputeType int32
ComputeType represents encodes cuTensorNet's compute type (see "User Guide - Accuracy Guarantees" for details).
const ( Compute16F ComputeType = 1 << 0 // floating-point: 5-bit exponent and 10-bit mantissa (aka half) Compute16BF ComputeType = 1 << 10 // floating-point: 8-bit exponent and 7-bit mantissa (aka bfloat) ComputeTF32 ComputeType = 1 << 12 // floating-point: 8-bit exponent and 10-bit mantissa (aka tensor-float-32) Compute3xtf32 ComputeType = 1 << 13 // floating-point: More precise than TF32, but less precise than float Compute32F ComputeType = 1 << 2 // floating-point: 8-bit exponent and 23-bit mantissa (aka float) Compute64F ComputeType = 1 << 4 // floating-point: 11-bit exponent and 52-bit mantissa (aka double) Compute8U ComputeType = 1 << 6 // 8-bit unsigned integer Compute8I ComputeType = 1 << 8 // 8-bit signed integer Compute32U ComputeType = 1 << 7 // 32-bit unsigned integer Compute32I ComputeType = 1 << 9 // 32-bit signed integer )
func (ComputeType) String ¶
func (e ComputeType) String() string
String returns the constant name, or a numeric representation for unknown values.
type ContractionAutotunePreference ¶
type ContractionAutotunePreference uintptr
ContractionAutotunePreference is an opaque handle for cutensornetContractionAutotunePreference_t.
func (ContractionAutotunePreference) Attribute
deprecated
func (c ContractionAutotunePreference) Attribute(handle Handle, attr ContractionAutotunePreferenceAttributes, buffer unsafe.Pointer, sizeInBytes uint) error
Attribute wraps cutensornetContractionAutotunePreferenceGetAttribute.
Deprecated: Use NetworkAutotunePreference.Attribute instead.
func (*ContractionAutotunePreference) Close
deprecated
func (c *ContractionAutotunePreference) Close() error
Close wraps cutensornetDestroyContractionAutotunePreference.
If c is zero, Close returns nil. Otherwise Close sets c to zero when the call succeeds and leaves it unchanged when it fails. Only c is zeroed: a copy of it still refers to the released object.
Deprecated: Use NetworkAutotunePreference.Close instead.
func (ContractionAutotunePreference) Int32 ¶
func (a ContractionAutotunePreference) Int32(handle Handle, attr ContractionAutotunePreferenceAttributes) (int32, error)
Int32 returns an int32-valued autotune preference attribute.
func (ContractionAutotunePreference) SetAttribute
deprecated
func (c ContractionAutotunePreference) SetAttribute(handle Handle, attr ContractionAutotunePreferenceAttributes, buffer unsafe.Pointer, sizeInBytes uint) error
SetAttribute wraps cutensornetContractionAutotunePreferenceSetAttribute.
Deprecated: Use NetworkAutotunePreference.SetAttribute instead.
func (ContractionAutotunePreference) SetInt32 ¶
func (a ContractionAutotunePreference) SetInt32(handle Handle, attr ContractionAutotunePreferenceAttributes, v int32) error
SetInt32 sets an int32-valued autotune preference attribute.
type ContractionAutotunePreferenceAttributes
deprecated
type ContractionAutotunePreferenceAttributes int32
ContractionAutotunePreferenceAttributes lists all attributes of a ContractionAutotunePreference that are accessible.
Deprecated: Deprecated by NVIDIA.
const ( ContractionAutotuneMaxIterations ContractionAutotunePreferenceAttributes = 0 // int32_t: Maximal number of auto-tune iterations for each pairwise contraction (default: 3). ContractionAutotuneIntermediateModes ContractionAutotunePreferenceAttributes = 1 // int32_t: 0=OFF, 1=ON, 2=AUTO (default). If set to 1, cutensorContractionAutotune() auto-tunes the intermediate mode order by executing one slice of the network a few times in order to determine how to achieve the best performance with cuTENSOR. If set to 2, heuristically chooses whether to auto-tune the intermediate mode order based upon network characteristics. )
func (ContractionAutotunePreferenceAttributes) String ¶
func (e ContractionAutotunePreferenceAttributes) String() string
String returns the constant name, or a numeric representation for unknown values.
type ContractionOptimizerConfig ¶
type ContractionOptimizerConfig uintptr
ContractionOptimizerConfig is an opaque handle for cutensornetContractionOptimizerConfig_t.
func (ContractionOptimizerConfig) Attribute ¶
func (c ContractionOptimizerConfig) Attribute(handle Handle, attr ContractionOptimizerConfigAttributes, buffer unsafe.Pointer, sizeInBytes uint) error
Attribute wraps cutensornetContractionOptimizerConfigGetAttribute.
func (*ContractionOptimizerConfig) Close ¶
func (c *ContractionOptimizerConfig) Close() error
Close wraps cutensornetDestroyContractionOptimizerConfig.
If c is zero, Close returns nil. Otherwise Close sets c to zero when the call succeeds and leaves it unchanged when it fails. Only c is zeroed: a copy of it still refers to the released object.
func (ContractionOptimizerConfig) Int32 ¶
func (c ContractionOptimizerConfig) Int32(handle Handle, attr ContractionOptimizerConfigAttributes) (int32, error)
Int32 returns an int32-valued or enum-valued configuration attribute.
func (ContractionOptimizerConfig) SetAttribute ¶
func (c ContractionOptimizerConfig) SetAttribute(handle Handle, attr ContractionOptimizerConfigAttributes, buffer unsafe.Pointer, sizeInBytes uint) error
SetAttribute wraps cutensornetContractionOptimizerConfigSetAttribute.
func (ContractionOptimizerConfig) SetInt32 ¶
func (c ContractionOptimizerConfig) SetInt32(handle Handle, attr ContractionOptimizerConfigAttributes, v int32) error
SetInt32 sets an int32-valued or enum-valued configuration attribute.
type ContractionOptimizerConfigAttributes ¶
type ContractionOptimizerConfigAttributes int32
ContractionOptimizerConfigAttributes lists all attributes of a ContractionOptimizerConfig that can be modified.
const ( ContractionOptimizerConfigGraphNumPartitions ContractionOptimizerConfigAttributes = 0 // int32_t: The network is recursively split over `num_partitions` until the size of each partition is less than or equal to the cutoff. ContractionOptimizerConfigGraphCutoffSize ContractionOptimizerConfigAttributes = 1 // int32_t: The network is recursively split over `num_partitions` until the size of each partition is less than or equal to this cutoff. ContractionOptimizerConfigGraphAlgorithm ContractionOptimizerConfigAttributes = 2 // [GraphAlgo]: the graph algorithm to be used in graph partitioning. Choices include ContractionOptimizerConfigGraphImbalanceFactor ContractionOptimizerConfigAttributes = 3 // int32_t: Specifies the maximum allowed size imbalance among the partitions. Allowed range [30, 2000]. When the hyper-optimizer is disabled the default value is 200. ContractionOptimizerConfigGraphNumIterations ContractionOptimizerConfigAttributes = 4 // int32_t: Specifies the number of iterations for the refinement algorithms at each stage of the uncoarsening process of the graph partitioner. ContractionOptimizerConfigGraphNumCuts ContractionOptimizerConfigAttributes = 5 // int32_t: Specifies the number of different partitioning that the graph partitioner will compute. The final partitioning is the one that achieves the best edge-cut or communication volume. ContractionOptimizerConfigReconfigNumIterations ContractionOptimizerConfigAttributes = 10 // int32_t: Specifies the number of subtrees to be chosen for reconfiguration. ContractionOptimizerConfigReconfigNumLeaves ContractionOptimizerConfigAttributes = 11 // int32_t: Specifies the maximum number of leaves in the subtree chosen for optimization in each reconfiguration iteration. ContractionOptimizerConfigSlicerDisableSlicing ContractionOptimizerConfigAttributes = 20 // int32_t: If set to 1, disables slicing regardless of memory available. ContractionOptimizerConfigSlicerMemoryModel ContractionOptimizerConfigAttributes = 21 // [MemoryModel]: Memory model used to determine workspace size. ContractionOptimizerConfigSlicerMemoryFactor ContractionOptimizerConfigAttributes = 22 // int32_t: The memory limit for the first slice-finding iteration as a percentage of the workspace size. ContractionOptimizerConfigSlicerMinSlices ContractionOptimizerConfigAttributes = 23 // int32_t: Minimum number of slices to produce at the first round of slicing. Default is 1. ContractionOptimizerConfigSlicerSliceFactor ContractionOptimizerConfigAttributes = 24 // int32_t: Factor by which to increase the total number of slice at each slicing round. Default is 32, must be at least 2. ContractionOptimizerConfigHyperNumSamples ContractionOptimizerConfigAttributes = 30 // int32_t: Number of hyper-optimizer random samples. Default 0 (disabled). ContractionOptimizerConfigHyperNumThreads ContractionOptimizerConfigAttributes = 31 // int32_t: Number of parallel hyper-optimizer threads. Default is number-of-cores / 2. ContractionOptimizerConfigSimplificationDisableDr ContractionOptimizerConfigAttributes = 40 // int32_t: If set to 1, disable deferred rank simplification. ContractionOptimizerConfigSeed ContractionOptimizerConfigAttributes = 60 // int32_t: Random seed to be used internally in order to reproduce same path. ContractionOptimizerConfigCostFunctionObjective ContractionOptimizerConfigAttributes = 61 // [OptimizerCost]: the objective function to use for finding the optimal contraction path. ContractionOptimizerConfigCacheReuseNruns ContractionOptimizerConfigAttributes = 62 // int32_t: Number of runs that utilize cache-reuse ContractionOptimizerConfigSmartOption ContractionOptimizerConfigAttributes = 63 // [SmartOption]: enable or disable smart options. ContractionOptimizerConfigGpuArch ContractionOptimizerConfigAttributes = 64 // Set the GPU architecture to optimize the path for. )
func (ContractionOptimizerConfigAttributes) String ¶
func (e ContractionOptimizerConfigAttributes) String() string
String returns the constant name, or a numeric representation for unknown values.
type ContractionOptimizerInfo ¶
type ContractionOptimizerInfo uintptr
ContractionOptimizerInfo is an opaque handle for cutensornetContractionOptimizerInfo_t.
func (ContractionOptimizerInfo) Attribute ¶
func (c ContractionOptimizerInfo) Attribute(handle Handle, attr ContractionOptimizerInfoAttributes, buffer unsafe.Pointer, sizeInBytes uint) error
Attribute wraps cutensornetContractionOptimizerInfoGetAttribute.
func (*ContractionOptimizerInfo) Close ¶
func (c *ContractionOptimizerInfo) Close() error
Close wraps cutensornetDestroyContractionOptimizerInfo.
If c is zero, Close returns nil. Otherwise Close sets c to zero when the call succeeds and leaves it unchanged when it fails. Only c is zeroed: a copy of it still refers to the released object.
func (ContractionOptimizerInfo) Float64 ¶
func (c ContractionOptimizerInfo) Float64(handle Handle, attr ContractionOptimizerInfoAttributes) (float64, error)
Float64 returns a double-valued optimizer info attribute, such as the estimated FLOP count of the chosen path.
The FLOP and runtime attributes are the library's own estimates for the path it selected. They are not measurements of anything this package ran.
func (ContractionOptimizerInfo) Int32 ¶
func (c ContractionOptimizerInfo) Int32(handle Handle, attr ContractionOptimizerInfoAttributes) (int32, error)
Int32 returns an int32-valued optimizer info attribute.
func (ContractionOptimizerInfo) Int64 ¶
func (c ContractionOptimizerInfo) Int64(handle Handle, attr ContractionOptimizerInfoAttributes) (int64, error)
Int64 returns an int64-valued optimizer info attribute, such as the number of slices the path was split into.
func (ContractionOptimizerInfo) PackData ¶
func (c ContractionOptimizerInfo) PackData(handle Handle, buffer unsafe.Pointer, sizeInBytes uint) error
PackData wraps cutensornetContractionOptimizerInfoPackData.
func (ContractionOptimizerInfo) PackedSize ¶
func (c ContractionOptimizerInfo) PackedSize(handle Handle) (uint, error)
PackedSize wraps cutensornetContractionOptimizerInfoGetPackedSize.
func (ContractionOptimizerInfo) SetAttribute ¶
func (c ContractionOptimizerInfo) SetAttribute(handle Handle, attr ContractionOptimizerInfoAttributes, buffer unsafe.Pointer, sizeInBytes uint) error
SetAttribute wraps cutensornetContractionOptimizerInfoSetAttribute.
func (ContractionOptimizerInfo) SetInt64 ¶
func (c ContractionOptimizerInfo) SetInt64(handle Handle, attr ContractionOptimizerInfoAttributes, v int64) error
SetInt64 sets an int64-valued optimizer info attribute.
type ContractionOptimizerInfoAttributes ¶
type ContractionOptimizerInfoAttributes int32
ContractionOptimizerInfoAttributes lists all attributes of a ContractionOptimizerInfo that are accessible.
const ( ContractionOptimizerInfoPath ContractionOptimizerInfoAttributes = 0 // [ContractionPath]: Pointer to the contraction path. ContractionOptimizerInfoNumSlices ContractionOptimizerInfoAttributes = 10 // int64_t: Total number of slices. ContractionOptimizerInfoNumSlicedModes ContractionOptimizerInfoAttributes = 11 // int32_t: Total number of sliced modes. (get-only) ContractionOptimizerInfoSlicedMode ContractionOptimizerInfoAttributes = 12 // int32_t* slicedModes: slicedModes[i] with i < numSlicedModes refers to the mode label of the i-th sliced mode (see modesIn w.r.t. [Handle.CreateNetworkDescriptor]). (get-only) ContractionOptimizerInfoSlicedExtent ContractionOptimizerInfoAttributes = 13 // int64_t* slicedExtents: slicedExtents[i] with i < numSlicedModes refers to the sliced extent of the i-th sliced mode (see extentsIn w.r.t. [Handle.CreateNetworkDescriptor]). (get-only) ContractionOptimizerInfoSlicingConfig ContractionOptimizerInfoAttributes = 14 // [SlicingConfig]*: Pointer to the slice configuration settings (number of slices, sliced modes, and sliced extents) used with the given path. ContractionOptimizerInfoSlicingOverhead ContractionOptimizerInfoAttributes = 15 // double: Overhead due to slicing. ContractionOptimizerInfoPhase1FlopCount ContractionOptimizerInfoAttributes = 20 // double: FLOP count for the given network after phase 1 of pathfinding (i.e., before slicing and reconfig). ContractionOptimizerInfoFlopCount ContractionOptimizerInfoAttributes = 21 // double: FLOP count for the given network after slicing. ContractionOptimizerInfoEffectiveFlopsEst ContractionOptimizerInfoAttributes = 22 // double: Experimental. Returns the total flop-equivalent for one pass for all slices based on the cost function. When the cost function is flops, conventional flops are returned. When a time-based cost function is chosen, effectiveFlopsEstimation = RuntimeEstimation * ops_peak. ContractionOptimizerInfoRuntimeEst ContractionOptimizerInfoAttributes = 23 // double: Experimental. Returns the runtime estimation in [s] based on the time cost function objective for one pass for all slices. ContractionOptimizerInfoLargestTensor ContractionOptimizerInfoAttributes = 24 // double: The number of elements in the largest intermediate tensor. ContractionOptimizerInfoIntermediateModes ContractionOptimizerInfoAttributes = 30 // int32_t* intermediateModes: The modes in \f$[\text intermediateModes [\sum_ n=0 ^ i-1 \text numIntermediateModes [n]], \text intermediateModes [\sum_ n=0 ^ i \text numIntermediateModes [n]])\f$ are the modes for the intermediate tensor i (so the total bytes to store intermediateModes is \f$\text sizeof (\text int32_t )*\left(\sum_n \text numIntermediateModes [n]\right)\f$). ContractionOptimizerInfoNumIntermediateModes ContractionOptimizerInfoAttributes = 31 // int32_t* numIntermediateModes: numIntermediateModes[i] with i < numInputs - 1 is the number of modes for the intermediate tensor i (see numInputs w.r.t. [Handle.CreateNetworkDescriptor]). )
func (ContractionOptimizerInfoAttributes) String ¶
func (e ContractionOptimizerInfoAttributes) String() string
String returns the constant name, or a numeric representation for unknown values.
type ContractionPath ¶
ContractionPath holds information about the contraction path.
The provided path is interchangeable with the path returned by numpy.einsum_path.
type ContractionPlan ¶
type ContractionPlan uintptr
ContractionPlan is an opaque handle for cutensornetContractionPlan_t.
func (*ContractionPlan) Close
deprecated
func (c *ContractionPlan) Close() error
Close wraps cutensornetDestroyContractionPlan.
If c is zero, Close returns nil. Otherwise Close sets c to zero when the call succeeds and leaves it unchanged when it fails. Only c is zeroed: a copy of it still refers to the released object.
Deprecated: Deprecated by NVIDIA.
type DataType ¶
type DataType int32
DataType identifies a CUDA data representation.
const ( // real as a half R16F DataType = 2 // complex as a pair of half numbers C16F DataType = 6 // real as a nv_bfloat16 R16BF DataType = 14 // complex as a pair of nv_bfloat16 numbers C16BF DataType = 15 // real as a float R32F DataType = 0 // complex as a pair of float numbers C32F DataType = 4 // real as a double R64F DataType = 1 // complex as a pair of double numbers C64F DataType = 5 // real as a signed 4-bit int R4I DataType = 16 // complex as a pair of signed 4-bit int numbers C4I DataType = 17 // real as a unsigned 4-bit int R4U DataType = 18 // complex as a pair of unsigned 4-bit int numbers C4U DataType = 19 // real as a signed 8-bit int R8I DataType = 3 // complex as a pair of signed 8-bit int numbers C8I DataType = 7 // real as a unsigned 8-bit int R8U DataType = 8 // complex as a pair of unsigned 8-bit int numbers C8U DataType = 9 // real as a signed 16-bit int R16I DataType = 20 // complex as a pair of signed 16-bit int numbers C16I DataType = 21 // real as a unsigned 16-bit int R16U DataType = 22 // complex as a pair of unsigned 16-bit int numbers C16U DataType = 23 // real as a signed 32-bit int R32I DataType = 10 // complex as a pair of signed 32-bit int numbers C32I DataType = 11 // real as a unsigned 32-bit int R32U DataType = 12 // complex as a pair of unsigned 32-bit int numbers C32U DataType = 13 // real as a signed 64-bit int R64I DataType = 24 // complex as a pair of signed 64-bit int numbers C64I DataType = 25 // real as a unsigned 64-bit int R64U DataType = 26 // complex as a pair of unsigned 64-bit int numbers C64U DataType = 27 // real as a nv_fp8_e4m3 R8F_E4M3 DataType = 28 // real as an unsigned nv_fp8_e4m3 R8F_UE4M3 DataType = R8F_E4M3 // real as a nv_fp8_e5m2 R8F_E5M2 DataType = 29 // real as an exponent-only unsigned nv_fp8_e8m0 R8F_UE8M0 DataType = 30 // real as a nv_fp6_e2m3 R6F_E2M3 DataType = 31 // real as a nv_fp6_e3m2 R6F_E3M2 DataType = 32 // real as a nv_fp4_e2m1 R4F_E2M1 DataType = 33 // real as an unsigned nv_fp8_ue5m3 R8FUe5m3 DataType = 34 )
DataType constants.
type Handle ¶
type Handle uintptr
Handle is an opaque handle for cutensornetHandle_t.
func (*Handle) Close ¶
Close wraps cutensornetDestroy.
If h is zero, Close returns nil. Otherwise Close sets h to zero when the call succeeds and leaves it unchanged when it fails. Only h is zeroed: a copy of it still refers to the released object.
func (Handle) ContractSlices
deprecated
func (h Handle) ContractSlices(plan ContractionPlan, rawDataIn *uintptr, rawDataOut uintptr, accumulateOutput int32, workDesc WorkspaceDescriptor, sliceGroup SliceGroup, stream driver.Stream) error
ContractSlices wraps cutensornetContractSlices.
Deprecated: Use Handle.NetworkContract instead.
func (Handle) ContractionAutotune
deprecated
func (h Handle) ContractionAutotune(plan ContractionPlan, rawDataIn *uintptr, rawDataOut uintptr, workDesc WorkspaceDescriptor, pref ContractionAutotunePreference, stream driver.Stream) error
ContractionAutotune wraps cutensornetContractionAutotune.
Deprecated: Use Handle.NetworkAutotuneContraction instead.
func (Handle) ContractionOptimize ¶
func (h Handle) ContractionOptimize(networkDesc NetworkDescriptor, optimizerConfig ContractionOptimizerConfig, workspaceSizeConstraint uint64, optimizerInfo ContractionOptimizerInfo) error
ContractionOptimize wraps cutensornetContractionOptimize.
func (Handle) CreateContractionAutotunePreference
deprecated
func (h Handle) CreateContractionAutotunePreference() (ContractionAutotunePreference, error)
CreateContractionAutotunePreference wraps cutensornetCreateContractionAutotunePreference.
Deprecated: Use Handle.CreateNetworkAutotunePreference instead.
func (Handle) CreateContractionOptimizerConfig ¶
func (h Handle) CreateContractionOptimizerConfig() (ContractionOptimizerConfig, error)
CreateContractionOptimizerConfig wraps cutensornetCreateContractionOptimizerConfig.
func (Handle) CreateContractionOptimizerInfo ¶
func (h Handle) CreateContractionOptimizerInfo(networkDesc NetworkDescriptor) (ContractionOptimizerInfo, error)
CreateContractionOptimizerInfo wraps cutensornetCreateContractionOptimizerInfo.
func (Handle) CreateContractionOptimizerInfoFromPackedData ¶
func (h Handle) CreateContractionOptimizerInfoFromPackedData(networkDesc NetworkDescriptor, buffer unsafe.Pointer, sizeInBytes uint) (ContractionOptimizerInfo, error)
CreateContractionOptimizerInfoFromPackedData wraps cutensornetCreateContractionOptimizerInfoFromPackedData.
func (Handle) CreateContractionPlan
deprecated
func (h Handle) CreateContractionPlan(networkDesc NetworkDescriptor, optimizerInfo ContractionOptimizerInfo, workDesc WorkspaceDescriptor) (ContractionPlan, error)
CreateContractionPlan wraps cutensornetCreateContractionPlan.
Deprecated: Use Handle.NetworkPrepareContraction instead.
func (Handle) CreateNetwork ¶
func (h Handle) CreateNetwork() (NetworkDescriptor, error)
CreateNetwork wraps cutensornetCreateNetwork.
func (Handle) CreateNetworkAutotunePreference ¶
func (h Handle) CreateNetworkAutotunePreference() (NetworkAutotunePreference, error)
CreateNetworkAutotunePreference wraps cutensornetCreateNetworkAutotunePreference.
func (Handle) CreateNetworkDescriptor
deprecated
func (h Handle) CreateNetworkDescriptor(numInputs int32, numModesIn *int32, extentsIn []unsafe.Pointer, stridesIn []unsafe.Pointer, modesIn []unsafe.Pointer, qualifiersIn *TensorQualifiers, numModesOut int32, extentsOut *int64, stridesOut *int64, modesOut *int32, dataType DataType, computeType ComputeType) (NetworkDescriptor, error)
CreateNetworkDescriptor wraps cutensornetCreateNetworkDescriptor.
Deprecated: Use Handle.CreateNetwork instead.
func (Handle) CreateSliceGroupFromIDRange ¶
func (h Handle) CreateSliceGroupFromIDRange(sliceIdStart int64, sliceIdStop int64, sliceIdStep int64) (SliceGroup, error)
CreateSliceGroupFromIDRange wraps cutensornetCreateSliceGroupFromIDRange.
func (Handle) CreateSliceGroupFromIDs ¶
func (h Handle) CreateSliceGroupFromIDs(beginIDSequence *int64, endIDSequence *int64) (SliceGroup, error)
CreateSliceGroupFromIDs wraps cutensornetCreateSliceGroupFromIDs.
func (Handle) CreateTensorDescriptor ¶
func (h Handle) CreateTensorDescriptor(numModes int32, extents *int64, strides *int64, modeLabels *int32, dataType DataType) (TensorDescriptor, error)
CreateTensorDescriptor wraps cutensornetCreateTensorDescriptor.
func (Handle) CreateWorkspaceDescriptor ¶
func (h Handle) CreateWorkspaceDescriptor() (WorkspaceDescriptor, error)
CreateWorkspaceDescriptor wraps cutensornetCreateWorkspaceDescriptor.
func (Handle) DistributedGetNumRanks ¶
DistributedGetNumRanks wraps cutensornetDistributedGetNumRanks.
func (Handle) DistributedGetProcRank ¶
DistributedGetProcRank wraps cutensornetDistributedGetProcRank.
func (Handle) DistributedResetConfiguration ¶
DistributedResetConfiguration wraps cutensornetDistributedResetConfiguration.
func (Handle) DistributedSynchronize ¶
DistributedSynchronize wraps cutensornetDistributedSynchronize.
func (Handle) NetworkAppendTensor ¶
func (h Handle) NetworkAppendTensor(networkDesc NetworkDescriptor, numModes int32, extents *int64, modeLabels *int32, qualifiers *TensorQualifiers, dataType DataType) (int64, error)
NetworkAppendTensor wraps cutensornetNetworkAppendTensor.
func (Handle) NetworkAutotuneContraction ¶
func (h Handle) NetworkAutotuneContraction(networkDesc NetworkDescriptor, workDesc WorkspaceDescriptor, pref NetworkAutotunePreference, stream driver.Stream) error
NetworkAutotuneContraction wraps cutensornetNetworkAutotuneContraction.
func (Handle) NetworkContract ¶
func (h Handle) NetworkContract(networkDesc NetworkDescriptor, accumulateOutput int32, workDesc WorkspaceDescriptor, sliceGroup SliceGroup, stream driver.Stream) error
NetworkContract wraps cutensornetNetworkContract.
func (Handle) NetworkGetAttribute ¶
func (h Handle) NetworkGetAttribute(networkDesc NetworkDescriptor, attr NetworkAttributes, buffer unsafe.Pointer, sizeInBytes uint) error
NetworkGetAttribute wraps cutensornetNetworkGetAttribute.
func (Handle) NetworkPrepareContraction ¶
func (h Handle) NetworkPrepareContraction(networkDesc NetworkDescriptor, workDesc WorkspaceDescriptor) error
NetworkPrepareContraction wraps cutensornetNetworkPrepareContraction.
func (Handle) NetworkSetAttribute ¶
func (h Handle) NetworkSetAttribute(networkDesc NetworkDescriptor, attr NetworkAttributes, buffer unsafe.Pointer, sizeInBytes uint) error
NetworkSetAttribute wraps cutensornetNetworkSetAttribute.
func (Handle) NetworkSetInputTensorMemory ¶
func (h Handle) NetworkSetInputTensorMemory(networkDesc NetworkDescriptor, tensorId int64, buffer uintptr, strides *int64) error
NetworkSetInputTensorMemory wraps cutensornetNetworkSetInputTensorMemory.
func (Handle) NetworkSetOptimizerInfo ¶
func (h Handle) NetworkSetOptimizerInfo(networkDesc NetworkDescriptor, optimizerInfo ContractionOptimizerInfo) error
NetworkSetOptimizerInfo wraps cutensornetNetworkSetOptimizerInfo.
func (Handle) NetworkSetOutputTensor ¶
func (h Handle) NetworkSetOutputTensor(networkDesc NetworkDescriptor, numModes int32, modeLabels *int32, dataType DataType) error
NetworkSetOutputTensor wraps cutensornetNetworkSetOutputTensor.
func (Handle) NetworkSetOutputTensorMemory ¶
func (h Handle) NetworkSetOutputTensorMemory(networkDesc NetworkDescriptor, buffer uintptr, strides *int64) error
NetworkSetOutputTensorMemory wraps cutensornetNetworkSetOutputTensorMemory.
func (Handle) NewNetwork ¶
func (h Handle) NewNetwork(inputs []Tensor, output *Tensor, dataType DataType, computeType ComputeType) (*Network, error)
NewNetwork describes a tensor network with the given input operands and output operand and returns the resulting descriptor.
A nil output asks the library to infer the output modes from the inputs: any mode that appears in exactly one input survives, in the order the library chooses. Pass an explicit output to fix the mode order, the extents, or a non-default layout. An output with no modes is a full reduction to a scalar.
dataType applies to every operand; the library does not support mixing element types within one network. computeType selects the accumulation precision and must be one of the combinations cuTensorNet documents for dataType; an unsupported pair is rejected by the library, not here.
NewNetwork validates, before calling the library, that every operand is self-consistent and that a mode label has the same extent everywhere it appears. It does not validate the data-type and compute-type pairing, the strides against the underlying allocation, or anything that needs a device.
The returned Network must be released with Network.Close.
Example ¶
ExampleHandle_NewNetwork describes the matrix product C[m,n] = A[m,k] B[k,n] as a two-tensor network. The operands are stored column-major, stated with explicit strides: cuTensorNet operands are strided, and a row-major buffer would need strides of {K, 1} and {N, 1} instead.
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/cutensornet"
)
func main() {
h, err := cutensornet.Create()
if err != nil {
fmt.Println("cuTensorNet unavailable:", err)
return
}
defer h.Close()
const M, K, N = 64, 32, 48
a := cutensornet.Tensor{
Modes: []int32{'m', 'k'},
Extents: []int64{M, K},
Strides: []int64{1, M},
}
b := cutensornet.Tensor{
Modes: []int32{'k', 'n'},
Extents: []int64{K, N},
Strides: []int64{1, K},
}
c := cutensornet.Tensor{
Modes: []int32{'m', 'n'},
Extents: []int64{M, N},
Strides: []int64{1, M},
}
net, err := h.NewNetwork([]cutensornet.Tensor{a, b}, &c, cutensornet.R32F, cutensornet.Compute32F)
if err != nil {
fmt.Println("describe network:", err)
return
}
defer net.Close()
fmt.Println("network with", net.NumInputs(), "input tensors")
}
Output:
func (Handle) NewWorkspace ¶
NewWorkspace creates an empty workspace descriptor.
The returned Workspace must be released with Workspace.Close.
func (Handle) OutputTensorDescriptor ¶
func (h Handle) OutputTensorDescriptor(networkDesc NetworkDescriptor) (TensorDescriptor, error)
OutputTensorDescriptor wraps cutensornetGetOutputTensorDescriptor.
func (Handle) OutputTensorDetails
deprecated
func (h Handle) OutputTensorDetails(networkDesc NetworkDescriptor, numModes *int32, dataSize *uint, modeLabels *int32, extents *int64, strides *int64) error
OutputTensorDetails wraps cutensornetGetOutputTensorDetails.
Deprecated: Use Handle.OutputTensorDescriptor instead.
func (Handle) TensorDetails ¶
func (h Handle) TensorDetails(tensorDesc TensorDescriptor, numModes *int32, dataSize *uint, modeLabels *int32, extents *int64, strides *int64) error
TensorDetails wraps cutensornetGetTensorDetails.
func (Handle) UpdateContractionOptimizerInfoFromPackedData ¶
func (h Handle) UpdateContractionOptimizerInfoFromPackedData(buffer unsafe.Pointer, sizeInBytes uint, optimizerInfo ContractionOptimizerInfo) error
UpdateContractionOptimizerInfoFromPackedData wraps cutensornetUpdateContractionOptimizerInfoFromPackedData.
func (Handle) WorkspaceComputeContractionSizes ¶
func (h Handle) WorkspaceComputeContractionSizes(networkDesc NetworkDescriptor, optimizerInfo ContractionOptimizerInfo, workDesc WorkspaceDescriptor) error
WorkspaceComputeContractionSizes wraps cutensornetWorkspaceComputeContractionSizes.
func (Handle) WorkspaceGetMemory ¶
func (h Handle) WorkspaceGetMemory(workDesc WorkspaceDescriptor, memSpace Memspace, workKind WorkspaceKind, memoryPtr *uintptr, memorySize *int64) error
WorkspaceGetMemory wraps cutensornetWorkspaceGetMemory.
func (Handle) WorkspaceGetMemorySize ¶
func (h Handle) WorkspaceGetMemorySize(workDesc WorkspaceDescriptor, workPref WorksizePref, memSpace Memspace, workKind WorkspaceKind) (int64, error)
WorkspaceGetMemorySize wraps cutensornetWorkspaceGetMemorySize.
func (Handle) WorkspacePurgeCache ¶
func (h Handle) WorkspacePurgeCache(workDesc WorkspaceDescriptor, memSpace Memspace) error
WorkspacePurgeCache wraps cutensornetWorkspacePurgeCache.
func (Handle) WorkspaceSetMemory ¶
func (h Handle) WorkspaceSetMemory(workDesc WorkspaceDescriptor, memSpace Memspace, workKind WorkspaceKind, memoryPtr uintptr, memorySize int64) error
WorkspaceSetMemory wraps cutensornetWorkspaceSetMemory.
type LibraryAttempt ¶
LibraryAttempt records one failed attempt to open the shared library.
type LibraryConflictError ¶
type LibraryConflictError struct {
Loaded string
Requested string
// Implicit reports that the loaded library was opened lazily and no
// successful Load has since acknowledged it. A
// caller that sees this called some
// other function first, and that call took the default search list.
Implicit bool
}
LibraryConflictError reports a Load call naming a different library than the one already loaded. Only one library is loaded per process.
func (*LibraryConflictError) Error ¶
func (e *LibraryConflictError) Error() string
Error reports the conflicting library paths, and whether the library that is already loaded got there without a Load call.
type LibraryError ¶
type LibraryError struct {
Library string
Env string
Path string
Attempts []LibraryAttempt
Hint string
}
LibraryError reports that libcutensornet could not be opened. Attempts lists every name tried in order. Path is set when an explicit path, from Load or CUTENSORNET_LIB_PATH, was requested and failed. Hint reports pkg-config discovery results and query failures, when discovery ran.
func (*LibraryError) Error ¶
func (e *LibraryError) Error() string
Error describes the library load attempts and their errors.
func (*LibraryError) Unwrap ¶
func (e *LibraryError) Unwrap() []error
Unwrap returns the error from each attempt.
type LoggerCallback ¶
type LoggerCallback uintptr
LoggerCallback represents cutensornetLoggerCallback_t.
type LoggerCallbackData ¶
type LoggerCallbackData uintptr
LoggerCallbackData represents cutensornetLoggerCallbackData_t.
type MemoryModel ¶
type MemoryModel int32
MemoryModel lists memory models used to determine workspace size.
const ( MemoryModelHeuristic MemoryModel = 0 MemoryModelCutensor MemoryModel = 1 )
func (MemoryModel) String ¶
func (e MemoryModel) String() string
String returns the constant name, or a numeric representation for unknown values.
type Memspace ¶
type Memspace int32
Memspace represents memory space enumeration for workspace allocation.
const ( MemspaceDevice Memspace = 0 // Device memory space. Workspace memory buffers allocated on this memory space must be device accessible. Memory buffers are device accessible if allocated natively on device (`cudaMalloc`), or on managed memory (`cudaMallocManaged`), or registered on host (`cudaMallocHost`, `cudaHostAlloc`, or `cudaHostRegister`), or a system memory with Full CUDA Unified Memory support. MemspaceHost Memspace = 1 // Host memory space. Workspace memory buffers allocated on this memory space must be CPU accessible. Memory buffers are CPU accessible if allocated natively on host (e.g. `malloc`), or on managed memory (`cudaMallocManaged`), or registered on host (`cudaMallocHost` or `cudaHostAlloc`). )
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
A Network is a validated tensor-network description together with the descriptor the library holds for it.
The mode, extent and stride slices handed to Handle.NewNetwork are borrowed for the duration of the call only; the library copies what it needs. The descriptor itself is heap-allocated inside the library and must be released with Close.
A Network is not safe for concurrent use.
func (*Network) Close ¶
Close releases the network descriptor.
It reports ErrNetworkInUse and releases nothing while a Plan built from n is still live, because the library reads the descriptor during contraction. Close is idempotent once it has succeeded.
cuTensorNet 2.13 renamed the destructor for this handle from cutensornetDestroyNetworkDescriptor to cutensornetDestroyNetwork, deprecating the former. Close calls the current name and falls back to the deprecated one when the loaded library is old enough not to export it, so the descriptor is released either way rather than leaked.
func (*Network) Descriptor ¶
func (n *Network) Descriptor() NetworkDescriptor
Descriptor returns the raw descriptor, for the generated calls that this package does not wrap. The descriptor is owned by n and is invalid after Network.Close.
func (*Network) Int32 ¶
func (n *Network) Int32(attr NetworkAttributes) (int32, error)
Int32 returns an int32-valued or enum-valued network attribute.
type NetworkAttributes ¶
type NetworkAttributes int32
NetworkAttributes lists all attributes of a NetworkDescriptor that are accessible.
const ( NetworkInputTensorsNumConstant NetworkAttributes = 0 // int32_t: The number of input tensors that are constant (get-only). NetworkInputTensorsConstant NetworkAttributes = 1 // [TensorIDList]: Structure holding number of, and indices of input tensors that are constant. Setting this attribute will override previous setting of `[NetworkInputTensorsConstant]`. NetworkInputTensorsNumConjugated NetworkAttributes = 10 // int32_t: The number of input tensors that are conjugated (get-only). NetworkInputTensorsConjugated NetworkAttributes = 11 // [TensorIDList]: Structure holding number of, and indices of input tensors that are conjugated. Setting number of conjugated tesnors to -1 will select all tensors. Setting this attribute will override previous setting of `[NetworkInputTensorsConjugated]`. NetworkInputTensorsNumRequireGrad NetworkAttributes = 20 // int32_t: The number of input tensors that require gradient computation (get-only). NetworkInputTensorsRequireGrad NetworkAttributes = 21 // [TensorIDList]: Structure holding number of, and indices of input tensors that require gradient computation. Setting number of tensors requiring gradient computation to -1 will select all tensors. Setting this attribute will override previous setting of `[NetworkInputTensorsRequireGrad]`. NetworkComputeType NetworkAttributes = 30 // [ComputeType]: Set compute type. )
func (NetworkAttributes) String ¶
func (e NetworkAttributes) String() string
String returns the constant name, or a numeric representation for unknown values.
type NetworkAutotunePreference ¶
type NetworkAutotunePreference uintptr
NetworkAutotunePreference is an opaque handle for cutensornetNetworkAutotunePreference_t.
func (NetworkAutotunePreference) Attribute ¶
func (n NetworkAutotunePreference) Attribute(handle Handle, attr NetworkAutotunePreferenceAttributes, buffer unsafe.Pointer, sizeInBytes uint) error
Attribute wraps cutensornetNetworkAutotunePreferenceGetAttribute.
func (*NetworkAutotunePreference) Close ¶
func (n *NetworkAutotunePreference) Close() error
Close wraps cutensornetDestroyNetworkAutotunePreference.
If n is zero, Close returns nil. Otherwise Close sets n to zero when the call succeeds and leaves it unchanged when it fails. Only n is zeroed: a copy of it still refers to the released object.
func (NetworkAutotunePreference) Int32 ¶
func (n NetworkAutotunePreference) Int32(handle Handle, attr NetworkAutotunePreferenceAttributes) (int32, error)
Int32 returns an int32-valued network autotune preference attribute.
func (NetworkAutotunePreference) SetAttribute ¶
func (n NetworkAutotunePreference) SetAttribute(handle Handle, attr NetworkAutotunePreferenceAttributes, buf unsafe.Pointer, sizeInBytes uint) error
SetAttribute wraps cutensornetNetworkAutotunePreferenceSetAttribute.
func (NetworkAutotunePreference) SetInt32 ¶
func (n NetworkAutotunePreference) SetInt32(handle Handle, attr NetworkAutotunePreferenceAttributes, v int32) error
SetInt32 sets an int32-valued network autotune preference attribute.
type NetworkAutotunePreferenceAttributes ¶
type NetworkAutotunePreferenceAttributes int32
NetworkAutotunePreferenceAttributes lists all attributes of a NetworkAutotunePreference that are accessible.
const ( NetworkAutotuneMaxIterations NetworkAutotunePreferenceAttributes = 0 // int32_t: Maximal number of auto-tune iterations for each pairwise contraction (default: 3). NetworkAutotuneIntermediateModes NetworkAutotunePreferenceAttributes = 1 // int32_t: 0=OFF, 1=ON, 2=AUTO (default). If set to 1, [Handle.NetworkAutotuneContraction] auto-tunes the intermediate mode order by executing one slice of the network a few times in order to determine how to achieve the best performance with cuTENSOR. If set to 2, heuristically chooses whether to auto-tune the intermediate mode order based upon network characteristics. )
func (NetworkAutotunePreferenceAttributes) String ¶
func (e NetworkAutotunePreferenceAttributes) String() string
String returns the constant name, or a numeric representation for unknown values.
type NetworkDescriptor ¶
type NetworkDescriptor uintptr
NetworkDescriptor is an opaque handle for cutensornetNetworkDescriptor_t.
func (NetworkDescriptor) Destroy ¶
func (n NetworkDescriptor) Destroy() error
Destroy wraps cutensornetDestroyNetwork.
It is not named Close because NetworkDescriptor has another release method, DestroyDescriptor.
func (NetworkDescriptor) DestroyDescriptor
deprecated
func (n NetworkDescriptor) DestroyDescriptor() error
DestroyDescriptor wraps cutensornetDestroyNetworkDescriptor.
It is not named Close because NetworkDescriptor has another release method, Destroy.
Deprecated: Use NetworkDescriptor.Destroy instead.
type NetworkOperator ¶
type NetworkOperator uintptr
NetworkOperator represents cutensornetNetworkOperator_t.
type OptimizerCost ¶
type OptimizerCost int32
OptimizerCost lists various cost functions to optimize with.
const ( OptimizerCostFlops OptimizerCost = 0 // Conventional flops (default) OptimizerCostTime OptimizerCost = 1 // Time estimation based on arithmetic intensity (experimental). It is only available for Volta and later architectures. )
func (OptimizerCost) String ¶
func (e OptimizerCost) String() string
String returns the constant name, or a numeric representation for unknown values.
type Plan ¶
type Plan struct {
// contains filtered or unexported fields
}
A Plan is a contraction plan bound to the network and workspace it was built from.
The library reads the network descriptor and the workspace buffers during every contraction the plan performs, so a Plan keeps both alive: closing either while a plan is live reports an error rather than freeing memory the library still holds.
A Plan is not safe for concurrent use.
func (*Plan) Autotune ¶
func (p *Plan) Autotune(in []uintptr, out uintptr, pref ContractionAutotunePreference, stream driver.Stream) error
Autotune runs the contraction repeatedly on stream to pick the fastest algorithm for each pairwise contraction, and records the choice in the plan.
It writes to out and to the workspace exactly as Plan.Contract does, and is asynchronous in the same way. Pass a zero ContractionAutotunePreference to use the library defaults.
func (*Plan) Close ¶
Close destroys the plan and releases its claim on the workspace and the network, which may then be closed.
Close does not synchronize the stream. Work enqueued by Plan.Contract may still be reading the workspace; the caller must synchronize before releasing any of it. Close is idempotent.
func (*Plan) Contract ¶
func (p *Plan) Contract(in []uintptr, out uintptr, accumulate bool, slices SliceGroup, stream driver.Stream) error
Contract executes the contraction on stream.
in holds one device address per input operand, in the order the operands were given to Handle.NewNetwork; out is the device address of the output operand. When accumulate is true the result is added to whatever out already holds, otherwise out is overwritten.
slices selects which slices of the contraction to execute. Pass a zero SliceGroup to execute all of them.
Contract is asynchronous with respect to the host: it enqueues work on stream and returns. Every buffer named here, and every workspace buffer, must stay valid and unmodified until that work completes. Nothing in this package synchronizes the stream for you.
All the buffers must be accessible from the device that is current on the calling thread, and that must be the same device the Handle was created on.
func (*Plan) Plan ¶
func (p *Plan) Plan() ContractionPlan
Plan returns the raw plan handle, for the generated calls that this package does not wrap. It is owned by p and is invalid after Plan.Close.
type Result ¶
type Result int32
Result represents a cutensornet API error code (cutensornetStatus_t).
When the library is loaded, Result.Error returns rich messages from GetErrorString. When the library is not loaded, it falls back to the numeric error code and Go-defined name.
const ( Success Result = 0 ErrNotInitialized Result = 1 ErrAllocFailed Result = 3 ErrInvalidValue Result = 7 ErrArchMismatch Result = 8 ErrMappingError Result = 11 ErrExecutionFailed Result = 13 ErrInternalError Result = 14 ErrNotSupported Result = 15 ErrLicenseError Result = 16 ErrCublasError Result = 17 ErrCudaError Result = 18 ErrInsufficientWorkspace Result = 19 ErrInsufficientDriver Result = 20 ErrIoError Result = 21 ErrCutensorVersionMismatch Result = 22 ErrNoDeviceAllocator Result = 23 ErrAllHyperSamplesFailed Result = 24 ErrCusolverError Result = 25 ErrDeviceAllocatorError Result = 26 ErrDistributedFailure Result = 27 ErrInterrupted Result = 28 )
cutensornet error codes from cutensornet.h.
type SliceGroup ¶
type SliceGroup uintptr
SliceGroup is an opaque handle for cutensornetSliceGroup_t.
func (*SliceGroup) Close ¶
func (s *SliceGroup) Close() error
Close wraps cutensornetDestroySliceGroup.
If s is zero, Close returns nil. Otherwise Close sets s to zero when the call succeeds and leaves it unchanged when it fails. Only s is zeroed: a copy of it still refers to the released object.
type SliceInfoPair ¶
SliceInfoPair represents a pair of int32_t and int64_t values holding the sliced Mode and intended extent size of mode.
type SlicingConfig ¶
SlicingConfig holds information about slicing.
type SmartOption ¶
type SmartOption int32
SmartOption lists various smart optimization options.
const ( SmartOptionDisabled SmartOption = 0 // No smart options are enabled SmartOptionEnabled SmartOption = 1 // Automatic configuration (SMART) options of the contractionOptimizer are enabled (default behavior). This include but not limited to limit the pathfinder elapsed time and to avoid meaningless configuration as well as adjusting configuration on the fly. )
func (SmartOption) String ¶
func (e SmartOption) String() string
String returns the constant name, or a numeric representation for unknown values.
type StateAccessor ¶
type StateAccessor uintptr
StateAccessor represents cutensornetStateAccessor_t.
type StateExpectation ¶
type StateExpectation uintptr
StateExpectation represents cutensornetStateExpectation_t.
type StateMarginal ¶
type StateMarginal uintptr
StateMarginal represents cutensornetStateMarginal_t.
type StateProjectionMPS ¶
type StateProjectionMPS uintptr
StateProjectionMPS represents cutensornetStateProjectionMPS_t.
type SymbolError ¶
SymbolError reports that a symbol is not callable.
Err distinguishes the two ways that happens. A nil Err means the loaded library does not export the symbol, which is what an installation older than the symbol looks like. A non-nil Err means the library does export it and the binding itself failed; the library is not at fault.
func (*SymbolError) Error ¶
func (e *SymbolError) Error() string
Error reports the uncallable library symbol and, when the symbol was present but could not be bound, why.
func (*SymbolError) Unwrap ¶
func (e *SymbolError) Unwrap() error
Unwrap returns the reason the symbol could not be bound, or nil when the loaded library does not export it.
type Tensor ¶
type Tensor struct {
Modes []int32
Extents []int64
Strides []int64
Qualifiers TensorQualifiers
}
A Tensor describes one operand of a tensor network.
Modes carries one integer label per dimension. Two dimensions carry the same label exactly when they are the same index: a label shared between two input tensors is contracted, a label that also appears in the output tensor is kept. Extents carries the size of each dimension and must be the same length as Modes.
Strides is optional and, when present, must be the same length as Modes. It gives the distance in elements — not bytes — between logically neighbouring elements along each dimension. A nil Strides means the library derives generalized column-major (Fortran) strides from Extents. cuTensorNet operands are strided, not packed: a row-major operand must state its strides explicitly, and so must any operand that is a view into a larger allocation.
type TensorDescriptor ¶
type TensorDescriptor uintptr
TensorDescriptor is an opaque handle for cutensornetTensorDescriptor_t.
func (*TensorDescriptor) Close ¶
func (t *TensorDescriptor) Close() error
Close wraps cutensornetDestroyTensorDescriptor.
If t is zero, Close returns nil. Otherwise Close sets t to zero when the call succeeds and leaves it unchanged when it fails. Only t is zeroed: a copy of it still refers to the released object.
type TensorIDList ¶
TensorIDList holds a list of input tensor IDs.
type TensorQualifiers ¶
TensorQualifiers holds qualifiers/flags about the input tensors.
type TensorSVDConfig ¶
type TensorSVDConfig uintptr
TensorSVDConfig represents cutensornetTensorSVDConfig_t.
type TensorSVDInfo ¶
type TensorSVDInfo uintptr
TensorSVDInfo represents cutensornetTensorSVDInfo_t.
type WorksizePref ¶
type WorksizePref int32
WorksizePref represents workspace preference enumeration.
const ( WorksizePrefMin WorksizePref = 0 // At least one algorithm will be available for each contraction WorksizePrefRecommended WorksizePref = 1 // The most suitable algorithm will be available for each contraction WorksizePrefMax WorksizePref = 2 // All algorithms will be available for each contraction )
func (WorksizePref) String ¶
func (e WorksizePref) String() string
String returns the constant name, or a numeric representation for unknown values.
type Workspace ¶
type Workspace struct {
// contains filtered or unexported fields
}
A Workspace owns the scratch and cache memory cuTensorNet uses while planning, autotuning and contracting a network.
The library's protocol is: create a workspace descriptor, ask it how large a buffer of a given memory space and kind must be, allocate that buffer, and hand the address back through the descriptor. From that point the library holds the address. It reads and writes the buffer during planning and during every contraction that uses the descriptor, so freeing the buffer before the last such call has completed on the stream is a use-after-free that this package cannot detect for you at the moment it happens.
Workspace makes the ordering explicit instead. The deallocator handed to Workspace.Provide is not run until Workspace.Close, and Close refuses while any Plan created from the workspace is still live. Stream ordering is still the caller's problem: Close only proves that no Go-side plan remains, not that the device has finished with the buffer. Synchronize the stream before calling it.
This package never allocates device memory. Pair it with a CUDA allocator such as github.com/tmc/lib/nvidia/driver.
A Workspace is not safe for concurrent use.
Example ¶
ExampleWorkspace shows the workspace protocol: find a contraction path, ask how much scratch memory it needs, allocate that much, hand it over, and let the cutensornet.Workspace decide when it may be released.
alloc and free stand in for a CUDA device allocator, such as MemAlloc and DevicePtr.MemFree in github.com/tmc/lib/nvidia/driver. Nothing in the cutensornet package allocates device memory.
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/cutensornet"
)
func main() {
var (
alloc = func(n int64) (uintptr, error) { return 0, fmt.Errorf("no allocator in this example") }
free = func(uintptr) {}
)
h, err := cutensornet.Create()
if err != nil {
fmt.Println("cuTensorNet unavailable:", err)
return
}
defer h.Close()
inputs := []cutensornet.Tensor{
{Modes: []int32{'m', 'k'}, Extents: []int64{64, 32}},
{Modes: []int32{'k', 'n'}, Extents: []int64{32, 48}},
}
net, err := h.NewNetwork(inputs, nil, cutensornet.R32F, cutensornet.Compute32F)
if err != nil {
fmt.Println("describe network:", err)
return
}
defer net.Close()
cfg, err := h.CreateContractionOptimizerConfig()
if err != nil {
fmt.Println("optimizer config:", err)
return
}
defer cfg.Close()
info, err := h.CreateContractionOptimizerInfo(net.Descriptor())
if err != nil {
fmt.Println("optimizer info:", err)
return
}
defer info.Close()
if err := h.ContractionOptimize(net.Descriptor(), cfg, 64<<20, info); err != nil {
fmt.Println("find contraction path:", err)
return
}
ws, err := h.NewWorkspace()
if err != nil {
fmt.Println("workspace:", err)
return
}
if err := ws.ComputeContractionSizes(net, info); err != nil {
fmt.Println("size workspace:", err)
return
}
size, err := ws.Size(cutensornet.WorksizePrefRecommended, cutensornet.MemspaceDevice, cutensornet.WorkspaceScratch)
if err != nil {
fmt.Println("workspace size:", err)
return
}
buf, err := alloc(size)
if err != nil {
fmt.Println("allocate workspace:", err)
return
}
// The deallocator is handed to the workspace, not deferred here: the
// library holds the buffer until Close, which refuses while a plan is live.
if err := ws.Provide(cutensornet.MemspaceDevice, cutensornet.WorkspaceScratch,
buf, size, func() { free(buf) }); err != nil {
free(buf)
fmt.Println("provide workspace:", err)
return
}
defer ws.Close()
fmt.Printf("workspace of %d bytes provided\n", size)
}
Output:
func (*Workspace) Close ¶
Close destroys the workspace descriptor and then runs the deallocators registered with Workspace.Provide, in reverse order.
It reports ErrWorkspaceInUse and releases nothing while a Plan created from w is still live. Close does not synchronize any stream: the caller must have done that, or the deallocators race with device work still reading the buffers. Close is idempotent once it has succeeded.
func (*Workspace) ComputeContractionSizes ¶
func (w *Workspace) ComputeContractionSizes(net *Network, info ContractionOptimizerInfo) error
ComputeContractionSizes records in the workspace descriptor the scratch and cache sizes needed to contract net along the path in info. Call it before Workspace.Size; the size query reports what was last computed, not what a particular plan will need.
func (*Workspace) Descriptor ¶
func (w *Workspace) Descriptor() WorkspaceDescriptor
Descriptor returns the raw descriptor, for the generated calls that this package does not wrap. The descriptor is owned by w and is invalid after Workspace.Close.
func (*Workspace) NewPlan ¶
func (w *Workspace) NewPlan(net *Network, info ContractionOptimizerInfo) (*Plan, error)
NewPlan builds a contraction plan for net along the path in info, sized against the buffers already provided to w.
Call Workspace.ComputeContractionSizes and Workspace.Provide first: the plan is validated against the workspace as it stands at this moment, and the library holds those buffers from here until Plan.Close.
The returned Plan must be released with Plan.Close, before the workspace or the network.
func (*Workspace) Provide ¶
func (w *Workspace) Provide(space Memspace, kind WorkspaceKind, ptr uintptr, size int64, free func()) error
Provide hands a caller-allocated buffer of size bytes at address ptr to the workspace for the given memory space and kind, and takes over the decision of when it may be released.
free, if non-nil, is called by Workspace.Close after the descriptor has been destroyed, in reverse order of the Provide calls. Passing nil leaves the buffer entirely to the caller, who then must not release it until after Close returns and the stream has been synchronized.
The buffer must live in the memory space named by space: device-accessible memory for MemspaceDevice, host-accessible memory for MemspaceHost. This package cannot check that. It must also stay unmodified by anything other than the library for as long as the workspace holds it; a WorkspaceCache buffer additionally must survive unmodified across the iterations that reuse it.
A ptr of 0 with size > 0 asks the library to draw the buffer from its own memory pool instead; free must then be nil, since there is nothing for the caller to release. A ptr of 0 with size 0 disables the workspace of that kind.
func (*Workspace) PurgeCache ¶
PurgeCache invalidates the cached data in the WorkspaceCache buffer for the given memory space. It does not release the buffer or return it to a pool.
func (*Workspace) Size ¶
func (w *Workspace) Size(pref WorksizePref, space Memspace, kind WorkspaceKind) (int64, error)
Size returns the workspace size in bytes that the last Workspace.ComputeContractionSizes recorded for the given preference, memory space and kind.
WorksizePrefMin is the smallest buffer for which some algorithm is available for every pairwise contraction; WorksizePrefRecommended is the size at which the most suitable algorithm is available. Providing less than the Min size for WorkspaceScratch is rejected by the library when the workspace is used. WorkspaceCache accepts any size, including zero, which disables it.
type WorkspaceDescriptor ¶
type WorkspaceDescriptor uintptr
WorkspaceDescriptor is an opaque handle for cutensornetWorkspaceDescriptor_t.
func (*WorkspaceDescriptor) Close ¶
func (w *WorkspaceDescriptor) Close() error
Close wraps cutensornetDestroyWorkspaceDescriptor.
If w is zero, Close returns nil. Otherwise Close sets w to zero when the call succeeds and leaves it unchanged when it fails. Only w is zeroed: a copy of it still refers to the released object.
type WorkspaceKind ¶
type WorkspaceKind int32
WorkspaceKind is a type enumeration for workspace allocation.
const ( WorkspaceScratch WorkspaceKind = 0 // Scratch workspace memory. WorkspaceCache WorkspaceKind = 1 // Cache workspace memory, must be maintained valid and contents not modified until referencing operation iterations are completed. )
func (WorkspaceKind) String ¶
func (e WorkspaceKind) String() string
String returns the constant name, or a numeric representation for unknown values.
Source Files
¶
- attrs.go
- contraction_autotune_preference.gen.go
- contraction_optimizer_config.gen.go
- contraction_optimizer_info.gen.go
- contraction_plan.gen.go
- doc.gen.go
- enums.gen.go
- funcs.gen.go
- handle.gen.go
- handles.gen.go
- init.gen.go
- loader_unix.gen.go
- network.go
- network_autotune_preference.gen.go
- network_descriptor.gen.go
- provenance.gen.go
- result.gen.go
- slice_group.gen.go
- structs.gen.go
- tensor_descriptor.gen.go
- types.gen.go
- workspace.go
- workspace_descriptor.gen.go