Documentation
¶
Overview ¶
Package capi provides CGO bindings to the lux-accel C library.
Library resolution order:
- System paths (/usr/local/lib, /usr/lib)
- Homebrew paths (/opt/homebrew/lib)
- Local luxcpp install (../../../luxcpp/install/lib)
Install the library using one of:
- make install-system (from lux/accel)
- make build-deps && make install-system (build from luxcpp source)
- scripts/fetch-luxcpp.sh accel (download pre-built)
Package capi stub implementations. When the real libluxaccel is not installed, these weak-symbol C functions provide default implementations that return LUX_NO_BACKEND. When libluxaccel IS installed and linked (via CGO_LDFLAGS=-lluxaccel), the strong symbols from the real library override these.
Index ¶
- Variables
- func Attention(session *Session, q, k, v, output *Tensor, scale float32) error
- func BFVAdd(session *Session, ct1, ct2, result *Tensor) error
- func BFVDecrypt(session *Session, ciphertext, sk, plaintext *Tensor) error
- func BFVEncrypt(session *Session, plaintext, pk, ciphertext *Tensor) error
- func BFVMultiply(session *Session, ct1, ct2, relinKey, result *Tensor) error
- func BLSVerifyBatch(session *Session, messages, signatures, pubkeys, results *Tensor) error
- func BackendCount() int
- func BackendTypeAt(index int) int
- func ComputeTWAP(session *Session, prices, timestamps, twap *Tensor, start, end uint64) error
- func ConstantProductSwap(session *Session, reserveX, reserveY, amountIn, amountOut *Tensor, xToY bool, ...) error
- func DeviceCount(backend int) int
- func DilithiumSign(session *Session, msg, sk, sig *Tensor) error
- func DilithiumVerify(session *Session, msg, sig, pk *Tensor) (bool, error)
- func ECDSAVerifyBatch(session *Session, messages, signatures, pubkeys, results *Tensor) error
- func Ed25519VerifyBatch(session *Session, messages, signatures, pubkeys, results *Tensor) error
- func GELU(session *Session, input, output *Tensor) error
- func GetError() string
- func INTT(session *Session, input, output, invRoots *Tensor, modulus uint64) error
- func Init() error
- func Keccak256(session *Session, input, output *Tensor) error
- func KyberDecaps(session *Session, ct, sk, ss *Tensor) error
- func KyberEncaps(session *Session, pk, ct, ss *Tensor) error
- func KyberKeyGen(session *Session, pk, sk *Tensor) error
- func LayerNorm(session *Session, input, gamma, beta, output *Tensor, eps float32) error
- func LoadBackend(path string) error
- func MSM(session *Session, scalars, bases, result *Tensor) error
- func MatMul(session *Session, a, b, c *Tensor) error
- func MatchOrders(session *Session, bids, asks, matches, prices, amounts *Tensor) error
- func MerkleRoot(session *Session, leaves, root *Tensor) error
- func NTT(session *Session, input, output, roots *Tensor, modulus uint64) error
- func PolyMul(session *Session, a, b, c *Tensor, modulus uint64) error
- func Poseidon(session *Session, input, output *Tensor) error
- func ReLU(session *Session, input, output *Tensor) error
- func SHA256(session *Session, input, output *Tensor) error
- func Shutdown()
- func Softmax(session *Session, input, output *Tensor, axis int) error
- func Version() string
- type DeviceInfo
- type Session
- type Tensor
- func (t *Tensor) Bytes() int
- func (t *Tensor) DType() int
- func (t *Tensor) Destroy()
- func (t *Tensor) FromHost(src []byte) error
- func (t *Tensor) Handle() C.lux_tensor
- func (t *Tensor) HandlePtr() uintptr
- func (t *Tensor) NDim() int
- func (t *Tensor) NumEl() int
- func (t *Tensor) Shape(dim int) int
- func (t *Tensor) ToHost(dst []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrOutOfMemory = errors.New("out of memory") ErrInvalidArgument = errors.New("invalid argument") ErrNotSupported = errors.New("not supported") ErrNoBackends = errors.New("no backends") ErrKernelFailed = errors.New("kernel failed") )
Error types matching C library status codes.
Functions ¶
func BFVDecrypt ¶
BFVDecrypt decrypts BFV.
func BFVEncrypt ¶
BFVEncrypt encrypts with BFV.
func BFVMultiply ¶
BFVMultiply multiplies BFV ciphertexts.
func BLSVerifyBatch ¶
BLSVerifyBatch verifies BLS signatures.
func BackendTypeAt ¶
BackendTypeAt returns the backend type at index.
func ComputeTWAP ¶
ComputeTWAP computes time-weighted average price.
func ConstantProductSwap ¶
func ConstantProductSwap(session *Session, reserveX, reserveY, amountIn, amountOut *Tensor, xToY bool, fee float32) error
ConstantProductSwap computes AMM swap.
func DeviceCount ¶
DeviceCount returns the number of devices for a backend.
func DilithiumSign ¶
DilithiumSign signs a message.
func DilithiumVerify ¶
DilithiumVerify verifies a signature.
func ECDSAVerifyBatch ¶
ECDSAVerifyBatch verifies ECDSA signatures.
func Ed25519VerifyBatch ¶
Ed25519VerifyBatch verifies Ed25519 signatures.
func KyberDecaps ¶
KyberDecaps decapsulates shared secret.
func KyberEncaps ¶
KyberEncaps encapsulates shared secret.
func KyberKeyGen ¶
KyberKeyGen generates Kyber key pair.
func LoadBackend ¶
LoadBackend loads a backend plugin from path.
func MatchOrders ¶
MatchOrders matches orders.
func MerkleRoot ¶
MerkleRoot computes Merkle root.
Types ¶
type DeviceInfo ¶
type DeviceInfo struct {
Name string
Vendor string
Backend int
IsDiscrete bool
IsUnifiedMemory bool
TotalMemory uint64
MaxWorkgroupSize uint32
SIMDWidth uint32
}
DeviceInfo contains device information.
func GetDeviceInfo ¶
func GetDeviceInfo(backend, index int) (*DeviceInfo, error)
GetDeviceInfo retrieves device information.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session wraps a C session handle.
func CreateSessionWithBackend ¶
CreateSessionWithBackend creates a session with specific backend.
func CreateSessionWithDevice ¶
CreateSessionWithDevice creates a session with specific device.
type Tensor ¶
type Tensor struct {
// contains filtered or unexported fields
}
Tensor wraps a C tensor handle.
func CreateTensor ¶
CreateTensor creates a new tensor.
func CreateTensorWithData ¶
CreateTensorWithData creates a tensor with initial data.