re-new a handle by useing the new input tensor Args: handle, the handle x, input tensor Returns: handle, a new handle
(handle, x, is_pool=False)
| 130 | |
| 131 | |
| 132 | def re_new_handle(handle, x, is_pool=False): |
| 133 | """ |
| 134 | re-new a handle by useing the new input tensor |
| 135 | Args: |
| 136 | handle, the handle |
| 137 | x, input tensor |
| 138 | Returns: |
| 139 | handle, a new handle |
| 140 | """ |
| 141 | kernel_size = [handle.kernel_h, handle.kernel_w] |
| 142 | stride = [handle.stride_h, handle.stride_w] |
| 143 | padding = [handle.pad_h, handle.pad_w] |
| 144 | if is_pool: |
| 145 | params = (x, kernel_size, stride, padding, handle.is_max_pooling) |
| 146 | else: |
| 147 | params = (x, kernel_size, stride, padding, handle.channels, |
| 148 | handle.num_filters, handle.bias_term, handle.group) |
| 149 | if (type(handle) == singa.ConvHandle or |
| 150 | type(handle) == singa.PoolingHandle): |
| 151 | handle = singa.PoolingHandle(*params) if is_pool else singa.ConvHandle( |
| 152 | *params) |
| 153 | else: |
| 154 | handle = singa.CudnnPoolingHandle( |
| 155 | *params) if is_pool else singa.CudnnConvHandle(*params) |
| 156 | return handle |
| 157 | |
| 158 | |
| 159 | def get_padding_shape(pad_mode, input_spatial_shape, kernel_spatial_shape, |
nothing calls this directly
no test coverage detected