Beispiel #1
0
    def __init__(self):
        self.sequence_with_explicit_order = GraphSequence([
            ConverterSequenceNode('root', ['Transpose']),
            ConverterSequenceNode('order', ['Const']),
            NonConsumableConverterSequenceNode('input', ['?']),
        ])
        self.sequence_with_explicit_order.set_inputs('root', ['input', 'order'])
        self.sequence_with_explicit_order.set_outputs(['root'])

        self.sequence_with_implicit_order = GraphSequence([
            ConverterSequenceNode('root', ['Transpose']),
            ConverterSequenceNode('order', ['Sub']),
            ConverterSequenceNode('a', ['Sub']),
            ConverterSequenceNode('b', ['Const']),
            ConverterSequenceNode('c', ['Range']),
            ConverterSequenceNode('d', ['Const']),
            ConverterSequenceNode('e', ['Const']),
            ConverterSequenceNode('f', ['Rank']),
            NonConsumableConverterSequenceNode('input', ['?'])
        ])

        self.sequence_with_implicit_order.set_inputs('root', ['input', 'order'])
        self.sequence_with_implicit_order.set_inputs('order', ['a', 'c'])
        self.sequence_with_implicit_order.set_inputs('a', ['b', 'f'])
        self.sequence_with_implicit_order.set_inputs('c', ['d', 'e', 'f'])
        self.sequence_with_implicit_order.set_inputs('f', ['input'])
        self.sequence_with_implicit_order.set_outputs(['root'])

        self.sequences = [self.sequence_with_explicit_order, self.sequence_with_implicit_order]
Beispiel #2
0
 def __init__(self):
     self.sequence = GraphSequence([
         ConverterSequenceNode('root', ['ArgMax']),
         ConverterSequenceNode('axis', ['Const']),
         NonConsumableConverterSequenceNode('input', ['?']),
     ])
     self.sequence.set_inputs('root', ['input', 'axis'])
     self.sequence.set_outputs(['root'])
Beispiel #3
0
    def __init__(self):
        sequence_scalar_pow = GraphSequence([
            NonConsumableConverterSequenceNode('input', ['?']),
            ConverterSequenceNode('pow', ['Pow']),
            ConverterSequenceNode('const', ['Const'])
        ])
        sequence_scalar_pow.set_inputs('pow', ['input', 'const'])
        sequence_scalar_pow.set_outputs(['pow'])

        self.sequences = [sequence_scalar_pow]
Beispiel #4
0
 def __init__(self):
     self.sequence = GraphSequence([
         ConverterSequenceNode('root', ['StridedSlice']),
         ConverterSequenceNode('begin', ['Const']),
         ConverterSequenceNode('end', ['Const']),
         ConverterSequenceNode('strides', ['Const']),
         NonConsumableConverterSequenceNode('input', ['?']),
     ])
     self.sequence.set_inputs('root', ['input', 'begin', 'end', 'strides'])
     self.sequence.set_outputs(['root'])
Beispiel #5
0
    def __init__(self):
        sequence_resize = GraphSequence([ConverterSequenceNode('root', ['ResizeBilinear'])])
        sequence_resize.set_outputs(['root'])

        sequence_shape_stridedslice_resize = GraphSequence([
            NonConsumableConverterSequenceNode('input', ['?']),
            ConverterSequenceNode('shape', ['Shape']),
            ConverterSequenceNode('stridedSlice', ['StridedSlice']),
            ConverterSequenceNode('mul', ['Mul']),
            ConverterSequenceNode('const_stridedSlice_1', ['?']),
            ConverterSequenceNode('const_stridedSlice_2', ['?']),
            ConverterSequenceNode('const_stridedSlice_3', ['?']),
            ConverterSequenceNode('mul_const', ['?']),
            ConverterSequenceNode('root', ['ResizeBilinear'])])

        sequence_shape_stridedslice_resize.set_inputs('shape', ['input'])
        sequence_shape_stridedslice_resize.set_inputs('stridedSlice', ['shape',
                                                                       'const_stridedSlice_1',
                                                                       'const_stridedSlice_2',
                                                                       'const_stridedSlice_3'])
        sequence_shape_stridedslice_resize.set_inputs('mul', ['stridedSlice', 'mul_const'])
        sequence_shape_stridedslice_resize.set_inputs('root', ['mul', 'input'])
        sequence_shape_stridedslice_resize.set_outputs(['root'])

        self.sequences = [sequence_resize, sequence_shape_stridedslice_resize]
Beispiel #6
0
 def __init__(self):
     self.sequence = GraphSequence([
         NonConsumableConverterSequenceNode('inputs', ['?']),
         ConverterSequenceNode('a', ['Mul']),
         ConverterSequenceNode('b', ['Add']),
         ConverterSequenceNode('weights', ['Const', 'Identity']),
         ConverterSequenceNode('biases', ['Const', 'Identity'])
     ])
     self.sequence.set_inputs('a', ['inputs', 'weights'])
     self.sequence.set_inputs('b', ['a', 'biases'])
     self.sequence.set_outputs(['b'])
Beispiel #7
0
    def __init__(self):
        super(DepthwiseConvolutionLayerResolver, self).__init__()
        self.graph_sequence_with_bias = GraphSequence([
            ConverterSequenceNode('conv', ['DepthwiseConv2dNative']),
            ConverterSequenceNode('bias', ['BiasAdd']),
            NonConsumableConverterSequenceNode('other', ['?'])
        ])
        self.graph_sequence_with_bias.set_inputs('bias', ['conv', 'other'])
        self.graph_sequence_with_bias.set_outputs(['bias'])

        self.graph_sequence = GraphSequence([ConverterSequenceNode('conv', ['DepthwiseConv2dNative'])])
        self.graph_sequence.set_outputs(['conv'])
Beispiel #8
0
 def __init__(self):
     self.sequence = GraphSequence([
         ConverterSequenceNode('matmul_op', ['MatMul']),
         ConverterSequenceNode('bias_op', ['BiasAdd', 'Add']),  # output
         NonConsumableConverterSequenceNode('biases',
                                            ['Identity', 'Const']),
         NonConsumableConverterSequenceNode('weights',
                                            ['Identity', 'Const']),
         NonConsumableConverterSequenceNode('inputs', ['?'])
     ])
     self.sequence.set_inputs('matmul_op', ['inputs', 'weights'])
     self.sequence.set_inputs('bias_op', ['matmul_op', 'biases'])
     self.sequence.set_outputs(['bias_op'])
Beispiel #9
0
    def __init__(self, layer_type, op_type, descriptor_class):
        super(ReductionLayerResolver, self).__init__()
        self._layer_type = layer_type
        self._op_type = op_type
        self._descriptor_class = descriptor_class

        self.sequence = GraphSequence([
            ConverterSequenceNode('root', [self._op_type]),
            ConverterSequenceNode('reduction_indices', ['Const']),
            NonConsumableConverterSequenceNode('input', ['?']),
        ])
        self.sequence.set_inputs('root', ['input', 'reduction_indices'])
        self.sequence.set_outputs(['root'])
Beispiel #10
0
    def __init__(self):
        sequence_two_dim_softmax = GraphSequence(
            [ConverterSequenceNode('root', ['SoftMax'])])
        sequence_two_dim_softmax.set_outputs(['root'])

        sequence_multi_dim_softmax = GraphSequence([
            ConverterSequenceNode('max', ['Max']),
            ConverterSequenceNode('max_reduction_indicies', ['Const']),
            ConverterSequenceNode('sub', ['Sub']),
            ConverterSequenceNode('exp', ['Exp']),
            ConverterSequenceNode('sum', ['Sum']),
            ConverterSequenceNode('sum_reduction_indicies', ['Const']),
            ConverterSequenceNode('root', ['RealDiv']),
            NonConsumableConverterSequenceNode('input', ['?'])
        ])
        sequence_multi_dim_softmax.set_inputs(
            'max', ['input', 'max_reduction_indicies'])
        sequence_multi_dim_softmax.set_inputs('sub', ['input', 'max'])
        sequence_multi_dim_softmax.set_inputs('exp', ['sub'])
        sequence_multi_dim_softmax.set_inputs(
            'sum', ['exp', 'sum_reduction_indicies'])
        sequence_multi_dim_softmax.set_inputs('root', ['exp', 'sum'])
        sequence_multi_dim_softmax.set_outputs(['root'])

        self.sequences = [sequence_two_dim_softmax, sequence_multi_dim_softmax]
Beispiel #11
0
 def __init__(self):
     super(DilatedDepthwiseConvolutionLayerResolver, self).__init__()
     self.graph_sequence = GraphSequence([
         NonConsumableConverterSequenceNode('space_to_batch', ['SpaceToBatchND']),
         NonConsumableConverterSequenceNode('inputs', ['?']),
         NonConsumableConverterSequenceNode('dilation_sizes', ['?']),
         NonConsumableConverterSequenceNode('paddings', ['?']),
         ConverterSequenceNode('conv_op', ['DepthwiseConv2dNative']),
         ConverterSequenceNode('kernel', ['?']),
         NonConsumableConverterSequenceNode('batch_to_space', ['BatchToSpaceND']),  # output
         NonConsumableConverterSequenceNode('block_shape_out', ['?']),
         NonConsumableConverterSequenceNode('crops', ['?'])
     ])
     self.graph_sequence.set_inputs('space_to_batch', ['inputs', 'dilation_sizes', 'paddings'])
     self.graph_sequence.set_inputs('conv_op', ['space_to_batch', 'kernel'])
     self.graph_sequence.set_inputs('batch_to_space', ['conv_op', 'block_shape_out', 'crops'])
     self.graph_sequence.set_outputs(['batch_to_space'])
Beispiel #12
0
 def __init__(self):
     self.sequence = GraphSequence([
         ConverterSequenceNode('root', ['Slice']),
         NonConsumableConverterSequenceNode('input', ['?']),
         NonConsumableConverterSequenceNode('offsets', ['?']),
         NonConsumableConverterSequenceNode('size', ['?']),
     ])
     self.sequence.set_inputs('root', ['input', 'offsets', 'size'])
     self.sequence.set_outputs(['root'])
Beispiel #13
0
    def __init__(self, layer_type, descriptor_type, pooling_type, op_type):
        super(PoolingLayerResolver, self).__init__()
        self._layer_type = layer_type
        self._descriptor_type = descriptor_type
        self._polling_type = pooling_type
        self._op_type = op_type

        self.sequence = GraphSequence([ConverterSequenceNode('root', [self._op_type])])
        self.sequence.set_outputs(['root'])
Beispiel #14
0
    def __init__(self):
        sequence = GraphSequence([
            NonConsumableConverterSequenceNode('input', ['?']),
            ConverterSequenceNode('tile', ['Tile']),
            NonConsumableConverterSequenceNode('multiples', ['?'])
        ])
        sequence.set_inputs('tile', ['input', 'multiples'])
        sequence.set_outputs(['tile'])

        self.sequences = [sequence]
Beispiel #15
0
    def __init__(self):
        self.sequence_with_zero_padding = GraphSequence([
            ConverterSequenceNode('root', ['Pad', 'PadV2']),
            ConverterSequenceNode('paddings', ['Const']),
            NonConsumableConverterSequenceNode('input', ['?']),
        ])
        self.sequence_with_zero_padding.set_inputs('root', ['input', 'paddings'])
        self.sequence_with_zero_padding.set_outputs(['root'])

        self.sequence_with_const_padding = GraphSequence([
            ConverterSequenceNode('root', ['Pad', 'PadV2']),
            ConverterSequenceNode('paddings', ['Const']),
            ConverterSequenceNode('const_values', ['Const']),
            NonConsumableConverterSequenceNode('input', ['?']),
        ])
        self.sequence_with_const_padding.set_inputs('root', ['input', 'paddings', 'const_values'])
        self.sequence_with_const_padding.set_outputs(['root'])

        self.sequences = [self.sequence_with_zero_padding, self.sequence_with_const_padding]
    def __init__(self):
        sequence_extract_glimpse = GraphSequence([
            NonConsumableConverterSequenceNode('input', ['?']),
            NonConsumableConverterSequenceNode('size', ['?']),
            NonConsumableConverterSequenceNode('offsets', ['?']),
            ConverterSequenceNode('extract_glimpse', ['ExtractGlimpse'])
        ])
        sequence_extract_glimpse.set_inputs('extract_glimpse', ['input', 'size', 'offsets'])
        sequence_extract_glimpse.set_outputs(['extract_glimpse'])

        sequence_extract_glimpse_strided_slice = GraphSequence([
            NonConsumableConverterSequenceNode('input', ['?']),
            NonConsumableConverterSequenceNode('size', ['?']),
            ConverterSequenceNode('offsets', ['StridedSlice']),
            ConverterSequenceNode('extract_glimpse', ['ExtractGlimpse'])
        ])
        sequence_extract_glimpse_strided_slice.set_inputs('extract_glimpse',
                                                          ['input', 'size', 'offsets'])
        sequence_extract_glimpse_strided_slice.set_outputs(['extract_glimpse'])

        self.sequences = [sequence_extract_glimpse, sequence_extract_glimpse_strided_slice]
Beispiel #17
0
 def __init__(self):
     self.sequence = GraphSequence([
         ConverterSequenceNode('a', ['Add']),
         ConverterSequenceNode('b', ['Rsqrt']),
         ConverterSequenceNode('c', ['Mul']),
         ConverterSequenceNode('d', ['Mul']),
         ConverterSequenceNode('e', ['Sub']),
         ConverterSequenceNode('f', ['Add']),  # output
         NonConsumableConverterSequenceNode('inputs', ['?']),
         ConverterSequenceNode('mean', ['?']),
         ConverterSequenceNode('beta', ['?']),
         ConverterSequenceNode('variance', ['?']),
         ConverterSequenceNode('epsilon', ['?'])
     ])
     self.sequence.set_inputs('a', ['variance', 'epsilon'])
     self.sequence.set_inputs('b', ['a'])
     self.sequence.set_inputs('c', ['b', 'inputs'])
     self.sequence.set_inputs('d', ['b', 'mean'])
     self.sequence.set_inputs('e', ['d', 'beta'])
     self.sequence.set_inputs('f', ['c', 'e'])
     self.sequence.set_outputs(['f'])
Beispiel #18
0
    def __init__(self, layer_type, op_type, descriptor_class):
        super(EltWiseLayerResolver, self).__init__()
        self._layer_type = layer_type
        self._op_type = op_type
        self._descriptor_class = descriptor_class

        self.sequence = GraphSequence([ConverterSequenceNode('root', [self._op_type])])
        self.sequence.set_outputs(['root'])

        self.sequence_with_identity = GraphSequence([
            ConverterSequenceNode('root', [self._op_type]),
            ConverterSequenceNode('identity', ['Identity'])
        ])
        self.sequence_with_identity.set_inputs('identity', ['root'])
        self.sequence_with_identity.set_outputs(['identity'])

        self.sequence_with_const_input = GraphSequence([
            ConverterSequenceNode('root', [self._op_type]),
            NonConsumableConverterSequenceNode('const', ['Const', 'Identity']),
            NonConsumableConverterSequenceNode('other', ['?'])
        ])
        self.sequence_with_const_input.set_inputs('root', ['const', 'other'])
        self.sequence_with_const_input.set_outputs(['root'])

        self.sequence_with_const_input_and_identity = GraphSequence([
            ConverterSequenceNode('root', [self._op_type]),
            ConverterSequenceNode('identity', ['Identity']),
            NonConsumableConverterSequenceNode('const', ['Const']),
            NonConsumableConverterSequenceNode('other', ['?'])
        ])
        self.sequence_with_const_input_and_identity.set_inputs('root', ['const', 'other'])
        self.sequence_with_const_input_and_identity.set_inputs('identity', ['root'])
        self.sequence_with_const_input_and_identity.set_outputs(['identity'])
Beispiel #19
0
 def __init__(self):
     self.sequence = GraphSequence([
         ConverterSequenceNode('a', ['Relu']),
         ConverterSequenceNode('b', ['Abs']),
         ConverterSequenceNode('c', ['Sub']),
         ConverterSequenceNode('d', ['Mul']),
         ConverterSequenceNode('e', ['Mul']),
         ConverterSequenceNode('f', ['Add']),  # output
         ConverterSequenceNode('unknown', ['?']),
         ConverterSequenceNode('alphas', ['?']),
         NonConsumableConverterSequenceNode('inputs', ['?'])
     ])
     self.sequence.set_inputs('a', ['inputs'])
     self.sequence.set_inputs('b', ['inputs'])
     self.sequence.set_inputs('c', ['inputs', 'b'])
     self.sequence.set_inputs('d', ['alphas', 'c'])
     self.sequence.set_inputs('e', ['d', 'unknown'])
     self.sequence.set_inputs('f', ['a', 'e'])
     self.sequence.set_outputs(['f'])
 def __init__(self):
     self.sequence = GraphSequence([
         ConverterSequenceNode('reshape_out', ['Reshape']),
         ConverterSequenceNode('transpose', ['Transpose']),
         ConverterSequenceNode('reshape_in', ['Reshape']),
         ConverterSequenceNode('shape_in', ['Const']),
         ConverterSequenceNode('order', ['Const']),
         ConverterSequenceNode('shape_out', ['Const']),
         NonConsumableConverterSequenceNode('input', ['?']),
     ])
     self.sequence.set_inputs('reshape_out', ['shape_out', 'transpose'])
     self.sequence.set_inputs('transpose', ['order', 'reshape_in'])
     self.sequence.set_inputs('reshape_in', ['shape_in', 'input'])
     self.sequence.set_outputs(['reshape_out'])
Beispiel #21
0
 def __init__(self):
     super(GroupedConvolutionLayerResolver, self).__init__()
     tree_output_node = ConverterSequenceNode('conv_op', ['Conv2D'])
     self.sequence = GraphSequence([
         ConverterSequenceNode('a', ['Split']),
         ConverterSequenceNode('b', ['Split']),
         ConverterRepeatableSequenceTreeNode('repeatable_graph',
                                             tree_output_node,
                                             tree_output_node),
         ConverterSequenceNode('concat_op', ['Concat']),
         ConverterSequenceNode('weights', ['Identity', 'Const']),
         NonConsumableConverterSequenceNode('inputs', ['?']),
         NonConsumableConverterSequenceNode('concat_dim', ['Const']),
         NonConsumableConverterSequenceNode('split_dim1', ['Const']),
         ConverterSequenceNode('split_dim2', ['Const'])
     ])
     self.sequence.set_inputs('a', ['inputs', 'split_dim1'])
     self.sequence.set_inputs('b', ['weights', 'split_dim2'])
     self.sequence.set_inputs('repeatable_graph', ['a', 'b'])
     self.sequence.set_inputs('concat_op',
                              ['repeatable_graph', 'concat_dim'])
     self.sequence.set_outputs(['concat_op'])
Beispiel #22
0
 def __init__(self):
     self.sequence = GraphSequence(
         [ConverterSequenceNode('root', ['Relu6'])])
     self.sequence.set_outputs(['root'])
Beispiel #23
0
 def __init__(self):
     self.sequence = GraphSequence([
         ConverterSequenceNode('root', ['Reshape', 'Squeeze', 'ExpandDims'])
     ])
     self.sequence.set_outputs(['root'])
Beispiel #24
0
# //  except copyright notices indicating different years of publication for
# //  different portions of the software. This notice does not supersede the
# //  application of any third party copyright notice to that third party's
# //  code.
# //
# //  @@-COPYRIGHT-END-@@
# //=============================================================================
from converters.tensorflow.graph_matcher import (
    ConverterSequenceNode,
    NonConsumableConverterSequenceNode,
    GraphSequence
)

box_decoder_sequence = GraphSequence([
    NonConsumableConverterSequenceNode('Postprocessor/Tile', ['Tile']),
    ConverterSequenceNode('Postprocessor/Reshape_1', ['Reshape']),
    ConverterSequenceNode('Postprocessor/Reshape', ['Reshape']),
    ConverterSequenceNode('Postprocessor/Decode/transpose', ['Transpose']),
    ConverterSequenceNode('Postprocessor/Decode/div_3', ['RealDiv']),
    ConverterSequenceNode('Postprocessor/Decode/div_2', ['RealDiv']),
    ConverterSequenceNode('Postprocessor/Decode/get_center_coordinates_and_sizes/transpose', ['Transpose']),
    ConverterSequenceNode('Postprocessor/Decode/unstack', ['Unpack']),
    ConverterSequenceNode('Postprocessor/Decode/Exp', ['Exp']),
    ConverterSequenceNode('Postprocessor/Decode/get_center_coordinates_and_sizes/div_1', ['RealDiv']),
    ConverterSequenceNode('Postprocessor/Decode/get_center_coordinates_and_sizes/sub', ['Sub']),
    ConverterSequenceNode('Postprocessor/Decode/div_1', ['RealDiv']),
    ConverterSequenceNode('Postprocessor/Decode/Exp_1', ['Exp']),
    ConverterSequenceNode('Postprocessor/Decode/get_center_coordinates_and_sizes/div', ['RealDiv']),
    ConverterSequenceNode('Postprocessor/Decode/get_center_coordinates_and_sizes/unstack', ['Unpack']),
    ConverterSequenceNode('Postprocessor/Decode/get_center_coordinates_and_sizes/sub_1', ['Sub']),
    ConverterSequenceNode('Postprocessor/Decode/div', ['RealDiv']),
Beispiel #25
0
#=============================================================================
#
#  Copyright (c) 2015-2017 Qualcomm Technologies, Inc.
#  All Rights Reserved.
#  Confidential and Proprietary - Qualcomm Technologies, Inc.
#
#=============================================================================
from converters.tensorflow.graph_matcher import (
    ConverterSequenceNode,
    NonConsumableConverterSequenceNode,
    GraphSequence
)

cell_sequence = GraphSequence([
    NonConsumableConverterSequenceNode('rnn/multi_rnn_cell/cell_0/basic_lstm_cell/kernel/read', ['Identity']),
    ConverterSequenceNode('rnn/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/basic_lstm_cell/concat',
                          ['ConcatV2']),
    NonConsumableConverterSequenceNode('rnn/multi_rnn_cell/cell_0/basic_lstm_cell/bias/read', ['Identity']),
    ConverterSequenceNode('rnn/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/basic_lstm_cell/MatMul',
                          ['MatMul']),
    ConverterSequenceNode('rnn/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/basic_lstm_cell/BiasAdd',
                          ['BiasAdd']),
    ConverterSequenceNode('rnn/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/split', ['Split']),
    ConverterSequenceNode('rnn/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/add', ['Add']),
    ConverterSequenceNode('rnn/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/Tanh', ['Tanh']),
    ConverterSequenceNode('rnn/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/Sigmoid_1', ['Sigmoid']),
    ConverterSequenceNode('rnn/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/Sigmoid', ['Sigmoid']),
    ConverterSequenceNode('rnn/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/mul_1', ['Mul']),
    ConverterSequenceNode('rnn/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/mul', ['Mul']),
    ConverterSequenceNode('rnn/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/add_1', ['Add']),
    ConverterSequenceNode('rnn/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/Sigmoid_2', ['Sigmoid']),
    ConverterSequenceNode('rnn/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/Tanh_1', ['Tanh']),
Beispiel #26
0
    def __init__(self):
        super(GroupedConvolutionLayerResolver, self).__init__()

        # grouped convolution with split
        tree_output_node = ConverterSequenceNode('conv_op', ['Conv2D'])
        self.sequence = GraphSequence([
            ConverterSequenceNode('a', ['Split']),
            ConverterSequenceNode('b', ['Split']),
            ConverterRepeatableSequenceTreeNode('repeatable_graph', tree_output_node, tree_output_node),
            ConverterSequenceNode('concat_op', ['Concat']),
            ConverterSequenceNode('weights', ['Identity', 'Const']),
            NonConsumableConverterSequenceNode('inputs', ['?']),
            NonConsumableConverterSequenceNode('concat_dim', ['Const']),
            NonConsumableConverterSequenceNode('split_dim1', ['Const']),
            ConverterSequenceNode('split_dim2', ['Const'])
        ])
        self.sequence.set_inputs('a', ['inputs', 'split_dim1'])
        self.sequence.set_inputs('b', ['weights', 'split_dim2'])
        self.sequence.set_inputs('repeatable_graph', ['a', 'b'])
        self.sequence.set_inputs('concat_op', ['repeatable_graph', 'concat_dim'])
        self.sequence.set_outputs(['concat_op'])

        # grouped convolution with strided slice
        repeatable_sequence = GraphSequence([
                ConverterSequenceNode('ss', ['StridedSlice']),
                ConverterSequenceNode('ss_begin', ['Const']),
                ConverterSequenceNode('ss_end', ['Const']),
                ConverterSequenceNode('ss_strides', ['Const']),
                ConverterSequenceNode('conv', ['Conv2D']),
                ConverterSequenceNode('bias', ['BiasAdd']),
                ConverterSequenceNode('weights', ['Identity', 'Const']),
                ConverterSequenceNode('biases', ['Identity', 'Const'])
        ])
        repeatable_sequence.set_inputs('ss', ['ss_begin', 'ss_end', 'ss_strides'])
        repeatable_sequence.set_inputs('conv', ['ss', 'weights'])
        repeatable_sequence.set_inputs('bias', ['biases', 'conv'])
        repeatable_sequence.set_outputs(['bias'])

        self.sequence_with_strided_slice = GraphSequence([
            ConverterRepeatableSequenceTreeNode('repeatable_graph',
                                                tree_output_node=repeatable_sequence['bias'],
                                                tree_input_node=repeatable_sequence['ss']),
            ConverterSequenceNode('concat', ['Concat', 'ConcatV2']),
            ConverterSequenceNode('axis', ['Const']),
            NonConsumableConverterSequenceNode('input', ['?'])
        ])
        self.sequence_with_strided_slice.set_inputs('repeatable_graph', ['input'])
        self.sequence_with_strided_slice.set_inputs('concat', ['repeatable_graph', 'axis'])
        self.sequence_with_strided_slice.set_outputs(['concat'])
Beispiel #27
0
#=============================================================================
#
#  Copyright (c) 2015-2018 Qualcomm Technologies, Inc.
#  All Rights Reserved.
#  Confidential and Proprietary - Qualcomm Technologies, Inc.
#
#=============================================================================
from converters.tensorflow.graph_matcher import (
    ConverterSequenceNode,
    NonConsumableConverterSequenceNode,
    GraphSequence
)


real_div_sequence = GraphSequence([
    ConverterSequenceNode('root', ['RealDiv']),
    NonConsumableConverterSequenceNode('a', ['?']),
    NonConsumableConverterSequenceNode('b', ['?'])
])
real_div_sequence.set_inputs('root', ['a', 'b'])
real_div_sequence.set_outputs(['root'])

identity_sequence = GraphSequence([
    ConverterSequenceNode('root', ['Identity']),
    NonConsumableConverterSequenceNode('any', ['?']),
])
identity_sequence.set_inputs('root', ['any'])
identity_sequence.set_outputs(['root'])

placeholder_with_default_sequence = GraphSequence([
    ConverterSequenceNode('root', ['PlaceholderWithDefault']),
Beispiel #28
0
 def __init__(self):
     self.sequence = GraphSequence(
         [ConverterSequenceNode('root', ['ResizeNearestNeighbor'])])
     self.sequence.set_outputs(['root'])
Beispiel #29
0
    def __init__(self):
        sequence_reshape = GraphSequence([ConverterSequenceNode('root', ['Reshape', 'Squeeze', 'ExpandDims'])])
        sequence_reshape.set_outputs(['root'])

        sequence_flatten = GraphSequence([
            NonConsumableConverterSequenceNode('input', ['?']),
            ConverterSequenceNode('shape', ['Shape']),
            ConverterSequenceNode('slice_1', ['Slice']),
            ConverterSequenceNode('const_1', ['Const']),
            ConverterSequenceNode('const_2', ['Const']),
            ConverterSequenceNode('slice_2', ['Slice']),
            ConverterSequenceNode('const_3', ['Const']),
            ConverterSequenceNode('const_4', ['Const']),
            ConverterSequenceNode('prod', ['Prod']),
            ConverterSequenceNode('const_5', ['Const']),
            ConverterSequenceNode('expand_dims', ['ExpandDims']),
            ConverterSequenceNode('const_6', ['Const']),
            ConverterSequenceNode('concat', ['ConcatV2']),
            ConverterSequenceNode('const_7', ['Const']),
            ConverterSequenceNode('root', ['Reshape']),
        ])
        sequence_flatten.set_inputs('shape', ['input'])
        sequence_flatten.set_inputs('slice_1', ['shape', 'const_1', 'const_2'])
        sequence_flatten.set_inputs('slice_2', ['shape', 'const_3', 'const_4'])
        sequence_flatten.set_inputs('prod', ['slice_2', 'const_5'])
        sequence_flatten.set_inputs('expand_dims', ['prod', 'const_6'])
        sequence_flatten.set_inputs('concat', ['slice_1', 'expand_dims', 'const_7'])
        sequence_flatten.set_inputs('root', ['input', 'concat'])
        sequence_flatten.set_outputs(['root'])

        self.sequences = [sequence_reshape, sequence_flatten]
Beispiel #30
0
    def __init__(self):
        sequence_prelu = GraphSequence([
            ConverterSequenceNode('a', ['Relu']),
            ConverterSequenceNode('b', ['Abs']),
            ConverterSequenceNode('c', ['Sub']),
            ConverterSequenceNode('d', ['Mul']),
            ConverterSequenceNode('e', ['Mul']),
            ConverterSequenceNode('f', ['Add']),  # output
            ConverterSequenceNode('unknown', ['?']),
            ConverterSequenceNode('alphas', ['?']),
            NonConsumableConverterSequenceNode('inputs', ['?'])
        ])
        sequence_prelu.set_inputs('a', ['inputs'])
        sequence_prelu.set_inputs('b', ['inputs'])
        sequence_prelu.set_inputs('c', ['inputs', 'b'])
        sequence_prelu.set_inputs('d', ['alphas', 'c'])
        sequence_prelu.set_inputs('e', ['d', 'unknown'])
        sequence_prelu.set_inputs('f', ['a', 'e'])
        sequence_prelu.set_outputs(['f'])

        sequence_prelu_negative_alpha = GraphSequence([
            ConverterSequenceNode('a', ['Relu']),
            ConverterSequenceNode('b', ['Neg']),
            ConverterSequenceNode('c', ['Neg']),
            ConverterSequenceNode('d', ['Relu']),
            ConverterSequenceNode('e', ['Mul']),
            ConverterSequenceNode('f', ['Add']),  # output
            ConverterSequenceNode('alphas', ['?']),
            NonConsumableConverterSequenceNode('inputs', ['?'])
        ])
        sequence_prelu_negative_alpha.set_inputs('a', ['inputs'])
        sequence_prelu_negative_alpha.set_inputs('b', ['inputs'])
        sequence_prelu_negative_alpha.set_inputs('c', ['alphas'])
        sequence_prelu_negative_alpha.set_inputs('d', ['b'])
        sequence_prelu_negative_alpha.set_inputs('e', ['d', 'c'])
        sequence_prelu_negative_alpha.set_inputs('f', ['a', 'e'])
        sequence_prelu_negative_alpha.set_outputs(['f'])

        sequence_prelu_negative_relu = GraphSequence([
            ConverterSequenceNode('relu_pos', ['Relu']),
            ConverterSequenceNode('neg_1', ['Neg']),
            ConverterSequenceNode('neg_2', ['Neg']),
            ConverterSequenceNode('relu_neg', ['Relu']),
            ConverterSequenceNode('mul', ['Mul']),
            ConverterSequenceNode('f', ['Add']),  # output
            ConverterSequenceNode('alphas', ['?']),
            NonConsumableConverterSequenceNode('inputs', ['?'])
        ])
        sequence_prelu_negative_relu.set_inputs('relu_pos', ['inputs'])
        sequence_prelu_negative_relu.set_inputs('neg_1', ['inputs'])
        sequence_prelu_negative_relu.set_inputs('relu_neg', ['neg_1'])
        sequence_prelu_negative_relu.set_inputs('neg_2', ['relu_neg'])
        sequence_prelu_negative_relu.set_inputs('mul', ['neg_2', 'alphas'])
        sequence_prelu_negative_relu.set_inputs('f', ['relu_pos', 'mul'])
        sequence_prelu_negative_relu.set_outputs(['f'])

        self.sequences = [
            sequence_prelu, sequence_prelu_negative_alpha,
            sequence_prelu_negative_relu
        ]