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
a56d1833
Commit
a56d1833
authored
Feb 12, 2021
by
Nguyen, Thien Minh
Browse files
Handle qcor_qpu_config key and use the config parser
Signed-off-by:
Thien Nguyen
<
nguyentm@ornl.gov
>
parent
acc91309
Changes
1
Hide whitespace changes
Inline
Side-by-side
xacc/compiler/xacc_internal_compiler.cpp
View file @
a56d1833
...
...
@@ -2,7 +2,9 @@
#include
"Instruction.hpp"
#include
"Utils.hpp"
#include
"heterogeneous.hpp"
#include
"config_file_parser.hpp"
#include
"xacc.hpp"
#include
"xacc_service.hpp"
#include
"InstructionIterator.hpp"
#include
<CompositeInstruction.hpp>
#include
<stdlib.h>
...
...
@@ -55,18 +57,35 @@ auto process_qpu_backend_str = [](const std::string &qpu_backend_str)
auto
tmp
=
split
(
key_value
,
':'
);
auto
key
=
tmp
[
0
];
auto
value
=
tmp
[
1
];
// check if int first, then double,
// finally just throw it in as a string
try
{
auto
i
=
std
::
stoi
(
value
);
options
.
insert
(
key
,
i
);
}
catch
(
std
::
exception
&
e
)
{
if
(
key
==
"qcor_qpu_config"
)
{
// If the config is provided in a file:
// We could check for file extension here to
// determine a parsing plugin.
// Currently, we only support a simple key-value format (INI like).
// e.g.
// String like config:
// name=XACC
// Boolean configs
// true_val=true
// false_val=false
// Array/vector configs
// array=[1,2,3]
// array_double=[1.0,2.0,3.0]
auto
parser
=
xacc
::
getService
<
ConfigFileParsingUtil
>
(
"ini"
);
options
=
parser
->
parse
(
value
);
}
else
{
// check if int first, then double,
// finally just throw it in as a string
try
{
auto
d
=
std
::
sto
d
(
value
);
options
.
insert
(
key
,
d
);
auto
i
=
std
::
sto
i
(
value
);
options
.
insert
(
key
,
i
);
}
catch
(
std
::
exception
&
e
)
{
options
.
insert
(
key
,
value
);
try
{
auto
d
=
std
::
stod
(
value
);
options
.
insert
(
key
,
d
);
}
catch
(
std
::
exception
&
e
)
{
options
.
insert
(
key
,
value
);
}
}
}
}
...
...
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