Commit 2603bc3b authored by Zachary Parks's avatar Zachary Parks
Browse files

Changing CircuitOptimizer to handle variable InstructionParameters



Signed-off-by: default avatarZachary Parks <1zp@ornl.gov>
parent 2f9128d2
...@@ -49,14 +49,14 @@ std::shared_ptr<IR> CircuitOptimizer::transform(std::shared_ptr<IR> ir) { ...@@ -49,14 +49,14 @@ std::shared_ptr<IR> CircuitOptimizer::transform(std::shared_ptr<IR> ir) {
auto inst = gateFunction->getInstruction(i); auto inst = gateFunction->getInstruction(i);
if (isRotation(inst->name())) { if (isRotation(inst->name())) {
auto param = inst->getParameter(0); auto param = inst->getParameter(0);
double val = ipToDouble(param); if (!param.isVariable()) {
double val = ipToDouble(param);
if (std::fabs(val) < 1e-12) { if (std::fabs(val) < 1e-12) {
inst->disable(); inst->disable();
}
} }
} }
} }
// Remove all CNOT(p,q) CNOT(p,q) Pairs // Remove all CNOT(p,q) CNOT(p,q) Pairs
while (true) { while (true) {
bool modified = false; bool modified = false;
...@@ -78,7 +78,6 @@ std::shared_ptr<IR> CircuitOptimizer::transform(std::shared_ptr<IR> ir) { ...@@ -78,7 +78,6 @@ std::shared_ptr<IR> CircuitOptimizer::transform(std::shared_ptr<IR> ir) {
} }
} }
} }
if (!modified) if (!modified)
break; break;
} }
...@@ -94,7 +93,6 @@ std::shared_ptr<IR> CircuitOptimizer::transform(std::shared_ptr<IR> ir) { ...@@ -94,7 +93,6 @@ std::shared_ptr<IR> CircuitOptimizer::transform(std::shared_ptr<IR> ir) {
auto adj = graphView.getNeighborList(node.id()); auto adj = graphView.getNeighborList(node.id());
std::vector<int> nAsVec(adj.begin(), adj.end()); std::vector<int> nAsVec(adj.begin(), adj.end());
if (adj.size() == 1) { if (adj.size() == 1) {
auto nextNode = graphView.getVertex(nAsVec[0]); auto nextNode = graphView.getVertex(nAsVec[0]);
if (node.name() == "H" && nextNode.name() == "H") { if (node.name() == "H" && nextNode.name() == "H") {
...@@ -125,7 +123,6 @@ std::shared_ptr<IR> CircuitOptimizer::transform(std::shared_ptr<IR> ir) { ...@@ -125,7 +123,6 @@ std::shared_ptr<IR> CircuitOptimizer::transform(std::shared_ptr<IR> ir) {
} }
} }
} }
return ir; return ir;
} }
......
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