MCPcopy Create free account
hub / github.com/apache/singa / forward

Method forward

python/singa/autograd.py:3713–3734  ·  view source on GitHub ↗

forward propogation of Gemm Args: A (CTensor): The shape of A should be (M, K) if transA is 0, or (K, M) if transA is non-zero. B (CTensor): The shape of B should be (K, N) if transB is 0, or (N, K) if transB is non-zero.

(self, A, B, C=None)

Source from the content-addressed store, hash-verified

3711 self.transB = transB
3712
3713 def forward(self, A, B, C=None):
3714 """
3715 forward propogation of Gemm
3716 Args:
3717 A (CTensor): The shape of A should be (M, K) if transA is 0, or
3718 (K, M) if transA is non-zero.
3719 B (CTensor): The shape of B should be (K, N) if transB is 0, or
3720 (N, K) if transB is non-zero.
3721 C (CTensor): (optional), Optional input tensor C. If not specified,
3722 the computation is done as if C is a scalar 0. The shape of C
3723 should be unidirectional broadcastable to (M, N).
3724 Returns:
3725 tensor, the output
3726 """
3727 _A = singa.DefaultTranspose(A) if self.transA == 1 else A
3728 _B = singa.DefaultTranspose(B) if self.transB == 1 else B
3729 if training:
3730 self.inputs = (_A, _B, C)
3731 tmpM = singa.MultFloat(singa.Mult(_A, _B), self.alpha)
3732 if C:
3733 tmpM = singa.__add__(tmpM, singa.MultFloat(C, self.beta))
3734 return tmpM
3735
3736 def backward(self, dy):
3737 """

Callers

nothing calls this directly

Calls 1

__add__Method · 0.45

Tested by

no test coverage detected