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
90ded0e5
Commit
90ded0e5
authored
Jul 16, 2019
by
Mccaskey, Alex
Browse files
Merge branch 'master' into mccaskey/algorithm_optimizer
parents
b341629d
53a34eb3
Pipeline
#63400
passed with stage
in 9 minutes and 37 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
quantum/gate/ir/GateFunction.cpp
View file @
90ded0e5
...
...
@@ -332,19 +332,38 @@ void GateFunction::addInstruction(InstPtr instruction) {
xacc
::
InstructionParameter
param
=
instruction
->
getParameter
(
0
);
// Check to see if parameter is a string
if
(
param
.
isVariable
())
{
// check to see if the new parameter is a duplicate parameter
bool
dupParam
=
false
;
// strip the parameter of mathematical operators and numbers/doubles
InstructionParameter
strippedParam
=
splitParameter
(
param
);
// check if the instruction parameter is a duplicate
for
(
auto
p
:
parameters
)
{
if
(
p
.
as
<
std
::
string
>
()
==
strippedParam
.
as
<
std
::
string
>
())
{
dupParam
=
true
;
// This could be an expression of constants, so
// lets evaluate and see
symbol_table_t
symbol_table
;
symbol_table
.
add_constants
();
expression_t
expr
;
expr
.
register_symbol_table
(
symbol_table
);
parser_t
parser
;
if
(
parser
.
compile
(
param
.
toString
(),
expr
))
{
// std::cout << "Expr Compiled: " << expr.value() << "\n";
auto
value
=
expr
.
value
();
InstructionParameter
pp
(
value
);
instruction
->
setParameter
(
0
,
pp
);
}
else
{
// std::cout << "ADDING VAR: " << param.which() << ", " << param.toString()
// << "\n";
// check to see if the new parameter is a duplicate parameter
bool
dupParam
=
false
;
// strip the parameter of mathematical operators and numbers/doubles
InstructionParameter
strippedParam
=
splitParameter
(
param
);
// check if the instruction parameter is a duplicate
for
(
auto
p
:
parameters
)
{
// std::cout << "LOOPING PARAMS: ";
// std::cout << p.toString() << "\n";
// std::cout << strippedParam.toString() << "\n";
if
(
p
.
as
<
std
::
string
>
()
==
strippedParam
.
as
<
std
::
string
>
())
{
dupParam
=
true
;
}
}
// if new parameter is not a duplicate, add the stripped version
if
(
!
dupParam
)
{
parameters
.
push_back
(
strippedParam
);
}
}
// if new parameter is not a duplicate, add the stripped version
if
(
!
dupParam
)
{
parameters
.
push_back
(
strippedParam
);
}
}
}
...
...
xacc/ir/InstructionParameter.hpp
View file @
90ded0e5
...
...
@@ -62,11 +62,13 @@ public:
return
mpark
::
get
<
T
>
(
*
this
);
}
catch
(
std
::
exception
&
e
)
{
std
::
stringstream
s
;
s
<<
toString
()
<<
"
\n
"
;
s
<<
"This InstructionParameter type id is "
<<
this
->
which
()
<<
"
\n
Allowed Ids to Type
\n
"
;
for
(
auto
&
kv
:
whichType
)
{
s
<<
kv
.
first
<<
": "
<<
kv
.
second
<<
"
\n
"
;
}
XACCLogger
::
instance
()
->
error
(
"Cannot cast Variant:
\n
"
+
s
.
str
());
exit
(
0
);
}
return
T
();
}
...
...
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