import grain.testing; import numir; import mir.ndslice; import std.meta; auto hx = [1f, 2f, 3f, 4f].sliced(2, 2).variable(true); auto loss = sum(hx); assert(loss.data[0] == 10f); loss.backward(); assert(hx.gradSlice == [1f, 1f, 1f, 1f].sliced(2, 2));
summation