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
abec43a3
Commit
abec43a3
authored
Sep 15, 2021
by
Nguyen, Thien Minh
Browse files
Fixed
https://github.com/eclipse/xacc/issues/486
Signed-off-by:
Thien Nguyen
<
nguyentm@ornl.gov
>
parent
4b275a90
Changes
2
Hide whitespace changes
Inline
Side-by-side
quantum/gate/ir/Circuit.cpp
View file @
abec43a3
...
...
@@ -199,7 +199,7 @@ void Circuit::load(std::istream &inStream) {
}
}
const
int
Circuit
::
depth
()
{
return
toGraph
()
->
depth
()
-
2
;
}
const
int
Circuit
::
depth
()
{
return
toGraph
()
->
depth
();
}
const
std
::
string
Circuit
::
persistGraph
()
{
std
::
stringstream
s
;
...
...
quantum/gate/utils/tests/IRToGraphVisitorTester.cpp
View file @
abec43a3
...
...
@@ -61,6 +61,7 @@ TEST(IRToGraphTester, checkSimple) {
EXPECT_EQ
(
graph
->
getVertexProperties
(
5
).
getString
(
"name"
),
z
->
name
());
EXPECT_EQ
(
graph
->
getVertexProperties
(
5
).
get
<
int
>
(
"layer"
),
2
);
EXPECT_EQ
(
f
->
depth
(),
3
);
}
TEST
(
IRToGraphTester
,
checkCNOTLadder
)
{
...
...
@@ -92,6 +93,15 @@ TEST(IRToGraphTester, checkCNOTLadder) {
EXPECT_EQ
(
node
.
getString
(
"name"
),
"CNOT"
);
EXPECT_EQ
(
node
.
get
<
int
>
(
"layer"
),
i
-
1
);
}
EXPECT_EQ
(
f
->
depth
(),
4
);
}
TEST
(
IRToGraphTester
,
checkSingleGate
)
{
auto
f
=
std
::
make_shared
<
Circuit
>
(
"foo"
);
auto
x
=
std
::
make_shared
<
X
>
(
0
);
f
->
addInstruction
(
x
);
f
->
toGraph
()
->
write
(
std
::
cout
);
EXPECT_EQ
(
f
->
depth
(),
1
);
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
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