This source file includes following definitions.
- deep_copy
#include "DeepCopy.h"
namespace Halide{
namespace Internal {
using std::map;
using std::pair;
using std::string;
using std::vector;
pair<vector<Function>, map<string, Function>> deep_copy(
const vector<Function> &outputs, const map<string, Function> &env) {
vector<Function> copy_outputs;
map<string, Function> copy_env;
map<Function, Function, Function::Compare> copied_map;
for (const auto &iter : env) {
copied_map[iter.second] = Function(iter.second.name());
}
for (const auto &iter : env) {
iter.second.deep_copy(copied_map[iter.second], copied_map);
}
for (auto &iter : copied_map) {
iter.second.substitute_calls(copied_map);
}
for (const auto &iter : copied_map) {
copy_env.emplace(iter.first.name(), iter.second);
}
for (const auto &func : outputs) {
const auto &iter = copied_map.find(func);
if (iter != copied_map.end()) {
debug(4) << "Adding deep-copied version to outputs: " << func.name() << "\n";
copy_outputs.push_back(iter->second);
} else {
debug(4) << "Adding original version to outputs: " << func.name() << "\n";
copy_outputs.push_back(func);
}
}
return { copy_outputs, copy_env };
}
}
}