Commit d3115a09 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

Adding load/persist args to DWQMICompiler

parent 4d522e1f
......@@ -115,16 +115,31 @@ std::shared_ptr<IR> DWQMICompiler::compile(const std::string& src,
}
}
Embedding embedding;
// Get an embedding algorithm to execute
if (!runtimeOptions->exists("dwave-embedding")) {
if (!runtimeOptions->exists("dwave-embedding")
&& !runtimeOptions->exists("dwave-load-embedding")) {
// For now, this is an error
XACCError("You must specify an embedding algorithm");
XACCError("You must specify an embedding algorithm or embedding file.");
}
auto algoStr = (*runtimeOptions)["dwave-embedding"];
auto embeddingAlgorithm = EmbeddingAlgorithmRegistry::instance()->create(algoStr);
// Compute the minor graph embedding
auto embedding = embeddingAlgorithm->embed(problemGraph, hardwareGraph);
if (runtimeOptions->exists("dwave-load-embedding")) {
std::ifstream ifs((*runtimeOptions)["dwave-load-embedding"]);
embedding.load(ifs);
} else {
auto algoStr = (*runtimeOptions)["dwave-embedding"];
auto embeddingAlgorithm =
EmbeddingAlgorithmRegistry::instance()->create(algoStr);
// Compute the minor graph embedding
embedding = embeddingAlgorithm->embed(problemGraph, hardwareGraph);
if (runtimeOptions->exists("dwave-persist-embedding")) {
auto fileName = (*runtimeOptions)["dwave-persist-embedding"];
std::ofstream ofs(fileName);
embedding.persist(ofs);
}
}
// Add the embedding to the AcceleratorBuffer
aqcBuffer->setEmbedding(embedding);
......
......@@ -99,7 +99,9 @@ public:
"Provide the name of the Embedding Algorithm to use during compilation.")(
"dwave-parameter-setter", value<std::string>(),
"Provide the name of the "
"ParameterSetter to map logical parameters to physical parameters.");
"ParameterSetter to map logical parameters to physical parameters.")
("dwave-load-embedding", value<std::string>(), "Use the embedding in the given file.")
("dwave-persist-embedding", value<std::string>(), "Persist the computed embedding to the given file name.");
return desc;
}
......
Supports Markdown
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