FunctionCommon

common components (typecheck and backprop wrappers) for autograd functions

Postblit

this(this)
this(this)
Undocumented in source.

Members

Aliases

DeviceArgs
alias DeviceArgs = Tuple!(Parameters!forward)
Undocumented in source.
DeviceRets
alias DeviceRets = Tuple!(Parameters!backward)
Undocumented in source.
HostArgs
alias HostArgs = Tuple!(Parameters!forward)
Undocumented in source.
HostRets
alias HostRets = Tuple!(Parameters!backward)
Undocumented in source.

Functions

applyBackward
void applyBackward(UntypedVariable[] ugradOutputs)

type-erased version of backward function used in grain.autograd.BackProp object

applyForward
auto applyForward(Args args)

store grain.autograd.BackProp object in returned variables from forward function

Mixins

__anonymous
mixin TypeChecker!(forward, backward)
Undocumented in source.
__anonymous
mixin TypeChecker!(forward, backward)
Undocumented in source.

Variables

_mixin_dargs
DeviceArgs _mixin_dargs;
Undocumented in source.
_mixin_hargs
HostArgs _mixin_hargs;
Undocumented in source.

Examples

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));
}

Meta