Пример #1
0
 def extract(cls, node):
     attrs = {
         'op': __class__.op,
         'order': node.module.order,
     }
     Transpose.update_node_stat(node, attrs)
     return cls.enabled
Пример #2
0
 def extract(cls, node):
     # In case of undefined 'perm' attribute, Transpose operation in ONNX reverse the dimensions
     order = onnx_attr(node, 'perm', 'ints', default=None)
     attrs = {
         'order': int64_array(order) if order is not None else None,
         'reverse_order': order is None
     }
     Transpose.update_node_stat(node, attrs)
     return cls.enabled
Пример #3
0
    def replace_pattern(self, graph: Graph, match: [str, Node]):
        swapaxis = match['op']
        assert len(swapaxis.in_ports()) == 1
        assert swapaxis.has_and_set('order')
        order = swapaxis.order

        swapaxis.add_input_port(1)
        const = Const(graph, {'value': order, 'name': swapaxis.soft_get('name', swapaxis.id) + '/Order'}).create_node()
        const.out_port(0).connect(swapaxis.in_port(1))

        Transpose.update_node_stat(swapaxis, {'need_shape_inference': True})

        del swapaxis['order']
Пример #4
0
 def extract(cls, node):
     attrs = get_mxnet_layer_attrs(node.symbol_dict)
     order = list(attrs.tuple("axes", int, None))
     Transpose.update_node_stat(node, {'order': np.array(order, dtype=np.int32)})
     return cls.enabled
Пример #5
0
 def extract(cls, node):
     order = node.pb.permute_param.order
     Transpose.update_node_stat(node,
                                {'order': mo_array(order, dtype=np.int32)})
     return cls.enabled
Пример #6
0
 def extract(cls, node):
     Transpose.update_node_stat(node, {'order': None})
     return cls.enabled