type-erased version of backward function used in grain.autograd.BackProp object
store grain.autograd.BackProp object in returned variables from forward function
test NG functions
alias F1H = Variable!(float, 1, HostStorage); version (grain_cuda) alias F1D = Variable!(float, 1, HostStorage); struct A(DelayInstantiation) { mixin FunctionCommon; // mismatch of args F1H forward(F1H x) { return x; }; F1H backward(F1H x, F1H y) { return x; }; } static assert(!__traits(compiles, A!void)); version (grain_cuda) { struct B(DelayInstantiation) { mixin FunctionCommon; F1H forward(F1H x) { return x; }; F1H backward(F1H x) { return x; }; // mismatch of args in device version (grain_cuda) { F1D forward(F1D x) { return x; }; F1D backward(F1D x, F1D y) { return x; }; } } static assert(!__traits(compiles, B!void)); }
common components (typecheck and backprop wrappers) for autograd functions