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

Function axis_helper

python/singa/autograd.py:34–49  ·  view source on GitHub ↗

check which axes the x has been broadcasted Args: y_shape: the shape of result x_shape: the shape of x Return: a tuple refering the axes

(y_shape, x_shape)

Source from the content-addressed store, hash-verified

32
33
34def axis_helper(y_shape, x_shape):
35 """
36 check which axes the x has been broadcasted
37 Args:
38 y_shape: the shape of result
39 x_shape: the shape of x
40 Return:
41 a tuple refering the axes
42 """
43 res = []
44 j = len(x_shape) - 1
45 for i in range(len(y_shape) - 1, -1, -1):
46 if j < 0 or x_shape[j] != y_shape[i]:
47 res.append(i)
48 j -= 1
49 return tuple(res[::-1])
50
51
52def back_broadcast(y_shape, x_shape, x):

Callers 1

back_broadcastFunction · 0.70

Calls 2

appendMethod · 0.80
tupleFunction · 0.50

Tested by

no test coverage detected