def vjp_matmul_nt

bendtorch-core@0.1.0.0 · src/autograd/tensor_backward.bend:437

import bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend as TensorBackward
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core

437# d(x @ W^T)/dx: g @ W; d(x @ W^T)/dW: g^T @ x, with the operand values
438# saved at record time. Neither product builds a transpose: g @ W is
439# `matmul`, and g^T @ x is `matmul_tn`, which reads g in place. Each product
440# already has its operand's shape.
441def vjp_matmul_nt(+a: Nat, +b: Nat, +left: Shape.Shape, +right: Shape.Shape, saved: Saved, g: Core.Dynamic) -> Pass:
442  match saved:
443    case Unsaved{}:
444      Pass{Unsaved{}, g, Fail{TensorError{Core.StorageLengthMismatch{}}}}
445    case Operands{x, y}:
446      nt_first(a, b, left, right, x, y, Core.clone_dynamic(g))

Uses (10)

Used by (4)