Ejemplo n.º 1
0
 def extract(cls, node):
     attrs = {
         'op': __class__.op,
         'dim': node.module.shape,
     }
     Reshape.update_node_stat(node, attrs)
     return cls.enabled
Ejemplo n.º 2
0
 def extract(cls, node):
     dim = onnx_attr(node, 'shape', 'ints', None)
     if dim is not None:
         dim = int64_array(dim)
         Reshape.update_node_stat(node, {'dim': dim})
     else:
         Reshape.update_node_stat(node)
     return cls.enabled
Ejemplo n.º 3
0
    def extract(cls, node):
        attrs = get_mxnet_layer_attrs(node.symbol_dict)
        dim = attrs.tuple("shape", int, None)
        reverse = attrs.bool("reverse", False)
        update_attrs = {
            'dim': int64_array(dim),
            'reverse': reverse
        }
        for d in dim:
            if d in [-2, -3, -4] or reverse:
                MXReshape.update_node_stat(node, update_attrs)
                return cls.enabled

        # update the attributes of the node
        Reshape.update_node_stat(node, update_attrs)
        return cls.enabled
Ejemplo n.º 4
0
    def extract(cls, node):
        param = node.pb.reshape_param

        if param.axis != 0:
            log.error(
                'The operation "Reshape" has attribute "axis" with unsupported value "{}"'
                .format(param['axis']))
            return False

        if param.num_axes != -1:
            log.error(
                'The operation "Reshape" has attribute "num_axes" with unsupported value "{}"'
                .format(param['num_axes']))
            return False

        Reshape.update_node_stat(node, {
            'dim': list(param.shape.dim),
        })
        return cls.enabled
Ejemplo n.º 5
0
 def extract(cls, node: Node):
     Reshape.update_node_stat(node, {'special_zero': False})
     return cls.enabled