Commit 5cfd2553 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Fixed a bug in SingleQubitGateMerging pass



Must stop when seeing a non-unitary gate (reset) - throwing exception when computing the total unitary matrix

Comment out debug logging.

Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent f45c107c
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -74,10 +74,10 @@ antlrcpp::Any qasm3_visitor::visitAliasStatement(
                builder.create<mlir::quantum::QaliasArrayAllocOp>(
                    location, array_type, integer_attr, str_attr);
            // Add the alias register to the symbol table
            std::cout << "Adding symbol 1\n";
            // std::cout << "Adding symbol 1\n";
            symbol_table.add_symbol(in_aliasName, alias_allocation,
                                    {std::to_string(n_expressions)});
        std::cout << "made it here\n";
            // std::cout << "made it here\n";
            auto counter = 0;
            for (auto expr : expressions) {
              // GOAL HERE IS TO ASSIGN extracted qubits from original array
@@ -176,11 +176,10 @@ antlrcpp::Any qasm3_visitor::visitAliasStatement(
            };
            const auto new_size =
                slice_size_calc(orig_size, range_start, range_step, range_stop);
                            std::cout << "Adding symbol 2 " << in_aliasName << "\n";
            // std::cout << "Adding symbol 2 " << in_aliasName << "\n";

            symbol_table.add_symbol(in_aliasName, array_slice,
                                    {std::to_string(new_size)});
                                    std::cout << "HI\n";
          } else {
            printErrorMessage("Could not parse the alias statement.",
                              in_indexIdentifierContext);
@@ -232,7 +231,8 @@ antlrcpp::Any qasm3_visitor::visitAliasStatement(
              builder.create<mlir::quantum::ArrayConcatOp>(
                  location, array_type, first_reg_symbol, second_reg_symbol);
          const auto new_size = first_reg_size + second_reg_size;
          // std::cout << "Concatenate " << lhs_temp_var << "[" << first_reg_size
          // std::cout << "Concatenate " << lhs_temp_var << "[" <<
          // first_reg_size
          //           << "] with " << rhs_temp_var << "[" << second_reg_size
          //           << "] -> " << in_aliasName << "[" << new_size << "].\n";

+7 −1
Original line number Diff line number Diff line
@@ -84,7 +84,13 @@ void SingleQubitGateMergingPass::runOnOperation() {
        auto user = *return_value.user_begin();
        if (auto next_inst =
                dyn_cast_or_null<mlir::quantum::ValueSemanticsInstOp>(user)) {
          // Only allow unitary gates...
          if (next_inst.name() == "reset" || next_inst.name() == "mz") {
            break;
          } else {
            // Continue the search
            current_op = next_inst;
          }
        } else {
          break;
        }