check the shape is correct for same padding mode Args: handle, the handle pad_mode, pad_mode x: input tensor Returns: tuple, the correct padding(before divide 2)
(handle, pad_mode, x)
| 108 | |
| 109 | |
| 110 | def same_pad_shape_check(handle, pad_mode, x): |
| 111 | """ |
| 112 | check the shape is correct for same padding mode |
| 113 | Args: |
| 114 | handle, the handle |
| 115 | pad_mode, pad_mode |
| 116 | x: input tensor |
| 117 | Returns: |
| 118 | tuple, the correct padding(before divide 2) |
| 119 | """ |
| 120 | _kernel = [handle.kernel_h, handle.kernel_w] |
| 121 | _stride = [handle.stride_h, handle.stride_w] |
| 122 | _padding = [handle.pad_h, handle.pad_w] |
| 123 | _padding_correct = get_padding_shape(pad_mode, |
| 124 | x.shape()[2:], _kernel, _stride) |
| 125 | _padding_crop, _ = [x // 2 for x in _padding_correct] |
| 126 | assert _padding == _padding_crop, ( |
| 127 | 'For a same mode, the given padding %s is wrong, the correct one should be %s.' |
| 128 | % (_padding, _padding_crop)) |
| 129 | return _padding_correct |
| 130 | |
| 131 | |
| 132 | def re_new_handle(handle, x, is_pool=False): |
nothing calls this directly
no test coverage detected