grain.functions.common

Common components for autograd function object

Members

Functions

broadcast
auto broadcast(S1 a0, S2 b0)
broadcastable
auto broadcastable(Variable!(T, dim, Storage) a, Variable!(T, dim, Storage) b)

check if broadcastable

expand
auto expand(S s, size_t n)

expand dimension i.e. repeat n time on dim

maybeExpand
auto maybeExpand(S s, size_t n)

exapand dimension if s.length!dim == 1 else do nothing but type in the same expressions of repeat/unpack/swapped/index[0]

reduceShape
auto reduceShape(S s0, size_t[N] targetShape)

reduce slice into targetShape, TODO @nogc

Mixin templates

FunctionCommon
mixintemplate FunctionCommon()

common components (typecheck and backprop wrappers) for autograd functions

TypeChecker
mixintemplate TypeChecker(alias forward, alias backward)

a simple type check of forward/backward functions compatibility

Variables

isFunction
enum bool isFunction(T);

a trait to identify autograd functions

Meta