def tf_create_attrs(node, input_feature_channel, output_feature_channel): data_format = node.pb.attr["data_format"] dilations = tf_int_list(node.pb.attr["dilations"].list) if len(dilations) == 0: dilations = None attrs = { 'type': 'Convolution', 'auto_pad': convert_tf_padding_to_str(node.pb.attr['padding'].s.decode()), 'bias_addable': True, 'bias_term': False, 'dilation': dilations, 'stride': tf_int_list(node.pb.attr["strides"].list), 'channel_dims': tf_data_format_channel(data_format), 'batch_dims': tf_data_format_batch(data_format), 'input_feature_channel': input_feature_channel, 'output_feature_channel': output_feature_channel, 'layout': data_format.s.decode(), # get_group and get_output_feature_dim are special attrs that stores lambdas ( lambda node, kernel_shape:...) # this attrs calls in infer function to calculate output feature dimension and group attr 'get_group': None, # lambda should return group attr for given node 'get_output_feature_dim': None, # lamda should return output feature dimension } return attrs
def extract(cls, node): attrs = { 'spatial_dims': int64_array([1, 2]), 'sizes': tf_int_list(node.pb.attr['ksizes'].list), 'strides': tf_int_list(node.pb.attr['strides'].list), 'rates': tf_int_list(node.pb.attr['rates'].list), 'auto_pad': convert_tf_padding_to_str(node.pb.attr['padding'].s.decode()), } ExtractImagePatches.update_node_stat(node, attrs) return cls.enabled
def create_pooling_attrs(node, pool_method): data_format = node.pb.attr["data_format"] attrs = { 'auto_pad': convert_tf_padding_to_str(node.pb.attr['padding'].s.decode()), 'window': tf_int_list(node.pb.attr['ksize'].list), 'spatial_dims': tf_data_format_spatial(data_format), 'pad': None, # will be inferred when input shape is known 'stride': tf_int_list(node.pb.attr['strides'].list), 'pad_spatial_shape': None, 'output_spatial_shape': None, 'pool_method': pool_method, 'layout': data_format.s.decode(), 'exclude_pad': True, } return attrs
def tf_create_attrs(node, input_feature_channel, output_feature_channel): data_format = node.pb.attr["data_format"] return { 'auto_pad': convert_deconv_tf_padding_to_str(node.pb.attr['padding'].s.decode()), 'bias_addable': True, 'bias_term': False, 'spatial_dims': tf_data_format_spatial(data_format), 'channel_dims': tf_data_format_channel(data_format), 'batch_dims': tf_data_format_batch(data_format), 'pad': None, # will be inferred when input shape is known 'pad_spatial_shape': None, 'output_spatial_shape': None, 'output_shape': None, 'output': None, 'stride': tf_int_list(node.pb.attr["strides"].list), 'type': None, # don't set type until we are sure it is really translated to correct IR; see infer function 'group': None, 'layout': data_format.s.decode(), 'input_feature_channel': input_feature_channel, 'output_feature_channel': output_feature_channel, }
def extract(cls, node: Node): Squeeze.update_node_stat( node, {'squeeze_dims': tf_int_list(node.pb.attr['squeeze_dims'].list)}) return cls.enabled