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

Function re_new_handle

python/singa/utils.py:132–156  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

130
131
132def 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
159def get_padding_shape(pad_mode, input_spatial_shape, kernel_spatial_shape,

Callers

nothing calls this directly

Calls 5

typeFunction · 0.85
PoolingHandleMethod · 0.80
ConvHandleMethod · 0.80
CudnnPoolingHandleMethod · 0.80
CudnnConvHandleMethod · 0.80

Tested by

no test coverage detected