Documentation
¶
Overview ¶
Package miopen provides low-level bindings for the AMD MIOpen library using purego dlopen. No build tags required; use miopen.Available() to check runtime availability.
Index ¶
- func Available() bool
- type ActivationDescriptor
- type ActivationMode
- type BatchNormMode
- type ConvMode
- type ConvolutionDescriptor
- type DataType
- type Handle
- func (h *Handle) ActivationForward(actDesc *ActivationDescriptor, alpha float32, xDesc *TensorDescriptor, ...) error
- func (h *Handle) BatchNormalizationForwardInference(mode BatchNormMode, alpha, beta float32, xDesc *TensorDescriptor, ...) error
- func (h *Handle) ConvolutionForward(alpha float32, xDesc *TensorDescriptor, x unsafe.Pointer, ...) error
- func (h *Handle) ConvolutionForwardGetWorkspaceSize(xDesc *TensorDescriptor, wDesc *TensorDescriptor, ...) (int, error)
- func (h *Handle) Destroy() error
- func (h *Handle) FindConvolutionForwardAlgorithm(xDesc *TensorDescriptor, x unsafe.Pointer, wDesc *TensorDescriptor, ...) (uintptr, error)
- func (h *Handle) GetPoolingForwardOutputDim(poolDesc *PoolingDescriptor, xDesc *TensorDescriptor) (n, c, outH, outW int, err error)
- func (h *Handle) OpTensorAdd(alpha float32, bDesc *TensorDescriptor, b unsafe.Pointer, beta float32, ...) error
- func (h *Handle) PoolingForward(poolDesc *PoolingDescriptor, alpha float32, xDesc *TensorDescriptor, ...) error
- func (h *Handle) PoolingGetWorkSpaceSize(yDesc *TensorDescriptor) (int, error)
- func (h *Handle) SetStream(streamPtr unsafe.Pointer) error
- func (h *Handle) SoftmaxForward(algo SoftmaxAlgorithm, mode SoftmaxMode, alpha float32, ...) error
- type MIOpenLib
- type PoolingDescriptor
- type PoolingMode
- type SoftmaxAlgorithm
- type SoftmaxMode
- type TensorDescriptor
- type TensorLayout
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActivationDescriptor ¶
type ActivationDescriptor struct {
// contains filtered or unexported fields
}
ActivationDescriptor wraps miopenActivationDescriptor_t.
func CreateActivationDescriptor ¶
func CreateActivationDescriptor() (*ActivationDescriptor, error)
CreateActivationDescriptor creates a new activation descriptor.
func (*ActivationDescriptor) Destroy ¶
func (a *ActivationDescriptor) Destroy() error
Destroy releases the activation descriptor.
func (*ActivationDescriptor) Set ¶
func (a *ActivationDescriptor) Set(mode ActivationMode, alpha, beta, gamma float64) error
Set configures the activation descriptor.
type ActivationMode ¶
type ActivationMode int
ActivationMode mirrors miopenActivationMode_t.
const ( ActivationReLU ActivationMode = 3 // miopenActivationRELU ActivationSigmoid ActivationMode = 0 // miopenActivationLOGISTIC ActivationTanh ActivationMode = 2 // miopenActivationTANH ActivationELU ActivationMode = 6 // miopenActivationELU )
type BatchNormMode ¶
type BatchNormMode int
BatchNormMode mirrors miopenBatchNormMode_t.
const ( BatchNormPerActivation BatchNormMode = 0 // miopenBNPerActivation BatchNormSpatial BatchNormMode = 1 // miopenBNSpatial )
type ConvolutionDescriptor ¶
type ConvolutionDescriptor struct {
// contains filtered or unexported fields
}
ConvolutionDescriptor wraps miopenConvolutionDescriptor_t.
func CreateConvolutionDescriptor ¶
func CreateConvolutionDescriptor() (*ConvolutionDescriptor, error)
CreateConvolutionDescriptor creates a new convolution descriptor.
func (*ConvolutionDescriptor) Destroy ¶
func (c *ConvolutionDescriptor) Destroy() error
Destroy releases the convolution descriptor.
func (*ConvolutionDescriptor) Set2d ¶
func (c *ConvolutionDescriptor) Set2d(padH, padW, strH, strW, dilH, dilW int, mode ConvMode) error
Set2d configures a 2D convolution descriptor.
func (*ConvolutionDescriptor) SetGroupCount ¶
func (c *ConvolutionDescriptor) SetGroupCount(groups int) error
SetGroupCount sets the group count for grouped convolutions.
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle wraps a miopenHandle_t (opaque pointer).
func (*Handle) ActivationForward ¶
func (h *Handle) ActivationForward( actDesc *ActivationDescriptor, alpha float32, xDesc *TensorDescriptor, x unsafe.Pointer, beta float32, yDesc *TensorDescriptor, y unsafe.Pointer, ) error
ActivationForward applies an activation function.
func (*Handle) BatchNormalizationForwardInference ¶
func (h *Handle) BatchNormalizationForwardInference( mode BatchNormMode, alpha, beta float32, xDesc *TensorDescriptor, x unsafe.Pointer, yDesc *TensorDescriptor, y unsafe.Pointer, bnScaleBiasMeanVarDesc *TensorDescriptor, scale, bias, mean, variance unsafe.Pointer, epsilon float64, ) error
BatchNormalizationForwardInference performs batch normalization in inference mode.
func (*Handle) ConvolutionForward ¶
func (h *Handle) ConvolutionForward( alpha float32, xDesc *TensorDescriptor, x unsafe.Pointer, wDesc *TensorDescriptor, w unsafe.Pointer, convDesc *ConvolutionDescriptor, algo uintptr, workspace unsafe.Pointer, wsSize int, beta float32, yDesc *TensorDescriptor, y unsafe.Pointer, ) error
ConvolutionForward performs the forward convolution.
func (*Handle) ConvolutionForwardGetWorkspaceSize ¶
func (h *Handle) ConvolutionForwardGetWorkspaceSize( xDesc *TensorDescriptor, wDesc *TensorDescriptor, convDesc *ConvolutionDescriptor, yDesc *TensorDescriptor, ) (int, error)
ConvolutionForwardGetWorkspaceSize returns the workspace size in bytes.
func (*Handle) FindConvolutionForwardAlgorithm ¶
func (h *Handle) FindConvolutionForwardAlgorithm( xDesc *TensorDescriptor, x unsafe.Pointer, wDesc *TensorDescriptor, w unsafe.Pointer, convDesc *ConvolutionDescriptor, yDesc *TensorDescriptor, y unsafe.Pointer, workspace unsafe.Pointer, wsSize int, ) (uintptr, error)
FindConvolutionForwardAlgorithm finds the best convolution algorithm. Returns the algorithm enum value suitable for ConvolutionForward.
func (*Handle) GetPoolingForwardOutputDim ¶
func (h *Handle) GetPoolingForwardOutputDim( poolDesc *PoolingDescriptor, xDesc *TensorDescriptor, ) (n, c, outH, outW int, err error)
GetPoolingForwardOutputDim returns the output dimensions for a pooling operation.
func (*Handle) OpTensorAdd ¶
func (h *Handle) OpTensorAdd( alpha float32, bDesc *TensorDescriptor, b unsafe.Pointer, beta float32, yDesc *TensorDescriptor, y unsafe.Pointer, ) error
OpTensorAdd adds tensors: y = alpha * b + beta * y.
func (*Handle) PoolingForward ¶
func (h *Handle) PoolingForward( poolDesc *PoolingDescriptor, alpha float32, xDesc *TensorDescriptor, x unsafe.Pointer, beta float32, yDesc *TensorDescriptor, y unsafe.Pointer, workspaceIndex bool, workspace unsafe.Pointer, wsSize int, ) error
PoolingForward performs 2D pooling.
func (*Handle) PoolingGetWorkSpaceSize ¶
func (h *Handle) PoolingGetWorkSpaceSize(yDesc *TensorDescriptor) (int, error)
PoolingGetWorkSpaceSize returns the workspace size for pooling.
func (*Handle) SoftmaxForward ¶
func (h *Handle) SoftmaxForward( algo SoftmaxAlgorithm, mode SoftmaxMode, alpha float32, xDesc *TensorDescriptor, x unsafe.Pointer, beta float32, yDesc *TensorDescriptor, y unsafe.Pointer, ) error
SoftmaxForward computes softmax.
type MIOpenLib ¶
type MIOpenLib struct {
// contains filtered or unexported fields
}
MIOpenLib holds dlopen handles and resolved function pointers for MIOpen functions. All function pointers are resolved at Open() time via dlsym.
type PoolingDescriptor ¶
type PoolingDescriptor struct {
// contains filtered or unexported fields
}
PoolingDescriptor wraps miopenPoolingDescriptor_t.
func CreatePoolingDescriptor ¶
func CreatePoolingDescriptor() (*PoolingDescriptor, error)
CreatePoolingDescriptor creates a new pooling descriptor.
func (*PoolingDescriptor) Destroy ¶
func (p *PoolingDescriptor) Destroy() error
Destroy releases the pooling descriptor.
func (*PoolingDescriptor) Set2d ¶
func (p *PoolingDescriptor) Set2d(mode PoolingMode, windowH, windowW, padH, padW, strideH, strideW int) error
Set2d configures a 2D pooling descriptor.
type PoolingMode ¶
type PoolingMode int
PoolingMode mirrors miopenPoolingMode_t.
const ( PoolingMax PoolingMode = 0 // miopenPoolingMax PoolingAverageCountIncludePad PoolingMode = 1 // miopenPoolingAverageInclusive PoolingAverageCountExcludePad PoolingMode = 2 // miopenPoolingAverage )
type SoftmaxAlgorithm ¶
type SoftmaxAlgorithm int
SoftmaxAlgorithm selects the softmax computation variant.
const ( SoftmaxAccurate SoftmaxAlgorithm = 0 // MIOPEN_SOFTMAX_ACCURATE SoftmaxLog SoftmaxAlgorithm = 1 // MIOPEN_SOFTMAX_LOG SoftmaxFast SoftmaxAlgorithm = 2 // MIOPEN_SOFTMAX_FAST )
type SoftmaxMode ¶
type SoftmaxMode int
SoftmaxMode selects the dimension for softmax.
const ( SoftmaxModeChannel SoftmaxMode = 1 // MIOPEN_SOFTMAX_MODE_CHANNEL SoftmaxModeInstance SoftmaxMode = 0 // MIOPEN_SOFTMAX_MODE_INSTANCE )
type TensorDescriptor ¶
type TensorDescriptor struct {
// contains filtered or unexported fields
}
TensorDescriptor wraps miopenTensorDescriptor_t (opaque pointer).
func CreateTensorDescriptor ¶
func CreateTensorDescriptor() (*TensorDescriptor, error)
CreateTensorDescriptor creates a new tensor descriptor.
func (*TensorDescriptor) Destroy ¶
func (t *TensorDescriptor) Destroy() error
Destroy releases the tensor descriptor.
type TensorLayout ¶
type TensorLayout int
TensorLayout selects NCHW or NHWC.
const ( NCHW TensorLayout = 0 NHWC TensorLayout = 1 )