ditto
auto x = tensor!([2, 2])([1.0f, 2.0f, 3.0f, 4.0f]); auto x1 = onesLike(x); assert(x.shape == x1.shape); assert(x1.value == ones!(float, [2, 2]).value);
ditto
auto x = tensor!([2, 3])([1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f]); auto x1 = onesLike(x); assert(x.shape == x1.shape); assert(x1.value == ones!(float, [2, 3]).value);
ditto
auto x = tensor!([2, 3])([1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f]); auto x1 = onesLike!(UseGradient.yes)(x); static assert(canBackward!(typeof(x1)));