Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
de344fa4
"docs/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "3f591ef97503313b1907d251fc9a817540523eb5"
Unverified
Commit
de344fa4
authored
Aug 12, 2023
by
Songqing Zhang
Committed by
GitHub
Aug 12, 2023
Browse files
[Misc] Small fix of cpp tests (#6137)
parent
2c64ae03
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
24 deletions
+27
-24
tests/cpp/common.h
tests/cpp/common.h
+0
-1
tests/cpp/test_smart_ptr_serialize.cc
tests/cpp/test_smart_ptr_serialize.cc
+0
-4
tests/cpp/test_spmat_coo.cc
tests/cpp/test_spmat_coo.cc
+12
-8
tests/cpp/test_spmat_csr.cc
tests/cpp/test_spmat_csr.cc
+15
-11
No files found.
tests/cpp/common.h
View file @
de344fa4
...
...
@@ -36,7 +36,6 @@ inline bool ArrayEQ(dgl::runtime::NDArray a1, dgl::runtime::NDArray a2) {
if
(
a1
->
shape
[
i
]
!=
a2
->
shape
[
i
])
return
false
;
num
*=
a1
->
shape
[
i
];
}
if
(
a1
->
ctx
!=
a2
->
ctx
)
return
false
;
a1
=
a1
.
CopyTo
(
CPU
);
a2
=
a2
.
CopyTo
(
CPU
);
for
(
int64_t
i
=
0
;
i
<
num
;
++
i
)
...
...
tests/cpp/test_smart_ptr_serialize.cc
View file @
de344fa4
...
...
@@ -59,8 +59,6 @@ TYPED_TEST(SmartPtrTest, Vector_Test1) {
dmlc
::
MemoryStringStream
fs
(
&
blob
);
using
SmartPtr
=
typename
TestFixture
::
SmartPtr
;
typedef
std
::
pair
<
std
::
string
,
SmartPtr
>
Pair
;
auto
my1
=
SmartPtr
(
new
MyClass
(
"@A@"
));
auto
my2
=
SmartPtr
(
new
MyClass
(
"2222"
));
std
::
vector
<
Pair
>
myclasses
;
myclasses
.
emplace_back
(
"a"
,
SmartPtr
(
new
MyClass
(
"@A@B"
)));
...
...
@@ -83,8 +81,6 @@ TYPED_TEST(SmartPtrTest, Vector_Test2) {
std
::
string
blob
;
dmlc
::
MemoryStringStream
fs
(
&
blob
);
using
SmartPtr
=
typename
TestFixture
::
SmartPtr
;
auto
my1
=
SmartPtr
(
new
MyClass
(
"@A@"
));
auto
my2
=
SmartPtr
(
new
MyClass
(
"2222"
));
std
::
vector
<
SmartPtr
>
myclasses
;
myclasses
.
emplace_back
(
new
MyClass
(
"@A@"
));
...
...
tests/cpp/test_spmat_coo.cc
View file @
de344fa4
...
...
@@ -63,7 +63,9 @@ aten::COOMatrix COO1(DGLContext ctx = CTX) {
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
0
,
2
,
0
,
1
,
2
}),
sizeof
(
IDX
)
*
8
,
ctx
),
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
1
,
2
,
2
,
0
,
3
}),
sizeof
(
IDX
)
*
8
,
ctx
));
std
::
vector
<
IDX
>
({
1
,
2
,
2
,
0
,
3
}),
sizeof
(
IDX
)
*
8
,
ctx
),
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
0
,
3
,
1
,
2
,
4
}),
sizeof
(
IDX
)
*
8
,
ctx
));
}
template
<
typename
IDX
>
...
...
@@ -81,7 +83,9 @@ aten::COOMatrix COO2(DGLContext ctx = CTX) {
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
0
,
2
,
0
,
1
,
2
,
0
}),
sizeof
(
IDX
)
*
8
,
ctx
),
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
1
,
2
,
2
,
0
,
3
,
2
}),
sizeof
(
IDX
)
*
8
,
ctx
));
std
::
vector
<
IDX
>
({
1
,
2
,
2
,
0
,
3
,
2
}),
sizeof
(
IDX
)
*
8
,
ctx
),
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
0
,
1
,
2
,
3
,
4
,
5
}),
sizeof
(
IDX
)
*
8
,
ctx
));
}
template
<
typename
IDX
>
...
...
@@ -335,10 +339,10 @@ TEST(SpmatTest, COOToCSR) {
template
<
typename
IDX
>
void
_TestCOOHasDuplicate
()
{
auto
c
sr
=
COO1
<
IDX
>
();
ASSERT_FALSE
(
aten
::
COOHasDuplicate
(
c
sr
));
c
sr
=
COO2
<
IDX
>
();
ASSERT_TRUE
(
aten
::
COOHasDuplicate
(
c
sr
));
auto
c
oo
=
COO1
<
IDX
>
();
ASSERT_FALSE
(
aten
::
COOHasDuplicate
(
c
oo
));
c
oo
=
COO2
<
IDX
>
();
ASSERT_TRUE
(
aten
::
COOHasDuplicate
(
c
oo
));
}
TEST
(
SpmatTest
,
TestCOOHasDuplicate
)
{
...
...
@@ -483,12 +487,12 @@ TEST(SpmatTest, COOGetData) {
template
<
typename
IDX
>
void
_TestCOOGetDataAndIndices
()
{
auto
c
sr
=
COO2
<
IDX
>
();
auto
c
oo
=
COO2
<
IDX
>
();
auto
r
=
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
0
,
0
,
0
}),
sizeof
(
IDX
)
*
8
,
CTX
);
auto
c
=
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
0
,
1
,
2
}),
sizeof
(
IDX
)
*
8
,
CTX
);
auto
x
=
aten
::
COOGetDataAndIndices
(
c
sr
,
r
,
c
);
auto
x
=
aten
::
COOGetDataAndIndices
(
c
oo
,
r
,
c
);
auto
tr
=
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
0
,
0
,
0
}),
sizeof
(
IDX
)
*
8
,
CTX
);
auto
tc
=
...
...
tests/cpp/test_spmat_csr.cc
View file @
de344fa4
...
...
@@ -48,15 +48,15 @@ aten::CSRMatrix CSR2(DGLContext ctx = CTX) {
template
<
typename
IDX
>
aten
::
CSRMatrix
CSR3
(
DGLContext
ctx
=
CTX
)
{
// has duplicate entries and the columns are not sorted
// [[0, 1, 1, 1, 0],
// [1, 0, 0, 0, 0],
// [0, 0, 1, 1, 0],
// [0, 0, 0, 0, 0],
// [1, 1, 1, 0, 0],
// [0, 0, 0, 1, 0
]
],
// [0, 0, 0, 0, 0
]
],
// [1, 2, 1, 1, 0
]
],
// [0, 1, 0, 0, 1]],
// [[0, 1, 1, 1,
0,
0],
// [1, 0, 0, 0,
0,
0],
// [0, 0, 1, 1,
0,
0],
// [0, 0, 0, 0,
0,
0],
// [1, 1, 1, 0,
0,
0],
// [0, 0, 0, 1, 0
, 0
],
// [0, 0, 0, 0, 0
, 0
],
// [1, 2, 1, 1, 0
, 0
],
// [0, 1, 0, 0,
0,
1]],
// data: [5, 2, 0, 3, 1, 4, 8, 7, 6, 9, 12, 13, 11, 10, 14, 15, 16]
return
aten
::
CSRMatrix
(
9
,
6
,
...
...
@@ -87,7 +87,9 @@ aten::COOMatrix COO1(DGLContext ctx = CTX) {
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
0
,
2
,
0
,
1
,
2
}),
sizeof
(
IDX
)
*
8
,
ctx
),
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
1
,
2
,
2
,
0
,
3
}),
sizeof
(
IDX
)
*
8
,
ctx
));
std
::
vector
<
IDX
>
({
1
,
2
,
2
,
0
,
3
}),
sizeof
(
IDX
)
*
8
,
ctx
),
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
0
,
3
,
1
,
2
,
4
}),
sizeof
(
IDX
)
*
8
,
ctx
));
}
template
<
typename
IDX
>
...
...
@@ -105,7 +107,9 @@ aten::COOMatrix COO2(DGLContext ctx = CTX) {
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
0
,
2
,
0
,
1
,
2
,
0
}),
sizeof
(
IDX
)
*
8
,
ctx
),
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
1
,
2
,
2
,
0
,
3
,
2
}),
sizeof
(
IDX
)
*
8
,
ctx
));
std
::
vector
<
IDX
>
({
1
,
2
,
2
,
0
,
3
,
2
}),
sizeof
(
IDX
)
*
8
,
ctx
),
aten
::
VecToIdArray
(
std
::
vector
<
IDX
>
({
0
,
1
,
2
,
3
,
4
,
5
}),
sizeof
(
IDX
)
*
8
,
ctx
));
}
template
<
typename
IDX
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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