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
7b7222a2
Commit
7b7222a2
authored
Aug 06, 2021
by
Nguyen, Thien Minh
Browse files
Work on Accelerator::getNativeCode
Signed-off-by:
Thien Nguyen
<
nguyentm@ornl.gov
>
parent
f820332d
Changes
3
Hide whitespace changes
Inline
Side-by-side
quantum/plugins/ibm/accelerator/IBMAccelerator.cpp
View file @
7b7222a2
...
...
@@ -1237,6 +1237,35 @@ void IBMAccelerator::put(const std::string &_url, const std::string &postStr,
return
;
}
std
::
string
IBMAccelerator
::
getNativeCode
(
std
::
shared_ptr
<
CompositeInstruction
>
program
,
const
HeterogeneousMap
&
config
)
{
std
::
string
format
=
"QObj"
;
// QObj/QASM
if
(
config
.
stringExists
(
"format"
))
{
format
=
config
.
getString
(
"format"
);
}
// Handle different ways to specify the format:
if
(
format
==
"QObj"
||
format
==
"QOBJ"
||
format
==
"JSON"
)
{
chosenBackend
=
availableBackends
[
backend
];
auto
connectivity
=
getConnectivity
();
// Get the correct QObject Generator
auto
qobjGen
=
xacc
::
getService
<
QObjGenerator
>
(
mode
);
// Generate the QObject JSON
auto
jsonStr
=
qobjGen
->
getQObjJsonStr
(
{
program
},
shots
,
chosenBackend
,
getBackendPropsResponse
,
connectivity
,
json
::
parse
(
defaults_response
));
return
jsonStr
;
}
else
if
(
format
==
"qasm"
||
format
==
"Qasm"
||
format
==
"QASM"
||
format
==
"OpenQASM"
||
format
==
"OPENQASM"
)
{
return
""
;
}
xacc
::
error
(
"Unknown native code format '"
+
format
+
"'"
);
return
""
;
}
std
::
string
IBMAccelerator
::
get
(
const
std
::
string
&
_url
,
const
std
::
string
&
path
,
std
::
map
<
std
::
string
,
std
::
string
>
headers
,
...
...
quantum/plugins/ibm/accelerator/IBMAccelerator.hpp
View file @
7b7222a2
...
...
@@ -131,6 +131,8 @@ public:
std
::
vector
<
std
::
pair
<
int
,
int
>>
getConnectivity
()
override
;
std
::
string
getNativeCode
(
std
::
shared_ptr
<
CompositeInstruction
>
program
,
const
HeterogeneousMap
&
config
)
override
;
// Return the name of an IRTransformation of type Placement that is
// preferred for this Accelerator
const
std
::
string
defaultPlacementTransformation
()
override
{
...
...
xacc/accelerator/Accelerator.hpp
View file @
7b7222a2
...
...
@@ -106,6 +106,14 @@ public:
return
std
::
vector
<
std
::
pair
<
int
,
int
>>
{};
}
// Get circuit representation that the backend would be submitting to the
// physical QPU
virtual
std
::
string
getNativeCode
(
std
::
shared_ptr
<
CompositeInstruction
>
program
,
const
HeterogeneousMap
&
config
=
{})
{
return
program
->
toString
();
}
virtual
const
std
::
vector
<
std
::
complex
<
double
>>
getAcceleratorState
(
std
::
shared_ptr
<
CompositeInstruction
>
program
)
{
return
std
::
vector
<
std
::
complex
<
double
>>
{};
...
...
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