Commit e91c8fc2 authored by Paul's avatar Paul
Browse files

Use transform

parent 4cfc964e
...@@ -119,7 +119,7 @@ struct compile_plan ...@@ -119,7 +119,7 @@ struct compile_plan
{ {
if(config.has_value()) if(config.has_value())
{ {
const auto& problem = config.value().problem; const auto& problem = config->problem;
if(auto sol = pc.get(preop.name(), problem)) if(auto sol = pc.get(preop.name(), problem))
{ {
auto solution = sol.value(); auto solution = sol.value();
...@@ -134,7 +134,7 @@ struct compile_plan ...@@ -134,7 +134,7 @@ struct compile_plan
else else
{ {
pc.mark(preop.name(), problem); pc.mark(preop.name(), problem);
const auto& solutions = config.value().solutions; const auto& solutions = config->solutions;
results.resize(solutions.size()); results.resize(solutions.size());
for(auto i : range(solutions.size())) for(auto i : range(solutions.size()))
{ {
...@@ -163,13 +163,11 @@ struct compile_plan ...@@ -163,13 +163,11 @@ struct compile_plan
<< std::endl; << std::endl;
std::vector<double> times; std::vector<double> times;
times.reserve(results.size()); times.reserve(results.size());
for(const auto& cr : results) std::transform(results.begin(), results.end(), std::back_inserter(times), [&](const auto& cr) {
{ return time_op(*ctx, cr.replace.code_object, to_shapes(cr.ins->inputs()), 20).first;
times.push_back( });
time_op(*ctx, cr.replace.code_object, to_shapes(cr.ins->inputs()), 20).first);
}
auto i = std::distance(times.begin(), std::min_element(times.begin(), times.end())); auto i = std::distance(times.begin(), std::min_element(times.begin(), times.end()));
pc.insert(preop.name(), config.value().problem, config.value().solutions.at(i)); pc.insert(preop.name(), config->problem, config->solutions.at(i));
return results[i]; return results[i];
} }
void replace(module& m, problem_cache& pc) const void replace(module& m, problem_cache& pc) const
......
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