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

fix bug with arrayref from init list

parent ed06b06f
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -13,9 +13,6 @@ __qpu__ void qaoa_ansatz(qreg q, int n_steps, std::vector<double> gamma,
    H(q[0]);
  }

  // auto cost_ham_ptr = createObservable(cost_ham_str);
  // auto& cost_ham = *cost_ham_ptr.get();

  // Get all non-identity hamiltonian terms
  // for the following exp(H_i) trotterization
  auto cost_terms = cost_ham.getNonIdentitySubTerms();
+1 −1
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ class qasm3_visitor : public qasm3::qasm3BaseVisitor {
  // corresponding AllocOp of a given 1d shape.
  mlir::Value allocate_1d_memory(mlir::Location location, int64_t shape,
                                 mlir::Type type) {
    llvm::ArrayRef<int64_t> shaperef{shape};
    llvm::ArrayRef<int64_t> shaperef(shape);

    auto mem_type = mlir::MemRefType::get(shaperef, type);
    mlir::Value allocation = builder.create<mlir::AllocaOp>(location, mem_type);
+1 −1
Original line number Diff line number Diff line
@@ -973,7 +973,7 @@ antlrcpp::Any qasm3_expression_generator::visitExpressionTerminator(
              auto int_value_type = builder.getIntegerType(bit_width);
              auto init_attr = mlir::IntegerAttr::get(int_value_type, 0);

              llvm::ArrayRef<int64_t> shaperef{1};
              llvm::ArrayRef<int64_t> shaperef(1);
              auto mem_type = mlir::MemRefType::get(shaperef, int_value_type);
              mlir::Value init_allocation =
                  builder.create<mlir::AllocaOp>(location, mem_type);
+1 −1
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ mlir::Type convertQasm3Type(qasm3::qasm3Parser::ClassicalTypeContext* ctx,
    auto bit_size = symbol_table.evaluate_constant_integer_expression(idx_str);

    mlir::Type mlir_type;
    llvm::ArrayRef<int64_t> shaperef{bit_size};
    llvm::ArrayRef<int64_t> shaperef(bit_size);
    mlir_type = mlir::MemRefType::get(shaperef, result_type);
    return mlir_type;
  } else if (type == "bool") {
+2 −1
Original line number Diff line number Diff line
@@ -385,7 +385,7 @@ antlrcpp::Any qasm3_visitor::visitBitDeclaration(
  auto location = get_location(builder, file_name, context);

  // First case is indexIdentifierList, no initialization
  std::size_t size = 1;
  int64_t size = 1;
  if (auto index_ident_list = context->indexIdentifierList()) {
    for (auto idx_identifier : index_ident_list->indexIdentifier()) {
      auto var_name = idx_identifier->Identifier()->getText();
@@ -412,6 +412,7 @@ antlrcpp::Any qasm3_visitor::visitBitDeclaration(
        builder.create<mlir::StoreOp>(location, init_values[0], allocation);
        symbol_table.add_symbol(var_name, allocation);
      } else {

        auto allocation = allocate_1d_memory_and_initialize(
            location, size, builder.getI1Type(), init_values,
            llvm::makeArrayRef(init_indices));
Loading