def vjp_slice

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

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
import bendtorch-core@0.1.0.0/src/tensor/slice.bend as Slice

650# d(a slice of a)/da: g read with the kept shape, the slice's output with the
651# axis kept (PyTorch's unsqueeze for select), then scattered into +0.0 words
652# of a's shape (PyTorch's slice_backward): each input cell the slice read
653# gets the gradient word of the output cell it went to.
654def vjp_slice(+a: Nat, +input: Shape.Shape, +kept: Shape.Shape, +plan: Slice.Plan, g: Core.Dynamic) -> Pass:
655  Core.Packed{+shape, tensor} = g
656  slice_unsqueezed(a, input, kept, plan, shape, tensor, Shape.bool_case(Nat.is_eq(Shape.elements(shape), Shape.elements(kept))))

Uses (9)

Used by (1)