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

Function handle_odd_pad_bwd

python/singa/utils.py:88–107  ·  view source on GitHub ↗

handle odd padding mode backward Args: dx, the backward tensor odd_padding, the odd_padding Returns: tensor, the output

(dx, odd_padding)

Source from the content-addressed store, hash-verified

86
87
88def handle_odd_pad_bwd(dx, odd_padding):
89 """
90 handle odd padding mode backward
91 Args:
92 dx, the backward tensor
93 odd_padding, the odd_padding
94 Returns:
95 tensor, the output
96 """
97 # (axis, left padding if True else right padding)
98 flags = [(2, True), (2, False), (3, True), (3, False)]
99 for (axis, left), pad in zip(flags, odd_padding):
100 if pad == 0:
101 continue
102 axis_shape = list(dx.shape())[axis]
103 if left:
104 dx = singa.SliceOn(dx, pad, axis_shape, axis)
105 else:
106 dx = singa.SliceOn(dx, 0, axis_shape - pad, axis)
107 return dx
108
109
110def same_pad_shape_check(handle, pad_mode, x):

Callers

nothing calls this directly

Calls 1

shapeMethod · 0.80

Tested by

no test coverage detected