diff --git a/inference-engine/thirdparty/mkl-dnn b/inference-engine/thirdparty/mkl-dnn index 0813c00df7558b..fdf537051e8d30 160000 --- a/inference-engine/thirdparty/mkl-dnn +++ b/inference-engine/thirdparty/mkl-dnn @@ -1 +1 @@ -Subproject commit 0813c00df7558bc9b858d3a73c725bab2ce1b1eb +Subproject commit fdf537051e8d30adcf56f0a56afa3cc3abddc7a4 diff --git a/ngraph/frontend/paddlepaddle/src/op/scale.cpp b/ngraph/frontend/paddlepaddle/src/op/scale.cpp index 6afffd1141ae88..24493ada2e1977 100644 --- a/ngraph/frontend/paddlepaddle/src/op/scale.cpp +++ b/ngraph/frontend/paddlepaddle/src/op/scale.cpp @@ -25,7 +25,15 @@ namespace op { NamedOutputs scale (const NodeContext& node) { auto data = node.get_ng_input("X"); auto scale = ngraph::opset6::Constant::create(ngraph::element::f32, {1}, {node.get_attribute("scale")}); - return node.default_single_output_mapping({std::make_shared(data, scale)}, {"Out"}); + auto bias = ngraph::opset6::Constant::create(ngraph::element::f32, {1}, {node.get_attribute("bias")}); + auto bias_after_scale = node.get_attribute("bias_after_scale"); + if(!bias_after_scale) { + auto node_add = std::make_shared(data, bias); + return node.default_single_output_mapping({std::make_shared(node_add, scale)}, {"Out"}); + } else { + auto node_multiply = std::make_shared(data, scale); + return node.default_single_output_mapping({std::make_shared(node_multiply, bias)}, {"Out"}); + } } }}}} \ No newline at end of file diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_reshape.py b/ngraph/test/files/paddlepaddle/gen_scripts/generate_reshape.py new file mode 100644 index 00000000000000..d3fdab7351a1af --- /dev/null +++ b/ngraph/test/files/paddlepaddle/gen_scripts/generate_reshape.py @@ -0,0 +1,43 @@ +# +# reshape paddle model generator +# +import numpy as np +from save_model import saveModel + +data_type = 'float32' + +def reshape(name : str, x, out_shape): + import paddle as pdpd + pdpd.enable_static() + + with pdpd.static.program_guard(pdpd.static.Program(), pdpd.static.Program()): + node_x = pdpd.static.data(name='x', shape=x.shape, dtype=data_type) + out = pdpd.fluid.layers.reshape(x=node_x, shape=out_shape) + + cpu = pdpd.static.cpu_places(1) + exe = pdpd.static.Executor(cpu[0]) + # startup program will call initializer to initialize the parameters. + exe.run(pdpd.static.default_startup_program()) + + outs = exe.run( + feed={'x': x}, + fetch_list=[out]) + + saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]]) + + return outs[0] + +def main(): + data = np.array([[[ + [1, 2, 3, 4], + [5, 6, 7, 8], + [9, 10, 11, 12], + [13, 14, 15, 16], + ]]], dtype=np.float32) + out_shape = [1, 1, 2, 8] + reshape("reshape", data, out_shape) + + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_scale.py b/ngraph/test/files/paddlepaddle/gen_scripts/generate_scale.py new file mode 100644 index 00000000000000..d232b70becdb2a --- /dev/null +++ b/ngraph/test/files/paddlepaddle/gen_scripts/generate_scale.py @@ -0,0 +1,48 @@ +# +# pool2d paddle model generator +# +import numpy as np +from save_model import saveModel + +data_type = 'float32' + +def pdpd_scale(name : str, x, scale, bias, attrs : dict): + import paddle as pdpd + pdpd.enable_static() + + with pdpd.static.program_guard(pdpd.static.Program(), pdpd.static.Program()): + node_x = pdpd.static.data(name='x', shape=x.shape, dtype='float32') + out = pdpd.scale(x=node_x, scale=scale, bias=bias, + bias_after_scale=attrs['bias_after_scale']) + + cpu = pdpd.static.cpu_places(1) + exe = pdpd.static.Executor(cpu[0]) + # startup program will call initializer to initialize the parameters. + exe.run(pdpd.static.default_startup_program()) + + outs = exe.run( + feed={'x': x}, + fetch_list=[out]) + + saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]]) + + return outs[0] + + +def main(): + scale = 2.0 + bias = 1.0 + data = np.random.random([2, 3]).astype("float32") + pdpd_attrs = { + 'bias_after_scale' : True, + } + pdpd_scale("scale_test1", data, scale, bias, pdpd_attrs) + + pdpd_attrs = { + 'bias_after_scale' : False, + } + pdpd_scale("scale_test2", data, scale, bias, pdpd_attrs) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/ngraph/test/files/paddlepaddle/models/models.csv b/ngraph/test/files/paddlepaddle/models/models.csv index 1e62e961054789..dae30db6ee8394 100644 --- a/ngraph/test/files/paddlepaddle/models/models.csv +++ b/ngraph/test/files/paddlepaddle/models/models.csv @@ -13,3 +13,6 @@ maxPool_test5, #maxPool_test6, avgAdaptivePool2D_test1, #maxAdaptivePool2D_test1, +scale_test1, +scale_test2, +reshape,