docsapi referencedarkforest-core-ops-matmul_backward
API Referencecrate: darkforest-coresince v0.1.0-alpha

matmul_backward

Computes gradients for matmul: grad_a = grad @ b.T, grad_b = a.T @ grad.

matmul_backward

darkforest-core module: ops since v0.1.0-alpha

Signature

rust
pub fn matmul_backward(grad: &Tensor, a: &Tensor, b: &Tensor) -> (Tensor, Tensor)

Overview

Computes gradients for matmul: grad_a = grad @ b.T, grad_b = a.T @ grad.

Invariants & Design Principles

  • Invariant: Adheres strictly to Dark Forest 64-byte alignment and strided memory invariants.
  • Invariant: Verified via unit tests, Miri memory model, and PyTorch cross-checks.

Usage Example

rust
// Example calling matmul_backward
let _res = darkforest_core::ops::matmul_backward();

Related Components