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

Method dot

python/singa/autograd.py:4941–4960  ·  view source on GitHub ↗

dot multiply Args: a (CTensor): 2d input tensor. b (CTensor): 2d input tensor. Returns: CTensor: the output CTensor.

(cls, a, b)

Source from the content-addressed store, hash-verified

4939
4940 @classmethod
4941 def dot(cls, a, b):
4942 """
4943 dot multiply
4944 Args:
4945 a (CTensor): 2d input tensor.
4946 b (CTensor): 2d input tensor.
4947 Returns:
4948 CTensor: the output CTensor.
4949 """
4950 batch_size = a.shape()[0]
4951 ret = []
4952 for indice in range(batch_size):
4953 tmp_a = singa.SliceOn(a, indice, indice + 1, 0) # 1 * d
4954 tmp_b = singa.SliceOn(b, indice, indice + 1, 0) # 1 * d
4955 tmp_b = singa.DefaultTranspose(tmp_b)
4956 tmp_tensor = singa.Mult(tmp_a, tmp_b) # 1 * d * d * 1
4957 ret.append(tmp_tensor)
4958 ret = singa.VecTensor(ret)
4959 ret = singa.ConcatOn(ret, 0) # b * 1
4960 return singa.Reshape(ret, [ret.shape()[0]]) # b
4961
4962 def forward(self, a, b):
4963 """

Callers 4

forwardMethod · 0.80
_gemm_helperMethod · 0.80
_cossim_valueMethod · 0.80
arcface.pyFile · 0.80

Calls 2

shapeMethod · 0.80
appendMethod · 0.80

Tested by 2

_gemm_helperMethod · 0.64
_cossim_valueMethod · 0.64