Commit 60fb4cc3 authored by Paul's avatar Paul
Browse files

Preallocate vector

parent b28bd72d
...@@ -10,9 +10,10 @@ void expect_shape(migraph::shape expected, migraph::operation op, Ts... xs) ...@@ -10,9 +10,10 @@ void expect_shape(migraph::shape expected, migraph::operation op, Ts... xs)
{ {
migraph::program p; migraph::program p;
std::vector<migraph::shape> shapes{xs...}; std::vector<migraph::shape> shapes{xs...};
std::vector<migraph::instruction_ref> args; std::vector<migraph::instruction_ref> args(shapes.size());
for(auto&& s : shapes) std::transform(shapes.begin(), shapes.end(), args.begin(), [&](auto&& s) {
args.push_back(p.add_outline(s)); return p.add_outline(s);
});
p.add_instruction(op, args); p.add_instruction(op, args);
if(p.get_shape() != expected) if(p.get_shape() != expected)
{ {
...@@ -28,9 +29,10 @@ void throws_shape(migraph::operation op, Ts... xs) ...@@ -28,9 +29,10 @@ void throws_shape(migraph::operation op, Ts... xs)
{ {
migraph::program p; migraph::program p;
std::vector<migraph::shape> shapes{xs...}; std::vector<migraph::shape> shapes{xs...};
std::vector<migraph::instruction_ref> args; std::vector<migraph::instruction_ref> args(shapes.size());
for(auto&& s : shapes) std::transform(shapes.begin(), shapes.end(), args.begin(), [&](auto&& s) {
args.push_back(p.add_outline(s)); return p.add_outline(s);
});
bool thrown = test::throws([&] { p.add_instruction(op, args); }); bool thrown = test::throws([&] { p.add_instruction(op, args); });
if(not thrown) if(not thrown)
{ {
......
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