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
27a79414
Commit
27a79414
authored
Aug 06, 2021
by
Nguyen, Thien Minh
Browse files
Support qasm construction from QObj
Signed-off-by:
Thien Nguyen
<
nguyentm@ornl.gov
>
parent
c6d64045
Changes
2
Hide whitespace changes
Inline
Side-by-side
quantum/plugins/ibm/accelerator/IBMAccelerator.cpp
View file @
27a79414
...
...
@@ -1260,7 +1260,30 @@ IBMAccelerator::getNativeCode(std::shared_ptr<CompositeInstruction> program,
return
jsonStr
;
}
else
if
(
format
==
"qasm"
||
format
==
"Qasm"
||
format
==
"QASM"
||
format
==
"OpenQASM"
||
format
==
"OPENQASM"
)
{
return
""
;
chosenBackend
=
availableBackends
[
backend
];
const
auto
basis_gates
=
chosenBackend
[
"basis_gates"
].
get
<
std
::
vector
<
std
::
string
>>
();
// If the gate set has "u3" -> old gateset.
const
auto
gateSet
=
(
xacc
::
container
::
contains
(
basis_gates
,
"u3"
))
?
QObjectExperimentVisitor
::
GateSet
::
U_CX
:
QObjectExperimentVisitor
::
GateSet
::
RZ_SX_CX
;
auto
visitor
=
std
::
make_shared
<
QObjectExperimentVisitor
>
(
program
->
name
(),
program
->
nLogicalBits
(),
gateSet
);
InstructionIterator
it
(
program
);
int
memSlots
=
0
;
while
(
it
.
hasNext
())
{
auto
nextInst
=
it
.
next
();
if
(
nextInst
->
isEnabled
())
{
nextInst
->
accept
(
visitor
);
}
}
auto
experiment
=
visitor
->
getExperiment
();
std
::
stringstream
ss
;
for
(
auto
&
inst
:
experiment
.
get_instructions
())
{
// std::cout << "HOWDY: " << inst.toString() << "\n";
ss
<<
inst
.
toString
()
<<
"
\n
"
;
}
return
ss
.
str
();
}
xacc
::
error
(
"Unknown native code format '"
+
format
+
"'"
);
return
""
;
...
...
quantum/plugins/ibm/accelerator/json/QObject.hpp
View file @
27a79414
...
...
@@ -399,6 +399,26 @@ public:
std
::
optional
<
int64_t
>
get_condition_reg_id
()
const
{
return
conditional
;
}
void
set_condition_reg_id
(
int64_t
value
)
{
this
->
conditional
=
value
;
}
std
::
string
toString
()
const
{
std
::
stringstream
ss
;
ss
<<
name
;
if
(
!
params
.
empty
())
{
ss
<<
"("
;
for
(
int
i
=
0
;
i
<
params
.
size
();
++
i
)
{
ss
<<
params
[
i
];
if
(
i
!=
params
.
size
()
-
1
)
{
ss
<<
", "
;
}
}
ss
<<
")"
;
}
for
(
const
auto
&
qb
:
qubits
)
{
ss
<<
" q["
<<
qb
<<
"]"
;
}
ss
<<
";"
;
return
ss
.
str
();
}
};
class
Experiment
{
...
...
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