Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

Fusing Conv and Relu layer

mohan__deepa
Beginner
959 Views

Hi I am trying to fuse convolution and relu layer, but am running into issues. I think it is because of the way in which I am giving the apply_pattern. Could you kindly help fix the issue? I am doing this on a Resnet50 tensorflow .pb graph

I did this but I can see that this is not being matched as a proper subgraph in the main graph. In the pattern_match function, I can see matcher has an empty list

matcher = ism.MultiDiGraphMatcher(graph, subgraph, node_match, edge_match)
def convert_conv_relu_to_convrelu(graph: nx.MultiDiGraph):
    log.debug("Deepa")
    apply_pattern(
        graph,
        nodes=[
            ('input', dict(kind='data')),
            ('weights', dict(kind='data')),
            ('bias', dict(kind='data')),
            ('convout', dict(kind='data')),
            ('output', dict(kind='data')),
            ('conv', dict(kind='op', op='Conv2D')),
            ('relu', dict(kind='op', op='Relu'))
        ],
        edges=[
            ('weights', 'conv', {'in': 1}),
            ('bias','conv',{'in': 2}),
            ('input', 'conv', {'in': 0}),
            ('conv', 'convout'),
            ('convout', 'relu'),
            ('relu', 'output'),
        ],
        action=conv_relu_to_convrelu_action,
        node_attrs=['kind', 'op'],
        edge_attrs=['in'],
    )

 

0 Kudos
1 Reply
Zhen_Z_Intel
Employee
959 Views

Hello deepa,

May I know your usage of OpenVINO? The conv & relu fusion can be implemented by inference engine. For instance, on CPU, the MKLDNNPlugin will call append_eltwise function to fuse conv & relu.

Best regards,
Fiona

0 Kudos
Reply