Utils¶
-
singa.utils.
force_unicode
(s)¶ return string of a bytes ! borrow from onnx :param s: string or bytes
- Returns
string
-
singa.utils.
get_output_shape
(auto_pad, input_spatial_shape, kernel_spatial_shape, strides_spatial)¶ return output shape of conv2d or pooling, ! borrow from onnx :param auto_pad: string
- Parameters
kernel_spatial_shape – list[int]
strides_spatial – list[int]
output_spatial_shape – list[int]
- Returns
list[int
-
singa.utils.
get_padding_shape
(pad_mode, input_spatial_shape, kernel_spatial_shape, strides_spatial)¶ return padding shape of conv2d or pooling, :param pad_mode: string
- Parameters
kernel_spatial_shape – list[int]
strides_spatial – list[int]
- Returns
list[int]
-
singa.utils.
handle_odd_pad_bwd
(dx, odd_padding)¶ handle odd padding mode backward Args:dx
the backward tensor
- Args:odd_padding
the odd_padding
- Returns
tensor, the output
-
singa.utils.
handle_odd_pad_fwd
(x, odd_padding)¶ handle odd padding mode forward Args:x
the input tensor
- Args:odd_padding
the odd_padding
- Returns
tensor, the output
-
singa.utils.
post_order_recursive
(root, root_t)¶ return a list by the topological ordering (postorder of Depth-first search) :param root: singa operator
- Parameters
root_t – tensor
- Returns
deque[int]
-
singa.utils.
re_new_handle
(handle, x, is_pool=False)¶ re-new a handle by useing the new input tensor Args:handle
the handle
- Args:x
input tensor
- Returns
handle, a new handle
-
singa.utils.
same_pad_shape_check
(handle, pad_mode, x)¶ check the shape is correct for same padding mode Args:handle
the handle
- Args:pad_mode
pad_mode
- Args:x
input tensor
- Returns
tuple, the correct padding(before divide 2)
-
singa.utils.
update_progress
(progress, info)¶ Display progress bar and user info.
- Parameters
progress (float) – progress [0, 1], negative for halt, and >=1 for done.
info (str) – a string for user provided info to be displayed.