Commit 06a63ec1 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Fixed a bug in adjoint



We don't forward the buffer name properly and forget to handle Tdg and Sdg...

Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 086513da
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -721,11 +721,23 @@ void apply_adjoint(std::shared_ptr<CompositeInstruction> parent_kernel,
    }
    // Handles T and S gates, etc... => T -> Tdg
    else if (inst->name() == "T") {
      auto tdg = provider->createInstruction("Tdg", inst->bits());
      // Forward along the buffer name
      auto tdg = provider->createInstruction(
          "Tdg", {std::make_pair(inst->getBufferName(0), inst->bits()[0])});
      program->replaceInstruction(i, tdg);
    } else if (inst->name() == "S") {
      auto sdg = provider->createInstruction("Sdg", inst->bits());
      auto sdg = provider->createInstruction(
          "Sdg", {std::make_pair(inst->getBufferName(0), inst->bits()[0])});
      program->replaceInstruction(i, sdg);
    } else if (inst->name() == "Tdg") {
      // Forward along the buffer name
      auto t = provider->createInstruction(
          "T", {std::make_pair(inst->getBufferName(0), inst->bits()[0])});
      program->replaceInstruction(i, t);
    } else if (inst->name() == "Sdg") {
      auto s = provider->createInstruction(
          "S", {std::make_pair(inst->getBufferName(0), inst->bits()[0])});
      program->replaceInstruction(i, s);
    }
  }