Replies: 2 comments
-
|
Following script reproduce the issue, you can see the fuse will fail , check the "cnn_exec_graph.xml" with netron.app from openvino.inference_engine import IECore
import ngraph as ng
import numpy as np
import os
def run_cnn(func, input:dict):
ie_network = ng.function_to_cnn(func)
ie = IECore()
device = "CPU"
ie.set_config({"PERF_COUNT":"YES"}, device)
executable_network = ie.load_network(ie_network, device)
output = executable_network.infer(input)
ei = executable_network.get_exec_graph_info()
ei.serialize("cnn_exec_graph.xml")
return output
def test_elewise2():
input_shape = [10,5,32,32]
input_shape2 = [1,7,1,1]
x = ng.parameter(shape=input_shape, dtype=np.float32, name="x")
x2 = ng.parameter(shape=input_shape2, dtype=np.float32, name="x2")
conv_w = ng.constant(np.random.rand(7,5,3,3), dtype=np.float32, name="conv_w")
padding_begin = padding_end = [0, 0]
strides = [1, 1]
dilations = [1, 1]
conv_node = ng.convolution(x, conv_w, strides, padding_begin, padding_end, dilations)
c1 = ng.constant(3, dtype=np.float32, name="c1")
c2 = ng.constant(np.random.rand(*input_shape2), dtype=np.float32, name="c2")
add3 = ng.add(conv_node, c1)
z = ng.multiply(conv_node, c2) # fuse will not happen if we change c2 into x2
f = ng.Function(z, [x, x2], "TestFunction")
np.random.seed(42)
data_x = np.random.rand(*input_shape).astype(np.float32)
data_x2 = np.random.rand(*input_shape2).astype(np.float32)
result = run_cnn(f, {'x': data_x, 'x2': data_x2})
test_elewise2()Also if we change c2'shape into (1,7,30,30), it can not be fused. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
clDNN code generator outputs OpenCL C-style source code which is much powerful language than Xbak jit used in MKLDNN, so it can fuse much more cases than MKLDNN can |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
'
x1=conv(x0)
x2=x1 * (x1+3)
'
ZhnagYi 发现 clDNN plugin能够把 x1*(x1+3)这样的计算fuse到conv中,而mkldnn则不能, WHY?
Beta Was this translation helpful? Give feedback.
All reactions