Documentation
¶
Index ¶
- Variables
- func ForceVariant(v Variant)
- func GEMM[TInput, TOutput dtypes.Supported](alpha, beta TOutput, lhsFlat, rhsFlat []TInput, ...) error
- func GEMMDynamic(inputDType, outputDType dtypes.DType, alpha, beta float64, ...) error
- func HasDTypeSupport(input, output dtypes.DType) bool
- func RegisterGEMM[TInput, TOutput dtypes.Supported](name string, ...)
- type BufAllocAnyFn
- type BufAllocFn
- type BufReleaseFn
- type CacheParams
- type DTypePair
- type GEMMRegistration
- type Priority
- type Variant
Constants ¶
This section is empty.
Variables ¶
var ( // DTypeToGEMM is a map of DType to GEMM function. // Used for registration, use the generic GEMM[TInput, TOutput] to actually call it. DTypeToGEMM = make(map[DTypePair][]GEMMRegistration, 100) )
var ( // NoSIMD32Params are generic assumptions for L1/L2/L3 cache sizes for 32 bits dtypes (float32, int32, uint32) // // These values are somewhat arbitrary, assuming "standard" modern cache sizes. // They are parameterized so they can be tuned or determined dynamically later. NoSIMD32Params = CacheParams{ LHSL1KernelRows: 2, RHSL1KernelCols: 4, PanelContractingSize: 512, LHSPanelCrossSize: 2, RHSPanelCrossSize: 512, } )
Functions ¶
func ForceVariant ¶
func ForceVariant(v Variant)
ForceVariant forces the use of the small/large variant. Used for testing only.
func GEMM ¶
func GEMM[TInput, TOutput dtypes.Supported](alpha, beta TOutput, lhsFlat, rhsFlat []TInput, batchSize, lhsCrossSize, rhsCrossSize, contractingSize int, outputFlat []TOutput, bufAllocFn BufAllocFn[TInput], bufReleaseFn BufReleaseFn, pool *workerspool.Pool) error
GEMM[TInput, TOutput dtypes.DType] implements the matrix multiplication for the given dtypes. It returns an error if a GEMM function is not registered for the given dtypes.
func GEMMDynamic ¶
func GEMMDynamic(inputDType, outputDType dtypes.DType, alpha, beta float64, lhsFlat, rhsFlat any, batchSize, lhsCrossSize, rhsCrossSize, contractingSize int, outputFlat any, bufAllocAnyFn BufAllocAnyFn, bufReleaseFn BufReleaseFn, pool *workerspool.Pool) error
GEMMDynamic dispatches the GEMM function for the given dtypes. It is a dynamic switch around GEMM[TInput, TOutput].
The lhsFlat, rhsFlat and outputFlat parameters must be slices of the corresponding DType. The buffAllocAnyFn must yield a slice of the configured input DType, but cast as "any".
func HasDTypeSupport ¶
HasDTypeSupport returns true if a GEMM function is registered for the given dtypes.
func RegisterGEMM ¶
func RegisterGEMM[TInput, TOutput dtypes.Supported]( name string, gemmFn func(alpha, beta TOutput, lhsFlat, rhsFlat []TInput, batchSize, lhsCrossSize, rhsCrossSize, contractingSize int, outputFlat []TOutput, bufAllocFn BufAllocFn[TInput], bufReleaseFn BufReleaseFn, pool *workerspool.Pool) error, params *CacheParams, priority Priority)
RegisterGEMM registers a GEMM function for the given dtypes with the given priority. If the priority is lower than the one already registered, it does nothing.
Types ¶
type BufAllocAnyFn ¶
BufAllocAnyFn is a function that allocates a buffer (a slice) of some pre-agreed type.
type BufAllocFn ¶
BufAllocFn is a function that allocates a buffer (a slice) of type T, of the given size.
type BufReleaseFn ¶
type BufReleaseFn func(ref any)
type CacheParams ¶
type CacheParams struct {
LHSL1KernelRows int // or Mr: number of lhs kernel rows going to registers.
RHSL1KernelCols int // or Nr: Register Block Width
PanelContractingSize int // Kc: LHS cols or RHS rows to fit in L2/L3
LHSPanelCrossSize int // Mc: L2 rows
RHSPanelCrossSize int // Nc: L3 cols
}
Block/packs parameters for current architecture.
type DTypePair ¶
DTypePair represents the input/output types.
func GetDTypePair ¶
GetDTypePair returns the DTypePair for the given types.
type GEMMRegistration ¶
type GEMMRegistration struct {
Name string
DTypePair DTypePair
GEMMFn any // Typed GEMM function
Priority Priority
Params *CacheParams
}
GEMMRegistration is a registration of a GEMM function for the given dtype pair.