remove paddle mul op converter (#8190)
This commit is contained in:
parent
9731d9a295
commit
b2523b1c01
@ -1,45 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <ngraph/opsets/opset6.hpp>
|
||||
#include <node_context.hpp>
|
||||
|
||||
namespace ngraph {
|
||||
namespace frontend {
|
||||
namespace pdpd {
|
||||
namespace op {
|
||||
NamedOutputs mul(const NodeContext& node) {
|
||||
auto x = node.get_ng_input("X");
|
||||
auto y = node.get_ng_input("Y");
|
||||
PDPD_OP_VALIDATION_CHECK(node, x.get_partial_shape().rank().is_static(), "matmul: X rank must be static!");
|
||||
int64_t x_rank = x.get_partial_shape().rank().get_length();
|
||||
PDPD_OP_VALIDATION_CHECK(node,
|
||||
y.get_partial_shape().rank().is_static() && y.get_partial_shape().rank().get_length() == 2,
|
||||
"matmul: Y rank must be static, and 2!");
|
||||
if (x_rank > 2) {
|
||||
auto shape = std::make_shared<ngraph::opset6::ShapeOf>(x);
|
||||
int64_t x_num_col_dims = node.get_attribute<int32_t>("x_num_col_dims");
|
||||
auto axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, {0});
|
||||
auto split_lengths =
|
||||
ngraph::opset6::Constant::create(ngraph::element::i64, {2}, {x_num_col_dims, x_rank - x_num_col_dims});
|
||||
auto split = std::make_shared<ngraph::opset6::VariadicSplit>(shape, axis, split_lengths);
|
||||
auto f_dim_red_axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, {0});
|
||||
auto first_dim_reduce = std::make_shared<ngraph::opset6::ReduceProd>(split->output(0), f_dim_red_axis);
|
||||
auto f_dim_shape = ngraph::opset6::Constant::create(ngraph::element::i64, {1}, {1});
|
||||
auto first_dim = std::make_shared<ngraph::opset6::Reshape>(first_dim_reduce, f_dim_shape, false);
|
||||
auto s_dim_red_axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, {0});
|
||||
auto second_dim_reduce = std::make_shared<ngraph::opset6::ReduceProd>(split->output(1), s_dim_red_axis);
|
||||
auto s_dim_shape = ngraph::opset6::Constant::create(ngraph::element::i64, {1}, {1});
|
||||
auto second_dim = std::make_shared<ngraph::opset6::Reshape>(second_dim_reduce, s_dim_shape, false);
|
||||
auto out_shape = std::make_shared<ngraph::opset6::Concat>(ngraph::NodeVector{first_dim, second_dim}, 0);
|
||||
auto x_reshaped = std::make_shared<ngraph::opset6::Reshape>(x, out_shape, false);
|
||||
return node.default_single_output_mapping({std::make_shared<ngraph::opset6::MatMul>(x_reshaped, y)}, {"Out"});
|
||||
}
|
||||
return node.default_single_output_mapping({std::make_shared<ngraph::opset6::MatMul>(x, y)}, {"Out"});
|
||||
}
|
||||
|
||||
} // namespace op
|
||||
} // namespace pdpd
|
||||
} // namespace frontend
|
||||
} // namespace ngraph
|
@ -47,7 +47,6 @@ OP_CONVERTER(log);
|
||||
OP_CONVERTER(logical_not);
|
||||
OP_CONVERTER(matmul);
|
||||
OP_CONVERTER(matmul_v2);
|
||||
OP_CONVERTER(mul);
|
||||
OP_CONVERTER(matrix_nms);
|
||||
OP_CONVERTER(multiclass_nms);
|
||||
OP_CONVERTER(nearest_interp_v2);
|
||||
@ -127,7 +126,6 @@ std::map<std::string, CreatorFunction> get_supported_ops() {
|
||||
{"matmul", op::matmul},
|
||||
{"matmul_v2", op::matmul_v2},
|
||||
{"max_pool2d_with_index", op::pool2d},
|
||||
{"mul", op::mul},
|
||||
{"matrix_nms", op::matrix_nms},
|
||||
{"multiclass_nms3", op::multiclass_nms},
|
||||
{"nearest_interp_v2", op::nearest_interp_v2},
|
||||
@ -159,4 +157,4 @@ std::map<std::string, CreatorFunction> get_supported_ops() {
|
||||
|
||||
} // namespace pdpd
|
||||
} // namespace frontend
|
||||
} // namespace ngraph
|
||||
} // namespace ngraph
|
||||
|
@ -158,7 +158,6 @@ static const std::vector<std::string> models{std::string("argmax"),
|
||||
std::string("maxPool_test7"),
|
||||
std::string("maxPool_test8"),
|
||||
std::string("maxPool_test9"),
|
||||
std::string("mul_fp32"),
|
||||
std::string("nearest_downsample_false_0"),
|
||||
std::string("nearest_downsample_false_1"),
|
||||
std::string("nearest_upsample_false_0"),
|
||||
|
@ -2,30 +2,6 @@ import numpy as np
|
||||
from save_model import saveModel
|
||||
import sys
|
||||
|
||||
|
||||
def pdpd_mul(name, x1, x2):
|
||||
import paddle as pdpd
|
||||
|
||||
pdpd.enable_static()
|
||||
with pdpd.static.program_guard(pdpd.static.Program(), pdpd.static.Program()):
|
||||
node_x1 = pdpd.static.data(name='x1', shape=x1.shape, dtype=x1.dtype)
|
||||
node_x2 = pdpd.static.data(name='x2', shape=x2.shape, dtype=x2.dtype)
|
||||
bmm_node = pdpd.fluid.layers.mul(node_x1, node_x2)
|
||||
result = pdpd.static.nn.batch_norm(bmm_node, use_global_stats=True)
|
||||
|
||||
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={'x1': x1, 'x2': x2},
|
||||
fetch_list=[result])
|
||||
saveModel(name, exe, feedkeys=['x1', 'x2'], fetchlist=[result], inputs=[x1, x2], outputs=[outs[0]], target_dir=sys.argv[1])
|
||||
|
||||
return outs[0]
|
||||
|
||||
|
||||
def pdpd_matmul(name, x1, x2, x_transpose=False, y_transpose=False):
|
||||
import paddle as pdpd
|
||||
|
||||
@ -68,8 +44,6 @@ if __name__ == "__main__":
|
||||
input_2x3 = np.array([[1, 2, 3],
|
||||
[4, 5, 6]]).astype(np.float32)
|
||||
|
||||
pdpd_result = pdpd_mul("mul_fp32", input_2x5, input_5x3)
|
||||
|
||||
pdpd_matmul("matmul_xt", input_2x5, input_2x3, x_transpose=True, y_transpose=False)
|
||||
pdpd_matmul("matmul_yt", input_2x3, input_5x3, x_transpose=False, y_transpose=True)
|
||||
pdpd_matmul("matmul_xt_yt", input_2x5, input_5x2, x_transpose=True, y_transpose=True)
|
||||
|
Loading…
Reference in New Issue
Block a user