Commit 60f75082 authored by Khalique's avatar Khalique
Browse files

combined variadic functions

parent 78ee6fbe
...@@ -72,9 +72,9 @@ struct onnx_parser ...@@ -72,9 +72,9 @@ struct onnx_parser
add_binary_op("Mul", op::mul{}); add_binary_op("Mul", op::mul{});
add_binary_op("Sub", op::sub{}); add_binary_op("Sub", op::sub{});
add_mem_op("Sum", &onnx_parser::parse_sum); add_variadic_op("Sum", op::add{});
add_mem_op("Max", &onnx_parser::parse_max); add_variadic_op("Max", op::max{});
add_mem_op("Min", &onnx_parser::parse_min); add_variadic_op("Min", op::min{});
add_mem_op("ImageScaler", &onnx_parser::parse_imagescaler); add_mem_op("ImageScaler", &onnx_parser::parse_imagescaler);
add_mem_op("LeakyRelu", &onnx_parser::parse_leaky_relu); add_mem_op("LeakyRelu", &onnx_parser::parse_leaky_relu);
...@@ -190,37 +190,18 @@ struct onnx_parser ...@@ -190,37 +190,18 @@ struct onnx_parser
}); });
} }
instruction_ref template <class T>
parse_sum(const std::string&, const attribute_map&, std::vector<instruction_ref> args) void
{ add_variadic_op(std::string name, T x)
return std::accumulate(std::next(args.begin()),
args.end(),
args.front(),
[this](instruction_ref a, instruction_ref b) {
return add_broadcastable_binary_op(a, b, op::add{});
});
}
instruction_ref
parse_max(const std::string&, const attribute_map&, std::vector<instruction_ref> args)
{ {
return std::accumulate(std::next(args.begin()), ops.emplace(name, [this, x](attribute_map, std::vector<instruction_ref> args) {
args.end(), return std::accumulate(std::next(args.begin()),
args.front(), args.end(),
[this](instruction_ref a, instruction_ref b) { args.front(),
return add_broadcastable_binary_op(a, b, op::max{}); [this, x](instruction_ref a, instruction_ref b) {
}); return add_broadcastable_binary_op(a, b, x);
} });
});
instruction_ref
parse_min(const std::string&, const attribute_map&, std::vector<instruction_ref> args)
{
return std::accumulate(std::next(args.begin()),
args.end(),
args.front(),
[this](instruction_ref a, instruction_ref b) {
return add_broadcastable_binary_op(a, b, op::min{});
});
} }
instruction_ref instruction_ref
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment