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)
| 32 | |
| 33 | |
| 34 | def 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 | |
| 52 | def back_broadcast(y_shape, x_shape, x): |
no test coverage detected