variable

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

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

Examples

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

Meta