'Accumulate the derivative w.r.t the outputs of this layer.
A layer needs to compute derivatives w.r.t its outputs. These outputs may
have been connected to lots of other nodes through outgoing edges.
This method adds up the derivatives contributed by each outgoing edge.
It gets derivatives w.r.t the inputs at the other end of its outgoing edge.
Args:
edge: The edge which is sending the derivative.
deriv: The derivative w.r.t the inputs at the other end of this edge.'

def AccumulateDeriv(self, layer, edge, deriv):

    if (layer.is_input or edge.proto.block_gradient):
        return
    if layer.dirty:
        layer.deriv.add_dot(edge.params['weight'], deriv)
    else:
        cm.dot(edge.params['weight'], deriv, target=layer.deriv)
        layer.dirty = True
