Unverified Commit 096decdc authored by Mccaskey, Alex's avatar Mccaskey, Alex Committed by GitHub
Browse files

Merge pull request #458 from simon-ty/210603-2-rzz-ir

RZZ gate for XASM and XACC IR
parents 7e3f7cab 3bfc65e2
Pipeline #152496 passed with stage
in 22 minutes and 5 seconds
......@@ -69,7 +69,10 @@ public:
auto ifstmt = std::make_shared<xacc::quantum::IfStmt>();
auto reset = std::make_shared<xacc::quantum::Reset>();
auto scheduler = std::make_shared<xacc::quantum::PulseScheduler>();
auto rzz= std::make_shared<xacc::quantum::RZZ>();
context.RegisterService<xacc::Scheduler>(scheduler);
context.RegisterService<xacc::Instruction>(rzz);
context.RegisterService<xacc::Instruction>(h);
context.RegisterService<xacc::Instruction>(cn);
......
......@@ -536,6 +536,24 @@ public:
DEFINE_VISITABLE()
};
class RZZ : public Gate {
public:
RZZ() : Gate("RZZ",std::vector<InstructionParameter>{0.0}) {}
RZZ(std::size_t controlQubit, std::size_t targetQubit)
: Gate("RZZ", std::vector<std::size_t>{controlQubit, targetQubit},
std::vector<InstructionParameter>{0.0}) {}
RZZ(std::vector<std::size_t> qbits)
: Gate("RZZ", qbits, std::vector<InstructionParameter>{0.0}) {}
RZZ(std::size_t controlQubit, std::size_t targetQubit, double theta)
: Gate("RZZ", std::vector<std::size_t>{controlQubit, targetQubit},
std::vector<InstructionParameter>{theta}) {}
const int nRequiredBits() const override { return 2; }
DEFINE_CLONE(RZZ)
DEFINE_VISITABLE()
};
} // namespace quantum
} // namespace xacc
#endif
......@@ -48,8 +48,10 @@ class AllGateVisitor : public BaseInstructionVisitor,
public InstructionVisitor<U1>,
public InstructionVisitor<IfStmt>,
public InstructionVisitor<XY>,
public InstructionVisitor<Reset> {
public InstructionVisitor<Reset>,
public InstructionVisitor<RZZ> {
public:
void visit(RZZ &rzz) override {}
void visit(Hadamard &h) override {}
void visit(CNOT &h) override {}
void visit(Rz &h) override {}
......
......@@ -18,6 +18,23 @@
#include "Utils.hpp"
#include "Circuit.hpp"
TEST(XASMCompilerTester, checkRZZ) {
auto compiler = xacc::getCompiler("xasm");
auto IR =
compiler->compile(R"(
__qpu__ void rzz_test(qbit q, double theta) {
H(q[0]);
RZZ(q[0], q[1], theta);
CX(q[0], q[1]);
}
)");
auto kernel = IR->getComposites()[0];
std::cout << "HELLO: " << kernel->toString() << "\n";
std::cout << kernel->operator()({2.4})->toString() << "\n";
}
TEST (XASMCompilerTester, checkQcorIssue23) {
auto compiler = xacc::getCompiler("xasm");
auto IR = compiler->compile(R"(__qpu__ void rotate(qbit q, double x) {
......
Markdown is supported
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