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
e4cc8185
Unverified
Commit
e4cc8185
authored
Mar 30, 2020
by
Quan (Andy) Gan
Committed by
GitHub
Mar 30, 2020
Browse files
[Windows] fix compilation issues on vs2015 (#1405)
* [Windows] fix compilation issues on vs2015 * fix test
parent
e9440acb
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
22 deletions
+36
-22
conda/dgl/bld.bat
conda/dgl/bld.bat
+1
-3
python/dgl/sampling/neighbor.py
python/dgl/sampling/neighbor.py
+13
-7
src/graph/metis_partition.cc
src/graph/metis_partition.cc
+13
-6
src/graph/sampling/neighbor/neighbor.cc
src/graph/sampling/neighbor/neighbor.cc
+7
-5
tests/compute/test_sampling.py
tests/compute/test_sampling.py
+2
-1
No files found.
conda/dgl/bld.bat
View file @
e4cc8185
...
@@ -3,9 +3,7 @@ git submodule init
...
@@ -3,9 +3,7 @@ git submodule init
git
submodule
update
--recursive
git
submodule
update
--recursive
md
build
md
build
cd
build
cd
build
cmake
-DUSE
_CUDA
=
%USE_CUDA%
-DUSE
_OPENMP
=
ON
-DCUDA
_ARCH_NAME
=
All
-DCMAKE
_CXX_FLAGS
=
"/DDGL_EXPORTS"
-DCMAKE
_CONFIGURATION_TYPES
=
"Release"
-DDMLC
_FORCE_SHARED_CRT
=
ON
..
-G
"Visual Studio 15 2017 Win64"
||
EXIT
/B
1
COPY
%TEMP%
\dgl.dll .
msbuild
dgl
.sln
||
EXIT
/B
1
COPY
Release
\dgl.dll .
cd
..\python
cd
..\python
"
%PYTHON%
"
setup
.py
install
--single-version-externally-managed --record
=
record
.txt
||
EXIT
/B
1
"
%PYTHON%
"
setup
.py
install
--single-version-externally-managed --record
=
record
.txt
||
EXIT
/B
1
EXIT
/B
EXIT
/B
python/dgl/sampling/neighbor.py
View file @
e4cc8185
...
@@ -69,6 +69,7 @@ def sample_neighbors(g, nodes, fanout, edge_dir='in', prob=None, replace=False):
...
@@ -69,6 +69,7 @@ def sample_neighbors(g, nodes, fanout, edge_dir='in', prob=None, replace=False):
fanout_array
=
[
None
]
*
len
(
g
.
etypes
)
fanout_array
=
[
None
]
*
len
(
g
.
etypes
)
for
etype
,
value
in
fanout
.
items
():
for
etype
,
value
in
fanout
.
items
():
fanout_array
[
g
.
get_etype_id
(
etype
)]
=
value
fanout_array
[
g
.
get_etype_id
(
etype
)]
=
value
fanout_array
=
utils
.
toindex
(
fanout_array
).
todgltensor
()
if
prob
is
None
:
if
prob
is
None
:
prob_arrays
=
[
nd
.
array
([],
ctx
=
nd
.
cpu
())]
*
len
(
g
.
etypes
)
prob_arrays
=
[
nd
.
array
([],
ctx
=
nd
.
cpu
())]
*
len
(
g
.
etypes
)
...
@@ -100,7 +101,7 @@ def select_topk(g, k, weight, nodes=None, edge_dir='in', ascending=False):
...
@@ -100,7 +101,7 @@ def select_topk(g, k, weight, nodes=None, edge_dir='in', ascending=False):
----------
----------
g : DGLHeteroGraph
g : DGLHeteroGraph
Full graph structure.
Full graph structure.
k : int
k : int
or dict[etype, int]
The K value.
The K value.
weight : str
weight : str
Feature name of the weights associated with each edge. Its shape should be
Feature name of the weights associated with each edge. Its shape should be
...
@@ -138,11 +139,16 @@ def select_topk(g, k, weight, nodes=None, edge_dir='in', ascending=False):
...
@@ -138,11 +139,16 @@ def select_topk(g, k, weight, nodes=None, edge_dir='in', ascending=False):
else
:
else
:
nodes_all_types
.
append
(
nd
.
array
([],
ctx
=
nd
.
cpu
()))
nodes_all_types
.
append
(
nd
.
array
([],
ctx
=
nd
.
cpu
()))
if
not
isinstance
(
k
,
list
):
if
not
isinstance
(
k
,
dict
):
k
=
[
int
(
k
)]
*
len
(
g
.
etypes
)
k_array
=
[
int
(
k
)]
*
len
(
g
.
etypes
)
else
:
if
len
(
k
)
!=
len
(
g
.
etypes
):
if
len
(
k
)
!=
len
(
g
.
etypes
):
raise
DGLError
(
'K value must be specified for each edge type '
raise
DGLError
(
'K value must be specified for each edge type '
'if a list is provided.'
)
'if a dict is provided.'
)
k_array
=
[
None
]
*
len
(
g
.
etypes
)
for
etype
,
value
in
k
.
items
():
k_array
[
g
.
get_etype_id
(
etype
)]
=
value
k_array
=
utils
.
toindex
(
k_array
).
todgltensor
()
weight_arrays
=
[]
weight_arrays
=
[]
for
etype
in
g
.
canonical_etypes
:
for
etype
in
g
.
canonical_etypes
:
...
@@ -153,7 +159,7 @@ def select_topk(g, k, weight, nodes=None, edge_dir='in', ascending=False):
...
@@ -153,7 +159,7 @@ def select_topk(g, k, weight, nodes=None, edge_dir='in', ascending=False):
weight
,
etype
))
weight
,
etype
))
subgidx
=
_CAPI_DGLSampleNeighborsTopk
(
subgidx
=
_CAPI_DGLSampleNeighborsTopk
(
g
.
_graph
,
nodes_all_types
,
k
,
edge_dir
,
weight_arrays
,
bool
(
ascending
))
g
.
_graph
,
nodes_all_types
,
k
_array
,
edge_dir
,
weight_arrays
,
bool
(
ascending
))
induced_edges
=
subgidx
.
induced_edges
induced_edges
=
subgidx
.
induced_edges
ret
=
DGLHeteroGraph
(
subgidx
.
graph
,
g
.
ntypes
,
g
.
etypes
)
ret
=
DGLHeteroGraph
(
subgidx
.
graph
,
g
.
ntypes
,
g
.
etypes
)
for
i
,
etype
in
enumerate
(
ret
.
canonical_etypes
):
for
i
,
etype
in
enumerate
(
ret
.
canonical_etypes
):
...
...
src/graph/metis_partition.cc
View file @
e4cc8185
...
@@ -4,17 +4,18 @@
...
@@ -4,17 +4,18 @@
* \brief Call Metis partitioning
* \brief Call Metis partitioning
*/
*/
#include <metis.h>
#include <dgl/graph_op.h>
#include <dgl/packed_func_ext.h>
#include <dgl/packed_func_ext.h>
#include "../c_api_common.h"
#include "../c_api_common.h"
#if !defined(_WIN32)
#include <metis.h>
#include <dgl/graph_op.h>
using
namespace
dgl
::
runtime
;
using
namespace
dgl
::
runtime
;
namespace
dgl
{
namespace
dgl
{
#if !defined(_WIN32)
IdArray
GraphOp
::
MetisPartition
(
GraphPtr
g
,
int
k
)
{
IdArray
GraphOp
::
MetisPartition
(
GraphPtr
g
,
int
k
)
{
// The index type of Metis needs to be compatible with DGL index type.
// The index type of Metis needs to be compatible with DGL index type.
CHECK_EQ
(
sizeof
(
idx_t
),
sizeof
(
dgl_id_t
));
CHECK_EQ
(
sizeof
(
idx_t
),
sizeof
(
dgl_id_t
));
...
@@ -71,7 +72,13 @@ DGL_REGISTER_GLOBAL("transform._CAPI_DGLMetisPartition")
...
@@ -71,7 +72,13 @@ DGL_REGISTER_GLOBAL("transform._CAPI_DGLMetisPartition")
*
rv
=
GraphOp
::
MetisPartition
(
g
.
sptr
(),
k
);
*
rv
=
GraphOp
::
MetisPartition
(
g
.
sptr
(),
k
);
});
});
#else
}
// namespace dgl
#else // defined(_WIN32)
using
namespace
dgl
::
runtime
;
namespace
dgl
{
DGL_REGISTER_GLOBAL
(
"transform._CAPI_DGLMetisPartition"
)
DGL_REGISTER_GLOBAL
(
"transform._CAPI_DGLMetisPartition"
)
.
set_body
([]
(
DGLArgs
args
,
DGLRetValue
*
rv
)
{
.
set_body
([]
(
DGLArgs
args
,
DGLRetValue
*
rv
)
{
...
@@ -81,6 +88,6 @@ DGL_REGISTER_GLOBAL("transform._CAPI_DGLMetisPartition")
...
@@ -81,6 +88,6 @@ DGL_REGISTER_GLOBAL("transform._CAPI_DGLMetisPartition")
*
rv
=
aten
::
NullArray
();
*
rv
=
aten
::
NullArray
();
});
});
#endif // !defined(_WIN32)
}
// namespace dgl
}
// namespace dgl
#endif // !defined(_WIN32)
src/graph/sampling/neighbor/neighbor.cc
View file @
e4cc8185
...
@@ -172,7 +172,8 @@ DGL_REGISTER_GLOBAL("sampling.neighbor._CAPI_DGLSampleNeighbors")
...
@@ -172,7 +172,8 @@ DGL_REGISTER_GLOBAL("sampling.neighbor._CAPI_DGLSampleNeighbors")
.
set_body
([]
(
DGLArgs
args
,
DGLRetValue
*
rv
)
{
.
set_body
([]
(
DGLArgs
args
,
DGLRetValue
*
rv
)
{
HeteroGraphRef
hg
=
args
[
0
];
HeteroGraphRef
hg
=
args
[
0
];
const
auto
&
nodes
=
ListValueToVector
<
IdArray
>
(
args
[
1
]);
const
auto
&
nodes
=
ListValueToVector
<
IdArray
>
(
args
[
1
]);
const
auto
&
fanouts
=
ListValueToVector
<
int64_t
>
(
args
[
2
]);
IdArray
fanouts_array
=
args
[
2
];
const
auto
&
fanouts
=
fanouts_array
.
ToVector
<
int64_t
>
();
const
std
::
string
dir_str
=
args
[
3
];
const
std
::
string
dir_str
=
args
[
3
];
const
auto
&
prob
=
ListValueToVector
<
FloatArray
>
(
args
[
4
]);
const
auto
&
prob
=
ListValueToVector
<
FloatArray
>
(
args
[
4
]);
const
bool
replace
=
args
[
5
];
const
bool
replace
=
args
[
5
];
...
@@ -192,7 +193,8 @@ DGL_REGISTER_GLOBAL("sampling.neighbor._CAPI_DGLSampleNeighborsTopk")
...
@@ -192,7 +193,8 @@ DGL_REGISTER_GLOBAL("sampling.neighbor._CAPI_DGLSampleNeighborsTopk")
.
set_body
([]
(
DGLArgs
args
,
DGLRetValue
*
rv
)
{
.
set_body
([]
(
DGLArgs
args
,
DGLRetValue
*
rv
)
{
HeteroGraphRef
hg
=
args
[
0
];
HeteroGraphRef
hg
=
args
[
0
];
const
auto
&
nodes
=
ListValueToVector
<
IdArray
>
(
args
[
1
]);
const
auto
&
nodes
=
ListValueToVector
<
IdArray
>
(
args
[
1
]);
const
auto
&
k
=
ListValueToVector
<
int64_t
>
(
args
[
2
]);
IdArray
k_array
=
args
[
2
];
const
auto
&
k
=
k_array
.
ToVector
<
int64_t
>
();
const
std
::
string
dir_str
=
args
[
3
];
const
std
::
string
dir_str
=
args
[
3
];
const
auto
&
weight
=
ListValueToVector
<
FloatArray
>
(
args
[
4
]);
const
auto
&
weight
=
ListValueToVector
<
FloatArray
>
(
args
[
4
]);
const
bool
ascending
=
args
[
5
];
const
bool
ascending
=
args
[
5
];
...
...
tests/compute/test_sampling.py
View file @
e4cc8185
...
@@ -386,7 +386,8 @@ def _test_sample_neighbors_topk(hypersparse):
...
@@ -386,7 +386,8 @@ def _test_sample_neighbors_topk(hypersparse):
_test3
()
_test3
()
# test different k for different relations
# test different k for different relations
subg
=
dgl
.
sampling
.
select_topk
(
hg
,
[
1
,
2
,
0
,
2
],
'weight'
,
{
'user'
:
[
0
,
1
],
'game'
:
0
})
subg
=
dgl
.
sampling
.
select_topk
(
hg
,
{
'follow'
:
1
,
'play'
:
2
,
'liked-by'
:
0
,
'flips'
:
2
},
'weight'
,
{
'user'
:
[
0
,
1
],
'game'
:
0
})
assert
len
(
subg
.
ntypes
)
==
3
assert
len
(
subg
.
ntypes
)
==
3
assert
len
(
subg
.
etypes
)
==
4
assert
len
(
subg
.
etypes
)
==
4
assert
subg
[
'follow'
].
number_of_edges
()
==
2
assert
subg
[
'follow'
].
number_of_edges
()
==
2
...
...
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