def extract(cls, node): mode = onnx_attr(node, 'mode', 's', default='constant', dst_type=lambda x: x.decode()) pads = onnx_attr(node, 'pads', 'ints', dst_type=lambda x: np.array(x, dtype=np.int64)) value = onnx_attr(node, 'value', 'f', default=0.) assert pads is not None # MO Pad op and ONNX Pad op have different format for pads values # MO Pad has Dx2 where D is the total number of dimensions # ONNX Pad pads flat layout, so # need to reshape and transpose pads = np.transpose(pads.reshape([2, -1])) Pad.update_node_stat(node, { 'mode': mode, 'pads': pads, 'fill_value': value }) return cls.enabled
def extract(node): attrs = get_mxnet_layer_attrs(node.symbol_dict) pads = np.array(list(attrs.tuple('pad_width', int, None))) pads = pads.reshape([-1, 2]) value = attrs.float('constant_value', 0.0) node_attrs = { 'pads': pads, 'mode': attrs.str('mode', None), 'fill_value': value, } Pad.update_node_stat(node, node_attrs) return __class__.enabled
def extract(node): Pad.update_node_stat(node) return __class__.enabled
def extract(node): Pad.update_node_stat(node, {'mode': node.pb.attr['mode'].s.decode('utf-8').lower()}) return __class__.enabled
def extract(cls, node): Pad.update_node_stat(node) return cls.enabled