import std.stdio; { // Variable!(float, 1) x; auto x = [-1f, -2f, -3f].variable; auto y = x.dup; x.data[0] = 1.0; static assert(isVariable!(typeof(x))); static assert(!isVariable!void); static assert(isHost!(typeof(x))); assert(y.data[0] == -1); } version (grain_cuda) { { auto x = [[1f, 3f], [5f, 7f], [9f, 11f]].variable; assert(x.data.length == 6); static assert(!isHost!(typeof(x.to!DeviceStorage))); auto xx = x.dup; assert(x.to!DeviceStorage .to!HostStorage .sliced == x.sliced); } }
copy variable into the other device (e.g., CPU -> CUDA or CUDA -> CPU)