Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
a30cc096
Commit
a30cc096
authored
Jun 12, 2020
by
Mccaskey, Alex
Browse files
fixing bug in staq where U angles were hard coded to 0
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
b392cdf7
Pipeline
#106664
passed with stage
in 9 minutes and 41 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
quantum/plugins/staq/compiler/staq_compiler.cpp
View file @
a30cc096
...
...
@@ -217,6 +217,7 @@ std::shared_ptr<IR> StaqCompiler::compile(const std::string &src,
transformations
::
inline_ast
(
*
prog
,
{
false
,
transformations
::
default_overrides
,
"anc"
});
// std::cout <<"PROG: " << *prog << "\n";
// Visit Program to find out how many qreg there are and
// use that to build up openqasm xacc function prototype
...
...
@@ -262,7 +263,7 @@ std::shared_ptr<IR> StaqCompiler::compile(const std::string &src,
xx
<<
") {
\n
"
<<
translate
.
ss
.
str
()
<<
"}"
;
kernel
=
xx
.
str
();
}
//
std::cout << "\n\nFinal:\n" << kernel << "\n";
// std::cout << "\n\nFinal:\n" << kernel << "\n";
return
xasm
->
compile
(
kernel
,
acc
);
}
...
...
quantum/plugins/staq/compiler/tests/StaqCompilerTester.in.cpp
View file @
a30cc096
...
...
@@ -15,6 +15,28 @@
#include
"xacc.hpp"
#include
"xacc_service.hpp"
TEST
(
StaqCompilerTester
,
checkCphase
)
{
auto
src
=
R"#(
qreg q[4];
x q[3];
h q[0];
h q[1];
h q[2];
cu1(0.785398) q[0], q[3];
creg c[3];
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];)#"
;
auto
compiler
=
xacc
::
getCompiler
(
"staq"
);
auto
IR
=
compiler
->
compile
(
src
);
auto
hello
=
IR
->
getComposites
()[
0
];
std
::
cout
<<
"HELLO:
\n
"
<<
hello
->
toString
()
<<
"
\n
"
;
}
TEST
(
StaqCompilerTester
,
checkSimple
)
{
auto
compiler
=
xacc
::
getCompiler
(
"staq"
);
auto
IR
=
compiler
->
compile
(
R"(
...
...
quantum/plugins/staq/utils/staq_visitors.hpp
View file @
a30cc096
...
...
@@ -26,11 +26,11 @@ namespace xacc {
namespace
internal_staq
{
static
const
std
::
map
<
std
::
string
,
std
::
string
>
staq_to_xacc
{
// "u3", "u2", "u1", "ccx", cu1, cu3
{
"cx"
,
"CX"
},
{
"id"
,
"I"
},
{
"x"
,
"X"
},
{
"y"
,
"Y"
},
{
"z"
,
"Z"
},
{
"h"
,
"H"
},
{
"s"
,
"S"
},
{
"sdg"
,
"Sdg"
},
{
"t"
,
"T"
},
{
"tdg"
,
"Tdg"
},
{
"rx"
,
"Rx"
},
{
"ry"
,
"Ry"
},
{
"rz"
,
"Rz"
},
{
"cz"
,
"CZ"
},
{
"cy"
,
"CY"
},
{
"swap"
,
"Swap"
},
{
"ch"
,
"CH"
},
{
"crz"
,
"CRZ"
}};
{
"cx"
,
"CX"
},
{
"id"
,
"I"
},
{
"x"
,
"X"
},
{
"y"
,
"Y"
},
{
"z"
,
"Z"
},
{
"h"
,
"H"
},
{
"s"
,
"S"
},
{
"sdg"
,
"Sdg"
},
{
"t"
,
"T"
},
{
"tdg"
,
"Tdg"
},
{
"rx"
,
"Rx"
},
{
"ry"
,
"Ry"
},
{
"rz"
,
"Rz"
},
{
"cz"
,
"CZ"
},
{
"cy"
,
"CY"
},
{
"swap"
,
"Swap"
},
{
"ch"
,
"CH"
},
{
"crz"
,
"CRZ"
}
,
{
"cu1"
,
"CPhase"
}
};
class
CountQregs
:
public
staq
::
ast
::
Traverse
{
public:
...
...
@@ -77,8 +77,10 @@ public:
<<
"]);
\n
"
;
}
void
visit
(
UGate
&
u
)
override
{
ss
<<
"U("
<<
u
.
arg
().
var
()
<<
"["
<<
u
.
arg
().
offset
().
value
()
<<
"], "
<<
0
<<
", "
<<
0
<<
", "
<<
0
<<
");
\n
"
;
ss
<<
"U("
<<
u
.
arg
().
var
()
<<
"["
<<
u
.
arg
().
offset
().
value
()
<<
"], "
<<
u
.
theta
().
constant_eval
().
value
()
<<
", "
<<
u
.
phi
().
constant_eval
().
value
()
<<
", "
<<
u
.
lambda
().
constant_eval
().
value
()
<<
");
\n
"
;
}
void
visit
(
CNOTGate
&
cx
)
override
{
ss
<<
"CX("
<<
cx
.
ctrl
().
var
()
<<
"["
<<
cx
.
ctrl
().
offset
().
value
()
<<
"],"
...
...
@@ -111,7 +113,7 @@ class XACCToStaqOpenQasm : public AllGateVisitor {
public:
std
::
stringstream
ss
;
std
::
map
<
std
::
string
,
std
::
string
>
cregNames
;
std
::
map
<
std
::
string
,
std
::
string
>
cregNames
;
XACCToStaqOpenQasm
(
std
::
map
<
std
::
string
,
int
>
bufNamesToSize
);
void
visit
(
Hadamard
&
h
)
override
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment