def proto_extractor(pb, model_pb, mapping, disable_omitting_optional, enable_flattening_nested_params): log.info("Custom extractor for layer {} with mapping {}".format( pb.type, mapping)) log.debug('Found custom layer {}. Params are processed'.format(pb.name)) if mapping['hasParam'].lower() != 'true': return {} try: native_attr = collect_attributes( getattr(pb, mapping['protoParamName']), disable_omitting_optional=disable_omitting_optional, enable_flattening_nested_params=enable_flattening_nested_params) except AttributeError as e: error_message = 'Layer {} has no attribute {}'.format( pb.type, str(e).split(' ')[-1]) log.error(error_message) raise ValueError(error_message) keys = list(native_attr.keys()) obfuscate_special_attrs(native_attr, keys) # avoid 'mo_caffe' appearing in param for attr in native_attr: if 'mo_caffe' in native_attr[attr]: native_attr[attr] = native_attr[attr].replace('mo_caffe', 'caffe') log.debug(str(keys)) log.debug(str(native_attr)) attrs = { 'IE': [('layer', [('id', lambda node: node.id), 'name', 'type'], [('data', keys, []), '@ports', '@consts'])] } attrs.update(native_attr) return attrs
def extract(node): param = node.pb.elu_param attrs = collect_attributes(param) attrs['operation'] = 'elu' Activation.update_node_stat(node, attrs) return ELUFrontExtractor.enabled
def extract(cls, node): mapping_rule = collect_attributes(node.pb.shuffle_channel_param) mapping_rule.update(layout_attrs()) # update the attributes of the node ShuffleChannels.update_node_stat(node, mapping_rule) return cls.enabled
def extract(node): mapping_rule = collect_attributes(node.pb.shuffle_channel_param) mapping_rule.update(layout_attrs()) # update the attributes of the node Op.get_op_class_by_name(__class__.op).update_node_stat( node, mapping_rule) return __class__.enabled
def extract(cls, node): proto_layer = node.pb param = proto_layer.accum_param attrs = collect_attributes(param) # update the attributes of the node AccumOp.update_node_stat(node, attrs) return cls.enabled
def extract(node): proto_layer = node.pb param = proto_layer.accum_param attrs = collect_attributes(param) # update the attributes of the node Op.get_op_class_by_name(__class__.op).update_node_stat(node, attrs) return __class__.enabled
def extract(cls, node): proto_layer = node.pb param = proto_layer.power_file_param attrs = collect_attributes(param) # update the attributes of the node PowerFileOp.update_node_stat(node, attrs) return cls.enabled
def extract(node): proto_layer = node.pb param = proto_layer.norm_param attrs = collect_attributes(param, enable_flattening_nested_params=True) attrs.update(weights_biases(False, node.model_pb)) # update the attributes of the node Op.get_op_class_by_name(__class__.op).update_node_stat(node, attrs) return __class__.enabled
def extract(cls, node): proto_layer = node.pb param = proto_layer.norm_param attrs = collect_attributes(param, enable_flattening_nested_params=True) attrs.update(weights_biases(False, node.model_pb)) # update the attributes of the node NormalizeOp.update_node_stat(node, attrs) return cls.enabled
def extract(cls, node): proto_layer = node.pb param = proto_layer.mvn_param attrs = collect_attributes(param) if 'normalize_variance' not in attrs: attrs['normalize_variance'] = 1 if 'across_channels' not in attrs: attrs['across_channels'] = 0 # update the attributes of the node MVNCaffe.update_node_stat(node, attrs) return cls.enabled
def extract(cls, node): param = node.pb.elu_param attrs = collect_attributes(param) Elu.update_node_stat(node, attrs) return cls.enabled