Exemplo n.º 1
0
 def test_psroipool_infer_nhwc(self):
     graph = build_graph(
         nodes_attributes,
         [('node_1', 'psroipool'), ('node_2', 'psroipool'),
          ('psroipool', 'node_3'), ('node_3', 'op_output')], {
              'node_3': {
                  'shape': None
              },
              'node_1': {
                  'shape': np.array([1, 227, 227, 3])
              },
              'node_2': {
                  'shape': np.array([100, 5])
              },
              'psroipool': {
                  'output_dim': 4,
                  'group_size': 15
              }
          })
     graph.graph['layout'] = 'NHWC'
     psroipool_node = Node(graph, 'psroipool')
     PSROIPoolingOp.psroipooling_infer(psroipool_node)
     exp_shape = np.array([100, 15, 15, 4])
     res_shape = graph.node['node_3']['shape']
     for i in range(0, len(exp_shape)):
         self.assertEqual(exp_shape[i], res_shape[i])
Exemplo n.º 2
0
    def test_psroipool_infer_no_shape(self):
        graph = build_graph(
            nodes_attributes,
            [('node_1', 'psroipool'), ('node_2', 'psroipool'),
             ('psroipool', 'node_3'), ('node_3', 'op_output')], {
                 'node_3': {
                     'shape': None
                 },
                 'node_1': {
                     'shape': None
                 },
                 'node_2': {
                     'shape': np.array([100, 5])
                 },
                 'psroipool': {
                     'output_dim': 4,
                     'group_size': 224
                 }
             })
        graph.graph['layout'] = 'NCHW'

        psroipool_node = Node(graph, 'psroipool')
        PSROIPoolingOp.psroipooling_infer(psroipool_node)
        res_shape = graph.node['node_3']['shape']
        self.assertIsNone(res_shape)
Exemplo n.º 3
0
    def extract(node):
        attrs = get_mxnet_layer_attrs(node.symbol_dict)
        spatial_scale = attrs.float('spatial_scale', None)
        group_size = attrs.int('group_size', 0)
        no_trans = attrs.bool('no_trans', False)
        trans_std = attrs.float('trans_std', 0)
        output_dim = attrs.int('output_dim', 0)
        part_size = attrs.int('part_size', 0)
        sample_per_part = attrs.int('sample_per_part', 1)
        pooled_size = attrs.int('pooled_size', 0)

        data = {
            'spatial_scale': spatial_scale,
            'mode': 'bilinear_deformable',
            'group_size': group_size,
            'output_dim': output_dim,
            'no_trans': no_trans,
            'trans_std': trans_std,
            'part_size': part_size,
            'spatial_bins_x': sample_per_part,
            'spatial_bins_y': sample_per_part,
            'pooled_width': pooled_size,
            'pooled_height': pooled_size,
        }

        # update the attributes of the node
        PSROIPoolingOp.update_node_stat(node, data)
        return __class__.enabled
Exemplo n.º 4
0
    def extract(cls, node):
        attrs = get_mxnet_layer_attrs(node.symbol_dict)
        spatial_scale = attrs.float('spatial_scale', None)
        group_size = attrs.int('group_size', 0)
        no_trans = attrs.bool('no_trans', False)
        trans_std = attrs.float('trans_std', 0)
        output_dim = attrs.int('output_dim', 0)
        part_size = attrs.int('part_size', 0)
        sample_per_part = attrs.int('sample_per_part', 1)
        pooled_size = attrs.int('pooled_size', 0)

        data = {
            'spatial_scale': spatial_scale,
            'mode': 'bilinear_deformable',
            'group_size': group_size,
            'output_dim': output_dim,
            'trans_std': trans_std,
            'part_size': part_size,
            'spatial_bins_x': sample_per_part,
            'spatial_bins_y': sample_per_part,
            'pooled_width': pooled_size,
            'pooled_height': pooled_size,
        }

        # update the attributes of the node
        if not node.graph.graph['cmd_params'].generate_experimental_IR_V10:
            data.update({'no_trans': no_trans})
            PSROIPoolingOp.update_node_stat(node, data)
        else:
            DeformablePSROIPoolingOp.update_node_stat(node, data)
        return cls.enabled
Exemplo n.º 5
0
    def extract(cls, node):
        proto_layer = node.pb
        param = proto_layer.psroi_pooling_param

        update_attrs = {
            'spatial_scale': param.spatial_scale,
            'output_dim': param.output_dim,
            'group_size': param.group_size,
        }

        mapping_rule = merge_attrs(param, update_attrs)

        mapping_rule.update(layout_attrs())

        # update the attributes of the node
        PSROIPoolingOp.update_node_stat(node, mapping_rule)
        return cls.enabled
Exemplo n.º 6
0
    def extract(cls, node):
        attrs = get_mxnet_layer_attrs(node.symbol_dict)

        spatial_scale = attrs.float("spatial_scale", None)
        pooled_size = attrs.int("pooled_size", None)
        output_dim = attrs.int("output_dim", None)
        group_size = attrs.int("group_size", 0)

        if group_size == 0:
            group_size = pooled_size

        data = {
            'spatial_scale': spatial_scale,
            'output_dim': output_dim,
            'group_size': group_size,
        }

        # update the attributes of the node
        PSROIPoolingOp.update_node_stat(node, data)
        return cls.enabled