'Doing following operations (* is dot product)
C = alpha * A * B   + beta * C
C = alpha * A.T * B + beta * C
C = alpha * A * B.T + beta * C.
relu: if true applied before output (and prior to beta addition)
The operation will be short-circuited to: out <- alpha * left * right
if beta has value 0 (the default).
Arguments:
A, B (CPUTensor): input operands
C (CPUTensor): output
alpha (float): scale A*B term
beta (float): scale C term before sum
relu (bool): whether to apply ReLu before output'

def compound_dot(self, A, B, C, alpha=1.0, beta=0.0, relu=False, bsum=None):

    assert (A.dtype == B.dtype == C.dtype)
    assert (A.shape[0] == C.shape[0])
    assert (B.shape[1] == C.shape[1])
    assert (A.shape[1] == B.shape[0])
    if (beta == 0):
        if (C._tensor.flags['C_CONTIGUOUS'] is not True):
            tmp = np.empty(C.shape, dtype=C.dtype)
            np.dot(A._tensor, B._tensor, tmp)
            C._tensor[:] = tmp.copy()
        else:
            np.dot(A._tensor, B._tensor, C._tensor)
        if relu:
            self.Relu(C._tensor, C._tensor)
    else:
        np.multiply(C._tensor, beta, C._tensor)
        tmp = np.empty(C.shape, dtype=C.dtype)
        np.dot(A._tensor, B._tensor, tmp)
        np.multiply(tmp, alpha, tmp)
        if relu:
            self.Relu(tmp, tmp)
        np.add(C._tensor, tmp, C._tensor)
    if (bsum is not None):
        bsum[:] = self.sum(C, 1)
    return C
