cudnn

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cudnn provides an optional Pure-Go (CGO_ENABLED=0) binding to NVIDIA's cuDNN shared library (libcudnn.so.9 / libcudnn.so.8 / cudnn64_9.dll) loaded dynamically via internal/dynlib.

If cuDNN is not installed on the system, Load returns ErrUnavailable and the CUDA backend seamlessly falls back to its built-in im2col + cuBLASLt / PTX convolution kernels.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("cuDNN library unavailable")

ErrUnavailable is returned when libcudnn cannot be located or loaded.

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API holds dynamically bound cuDNN function pointers.

func Load

func Load() (*API, error)

Load lazily opens libcudnn and binds the 2D convolution symbols.

func (*API) Create

func (a *API) Create() (Handle, error)

func (*API) CreateConv2DPlan

func (a *API) CreateConv2DPlan(h Handle, key Conv2DPlanKey, maxWorkspaceBytes uintptr) (*Conv2DPlan, error)

CreateConv2DPlan constructs descriptors and selects the fastest heuristic algorithm fitting within maxWorkspaceBytes.

func (*API) Destroy

func (a *API) Destroy(h Handle) error

func (*API) DestroyConv2DPlan

func (a *API) DestroyConv2DPlan(p *Conv2DPlan)

DestroyConv2DPlan frees all descriptors owned by plan.

func (*API) ExecuteConv2DPlan

func (a *API) ExecuteConv2DPlan(
	h Handle,
	p *Conv2DPlan,
	xPtr, wPtr, biasPtr, yPtr driver.DevicePtr,
	ws driver.DevicePtr,
	wsBytes uintptr,
) error

ExecuteConv2DPlan launches the cached convolution plan on the handle's bound stream. For Conv2DBwdFilter, yPtr is dy and wPtr is the output dw buffer (in OHWI layout).

func (*API) SetStream

func (a *API) SetStream(h Handle, stream driver.Stream) error

type ActivationDesc

type ActivationDesc uintptr

Opaque cuDNN handles and descriptors.

type ActivationMode

type ActivationMode int32

ActivationMode represents cudnnActivationMode_t.

const (
	ActivationRelu     ActivationMode = 1
	ActivationIdentity ActivationMode = 5
)

type Conv2DKind

type Conv2DKind uint8

Conv2DKind selects the cuDNN convolution operation for a cached Conv2DPlan.

const (
	Conv2DFwd Conv2DKind = iota
	Conv2DFwdBiasAct
	Conv2DBwdFilter
)

type Conv2DPlan

type Conv2DPlan struct {
	Key Conv2DPlanKey
	// contains filtered or unexported fields
}

Conv2DPlan caches pre-created cuDNN descriptors and the selected algorithm for zero-allocation steady-state execution and CUDA Graph capture.

type Conv2DPlanKey

type Conv2DPlanKey struct {
	Kind        Conv2DKind
	DataType    DataType
	ComputeType DataType
	MathType    MathType
	ActMode     ActivationMode
	B           int32
	InH, InW    int32
	CIn         int32
	OutH, OutW  int32
	COut        int32
	KH, KW      int32
	PadH, PadW  int32
	StrideH     int32
	StrideW     int32
	DilH, DilW  int32
}

Conv2DPlanKey uniquely identifies a cached cuDNN 2D NHWC convolution plan.

type ConvAlgoPerf

type ConvAlgoPerf struct {
	Algo        int32
	Status      Status
	Time        float32
	Memory      uintptr
	Determinism int32
	MathType    MathType
	Reserved    [3]int32
}

ConvAlgoPerf matches cudnnConvolutionFwdAlgoPerf_t and cudnnConvolutionBwdFilterAlgoPerf_t (identical C ABI layout on 64-bit platforms: 48 bytes).

type ConvBwdFilterAlgo

type ConvBwdFilterAlgo int32

ConvBwdFilterAlgo represents cudnnConvolutionBwdFilterAlgo_t.

type ConvDesc

type ConvDesc uintptr

Opaque cuDNN handles and descriptors.

type ConvFwdAlgo

type ConvFwdAlgo int32

ConvFwdAlgo represents cudnnConvolutionFwdAlgo_t.

const (
	ConvFwdAlgoImplicitGemm        ConvFwdAlgo = 0
	ConvFwdAlgoImplicitPrecompGemm ConvFwdAlgo = 1
)

type ConvMode

type ConvMode int32

ConvMode represents cudnnConvolutionMode_t.

const (
	ConvConvolution      ConvMode = 0
	ConvCrossCorrelation ConvMode = 1
)

type DataType

type DataType int32

DataType represents cudnnDataType_t.

const (
	DataFloat    DataType = 0
	DataDouble   DataType = 1
	DataHalf     DataType = 2
	DataBFloat16 DataType = 9
)

type FilterDesc

type FilterDesc uintptr

Opaque cuDNN handles and descriptors.

type Handle

type Handle uintptr

Opaque cuDNN handles and descriptors.

type MathType

type MathType int32

MathType represents cudnnMathType_t.

const (
	MathDefault                 MathType = 0
	MathTensorOp                MathType = 1
	MathTensorOpAllowConversion MathType = 2
	MathFMA                     MathType = 3
)

type NanPropagation

type NanPropagation int32

NanPropagation represents cudnnNanPropagation_t.

const (
	NotPropagateNan NanPropagation = 0
	PropagateNan    NanPropagation = 1
)

type Status

type Status int32

Status represents cudnnStatus_t.

const StatusSuccess Status = 0

type TensorDesc

type TensorDesc uintptr

Opaque cuDNN handles and descriptors.

type TensorFormat

type TensorFormat int32

TensorFormat represents cudnnTensorFormat_t.

const (
	TensorNCHW TensorFormat = 0
	TensorNHWC TensorFormat = 1
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL