variable

a helper function to create variable object from CPU/CUDA array

  1. auto variable(Sl sl, bool requiresGrad)
  2. auto variable(T x)
  3. auto variable(A a, bool requiresGrad)
    variable
    (
    A
    )
    (
    A a
    ,
    bool requiresGrad = false
    )
    if (
    isArray!A
    )

Examples

auto h = 0.5f.variable;
auto d = h.to!DeviceStorage;
assert(d.to!HostStorage.data == h.data);

Meta