(t *testing.T)
| 18 | } |
| 19 | |
| 20 | func testReduceSumForward[T float.DType](t *testing.T) { |
| 21 | x := mat.NewDense[T](mat.WithBacking([]T{0.1, 0.2, 0.3, 0.0}), mat.WithGrad(true)) |
| 22 | |
| 23 | f := NewReduceSum(x) |
| 24 | assert.Equal(t, []mat.Tensor{x}, f.Operands()) |
| 25 | |
| 26 | y, err := f.Forward() |
| 27 | assert.Nil(t, err) |
| 28 | assert.InDeltaSlice(t, []T{0.6}, y.Data(), 1.0e-6) |
| 29 | |
| 30 | err = f.Backward(mat.NewDense[T](mat.WithBacking([]T{0.5}))) |
| 31 | assert.Nil(t, err) |
| 32 | assert.InDeltaSlice(t, []T{0.5, 0.5, 0.5, 0.5}, x.Grad().Data(), 1.0e-6) |
| 33 | } |
nothing calls this directly
no test coverage detected