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
820c6b9e
Commit
820c6b9e
authored
Oct 18, 2018
by
Minjie Wang
Browse files
Add lint script and fix cpplint errors
parent
3e76bcc0
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
117 additions
and
104 deletions
+117
-104
include/dgl/graph.h
include/dgl/graph.h
+13
-8
include/dgl/graph_op.h
include/dgl/graph_op.h
+6
-1
include/dgl/runtime/README.md
include/dgl/runtime/README.md
+0
-3
include/dgl/runtime/c_backend_api.h
include/dgl/runtime/c_backend_api.h
+3
-3
include/dgl/runtime/c_runtime_api.h
include/dgl/runtime/c_runtime_api.h
+4
-4
include/dgl/runtime/device_api.h
include/dgl/runtime/device_api.h
+4
-4
include/dgl/runtime/module.h
include/dgl/runtime/module.h
+4
-4
include/dgl/runtime/ndarray.h
include/dgl/runtime/ndarray.h
+4
-4
include/dgl/runtime/packed_func.h
include/dgl/runtime/packed_func.h
+4
-4
include/dgl/runtime/registry.h
include/dgl/runtime/registry.h
+4
-4
include/dgl/runtime/serializer.h
include/dgl/runtime/serializer.h
+4
-4
include/dgl/runtime/threading_backend.h
include/dgl/runtime/threading_backend.h
+4
-4
include/dgl/runtime/util.h
include/dgl/runtime/util.h
+4
-4
include/dgl/scheduler.h
include/dgl/scheduler.h
+9
-5
src/c_api_common.cc
src/c_api_common.cc
+6
-1
src/c_api_common.h
src/c_api_common.h
+19
-7
src/graph/graph.cc
src/graph/graph.cc
+12
-7
src/graph/graph_apis.cc
src/graph/graph_apis.cc
+5
-0
src/graph/graph_op.cc
src/graph/graph_op.cc
+8
-30
src/runtime/README.md
src/runtime/README.md
+0
-3
No files found.
include/dgl/graph.h
View file @
820c6b9e
// DGL Graph interface
/*!
#ifndef DGL_DGLGRAPH_H_
* Copyright (c) 2018 by Contributors
#define DGL_DGLGRAPH_H_
* \file dgl/graph.h
* \brief DGL graph index class.
*/
#ifndef DGL_GRAPH_H_
#define DGL_GRAPH_H_
#include <stdint.h>
#include <vector>
#include <cstdint>
#include "runtime/ndarray.h"
#include "runtime/ndarray.h"
namespace
dgl
{
namespace
dgl
{
...
@@ -17,7 +22,7 @@ class GraphOp;
...
@@ -17,7 +22,7 @@ class GraphOp;
struct
Subgraph
;
struct
Subgraph
;
/*!
/*!
* \brief Base dgl graph class.
* \brief Base dgl graph
index
class.
*
*
* DGL's graph is directed. Vertices are integers enumerated from zero. Edges
* DGL's graph is directed. Vertices are integers enumerated from zero. Edges
* are uniquely identified by the two endpoints. Multi-edge is currently not
* are uniquely identified by the two endpoints. Multi-edge is currently not
...
@@ -41,7 +46,7 @@ class Graph {
...
@@ -41,7 +46,7 @@ class Graph {
}
EdgeArray
;
}
EdgeArray
;
/*! \brief default constructor */
/*! \brief default constructor */
Graph
(
bool
multigraph
=
false
)
:
is_multigraph_
(
multigraph
)
{}
explicit
Graph
(
bool
multigraph
=
false
)
:
is_multigraph_
(
multigraph
)
{}
/*! \brief default copy constructor */
/*! \brief default copy constructor */
Graph
(
const
Graph
&
other
)
=
default
;
Graph
(
const
Graph
&
other
)
=
default
;
...
@@ -192,7 +197,7 @@ class Graph {
...
@@ -192,7 +197,7 @@ class Graph {
* \return the id arrays of the two endpoints of the edges.
* \return the id arrays of the two endpoints of the edges.
*/
*/
EdgeArray
InEdges
(
IdArray
vids
)
const
;
EdgeArray
InEdges
(
IdArray
vids
)
const
;
/*!
/*!
* \brief Get the out edges of the vertex.
* \brief Get the out edges of the vertex.
* \note The returned src id array is filled with vid.
* \note The returned src id array is filled with vid.
...
@@ -347,4 +352,4 @@ struct Subgraph {
...
@@ -347,4 +352,4 @@ struct Subgraph {
}
// namespace dgl
}
// namespace dgl
#endif // DGL_
DGL
GRAPH_H_
#endif // DGL_GRAPH_H_
include/dgl/graph_op.h
View file @
820c6b9e
// Graph operations
/*!
* Copyright (c) 2018 by Contributors
* \file dgl/graph_op.h
* \brief Operations on graph index.
*/
#ifndef DGL_GRAPH_OP_H_
#ifndef DGL_GRAPH_OP_H_
#define DGL_GRAPH_OP_H_
#define DGL_GRAPH_OP_H_
#include <vector>
#include "graph.h"
#include "graph.h"
namespace
dgl
{
namespace
dgl
{
...
...
include/dgl/runtime/README.md
deleted
100644 → 0
View file @
3e76bcc0
# C API and runtime
Borrowed and adapted from TVM project.
include/dgl/runtime/c_backend_api.h
View file @
820c6b9e
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
* used by compiled tvm operators, usually user do not need to use these
* used by compiled tvm operators, usually user do not need to use these
* function directly.
* function directly.
*/
*/
#ifndef
TVM
_RUNTIME_C_BACKEND_API_H_
#ifndef
DGL
_RUNTIME_C_BACKEND_API_H_
#define
TVM
_RUNTIME_C_BACKEND_API_H_
#define
DGL
_RUNTIME_C_BACKEND_API_H_
#include "c_runtime_api.h"
#include "c_runtime_api.h"
...
@@ -136,4 +136,4 @@ TVM_DLL int TVMBackendRunOnce(void** handle,
...
@@ -136,4 +136,4 @@ TVM_DLL int TVMBackendRunOnce(void** handle,
#ifdef __cplusplus
#ifdef __cplusplus
}
// TVM_EXTERN_C
}
// TVM_EXTERN_C
#endif
#endif
#endif //
TVM
_RUNTIME_C_BACKEND_API_H_
#endif //
DGL
_RUNTIME_C_BACKEND_API_H_
include/dgl/runtime/c_runtime_api.h
View file @
820c6b9e
/*!
/*!
* Copyright (c) 2016 by Contributors
* Copyright (c) 2016 by Contributors
* \file
tvm
/runtime/c_runtime_api.h
* \file
dgl
/runtime/c_runtime_api.h
* \brief TVM runtime library.
* \brief TVM runtime library.
*
*
* The philosophy of TVM project is to customize the compilation
* The philosophy of TVM project is to customize the compilation
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
* - Use TVMFuncListGlobalNames to get global function name
* - Use TVMFuncListGlobalNames to get global function name
* - Use TVMFuncCall to call these functions.
* - Use TVMFuncCall to call these functions.
*/
*/
#ifndef
TVM
_RUNTIME_C_RUNTIME_API_H_
#ifndef
DGL
_RUNTIME_C_RUNTIME_API_H_
#define
TVM
_RUNTIME_C_RUNTIME_API_H_
#define
DGL
_RUNTIME_C_RUNTIME_API_H_
// Macros to do weak linking
// Macros to do weak linking
#ifdef _MSC_VER
#ifdef _MSC_VER
...
@@ -530,4 +530,4 @@ TVM_DLL int TVMStreamStreamSynchronize(int device_type,
...
@@ -530,4 +530,4 @@ TVM_DLL int TVMStreamStreamSynchronize(int device_type,
#ifdef __cplusplus
#ifdef __cplusplus
}
// TVM_EXTERN_C
}
// TVM_EXTERN_C
#endif
#endif
#endif //
TVM
_RUNTIME_C_RUNTIME_API_H_
#endif //
DGL
_RUNTIME_C_RUNTIME_API_H_
include/dgl/runtime/device_api.h
View file @
820c6b9e
/*!
/*!
* Copyright (c) 2016 by Contributors
* Copyright (c) 2016 by Contributors
* \file
tvm
/runtime/device_api.h
* \file
dgl
/runtime/device_api.h
* \brief Abstract device memory management API
* \brief Abstract device memory management API
*/
*/
#ifndef
TVM
_RUNTIME_DEVICE_API_H_
#ifndef
DGL
_RUNTIME_DEVICE_API_H_
#define
TVM
_RUNTIME_DEVICE_API_H_
#define
DGL
_RUNTIME_DEVICE_API_H_
#include <string>
#include <string>
#include "packed_func.h"
#include "packed_func.h"
...
@@ -180,4 +180,4 @@ class DeviceAPI {
...
@@ -180,4 +180,4 @@ class DeviceAPI {
constexpr
int
kRPCSessMask
=
128
;
constexpr
int
kRPCSessMask
=
128
;
}
// namespace runtime
}
// namespace runtime
}
// namespace tvm
}
// namespace tvm
#endif //
TVM
_RUNTIME_DEVICE_API_H_
#endif //
DGL
_RUNTIME_DEVICE_API_H_
include/dgl/runtime/module.h
View file @
820c6b9e
/*!
/*!
* Copyright (c) 2017 by Contributors
* Copyright (c) 2017 by Contributors
* \file
tvm
/runtime/module.h
* \file
dgl
/runtime/module.h
* \brief Runtime container of the functions generated by TVM,
* \brief Runtime container of the functions generated by TVM,
* This is used to support dynamically link, load and save
* This is used to support dynamically link, load and save
* functions from different convention under unified API.
* functions from different convention under unified API.
*/
*/
#ifndef
TVM
_RUNTIME_MODULE_H_
#ifndef
DGL
_RUNTIME_MODULE_H_
#define
TVM
_RUNTIME_MODULE_H_
#define
DGL
_RUNTIME_MODULE_H_
#include <dmlc/io.h>
#include <dmlc/io.h>
#include <memory>
#include <memory>
...
@@ -174,4 +174,4 @@ inline const ModuleNode* Module::operator->() const {
...
@@ -174,4 +174,4 @@ inline const ModuleNode* Module::operator->() const {
}
// namespace tvm
}
// namespace tvm
#include "packed_func.h"
#include "packed_func.h"
#endif //
TVM
_RUNTIME_MODULE_H_
#endif //
DGL
_RUNTIME_MODULE_H_
include/dgl/runtime/ndarray.h
View file @
820c6b9e
/*!
/*!
* Copyright (c) 2017 by Contributors
* Copyright (c) 2017 by Contributors
* \file
tvm
/runtime/ndarray.h
* \file
dgl
/runtime/ndarray.h
* \brief Abstract device memory management API
* \brief Abstract device memory management API
*/
*/
#ifndef
TVM
_RUNTIME_NDARRAY_H_
#ifndef
DGL
_RUNTIME_NDARRAY_H_
#define
TVM
_RUNTIME_NDARRAY_H_
#define
DGL
_RUNTIME_NDARRAY_H_
#include <atomic>
#include <atomic>
#include <vector>
#include <vector>
...
@@ -422,4 +422,4 @@ inline bool NDArray::Load(dmlc::Stream* strm) {
...
@@ -422,4 +422,4 @@ inline bool NDArray::Load(dmlc::Stream* strm) {
}
// namespace runtime
}
// namespace runtime
}
// namespace tvm
}
// namespace tvm
#endif //
TVM
_RUNTIME_NDARRAY_H_
#endif //
DGL
_RUNTIME_NDARRAY_H_
include/dgl/runtime/packed_func.h
View file @
820c6b9e
/*!
/*!
* Copyright (c) 2017 by Contributors
* Copyright (c) 2017 by Contributors
* \file
tvm
/runtime/packed_func.h
* \file
dgl
/runtime/packed_func.h
* \brief Type-erased function used across TVM API.
* \brief Type-erased function used across TVM API.
*/
*/
#ifndef
TVM
_RUNTIME_PACKED_FUNC_H_
#ifndef
DGL
_RUNTIME_PACKED_FUNC_H_
#define
TVM
_RUNTIME_PACKED_FUNC_H_
#define
DGL
_RUNTIME_PACKED_FUNC_H_
#include <dmlc/logging.h>
#include <dmlc/logging.h>
#include <functional>
#include <functional>
...
@@ -1212,4 +1212,4 @@ inline PackedFunc Module::GetFunction(const std::string& name, bool query_import
...
@@ -1212,4 +1212,4 @@ inline PackedFunc Module::GetFunction(const std::string& name, bool query_import
}
}
}
// namespace runtime
}
// namespace runtime
}
// namespace tvm
}
// namespace tvm
#endif //
TVM
_RUNTIME_PACKED_FUNC_H_
#endif //
DGL
_RUNTIME_PACKED_FUNC_H_
include/dgl/runtime/registry.h
View file @
820c6b9e
/*!
/*!
* Copyright (c) 2017 by Contributors
* Copyright (c) 2017 by Contributors
* \file
tvm
/runtime/registry.h
* \file
dgl
/runtime/registry.h
* \brief This file defines the TVM global function registry.
* \brief This file defines the TVM global function registry.
*
*
* The registered functions will be made available to front-end
* The registered functions will be made available to front-end
...
@@ -22,8 +22,8 @@
...
@@ -22,8 +22,8 @@
* });
* });
* \endcode
* \endcode
*/
*/
#ifndef
TVM
_RUNTIME_REGISTRY_H_
#ifndef
DGL
_RUNTIME_REGISTRY_H_
#define
TVM
_RUNTIME_REGISTRY_H_
#define
DGL
_RUNTIME_REGISTRY_H_
#include <string>
#include <string>
#include <vector>
#include <vector>
...
@@ -141,4 +141,4 @@ class Registry {
...
@@ -141,4 +141,4 @@ class Registry {
}
// namespace runtime
}
// namespace runtime
}
// namespace tvm
}
// namespace tvm
#endif //
TVM
_RUNTIME_REGISTRY_H_
#endif //
DGL
_RUNTIME_REGISTRY_H_
include/dgl/runtime/serializer.h
View file @
820c6b9e
/*!
/*!
* Copyright (c) 2017 by Contributors
* Copyright (c) 2017 by Contributors
* \file
tvm
/runtime/serializer.h
* \file
dgl
/runtime/serializer.h
* \brief Serializer extension to support TVM data types
* \brief Serializer extension to support TVM data types
* Include this file to enable serialization of DLDataType, DLContext
* Include this file to enable serialization of DLDataType, DLContext
*/
*/
#ifndef
TVM
_RUNTIME_SERIALIZER_H_
#ifndef
DGL
_RUNTIME_SERIALIZER_H_
#define
TVM
_RUNTIME_SERIALIZER_H_
#define
DGL
_RUNTIME_SERIALIZER_H_
#include <dmlc/io.h>
#include <dmlc/io.h>
#include <dmlc/serializer.h>
#include <dmlc/serializer.h>
...
@@ -48,4 +48,4 @@ struct Handler<DLContext> {
...
@@ -48,4 +48,4 @@ struct Handler<DLContext> {
}
// namespace serializer
}
// namespace serializer
}
// namespace dmlc
}
// namespace dmlc
#endif //
TVM
_RUNTIME_SERIALIZER_H_
#endif //
DGL
_RUNTIME_SERIALIZER_H_
include/dgl/runtime/threading_backend.h
View file @
820c6b9e
/*!
/*!
* Copyright (c) 2018 by Contributors
* Copyright (c) 2018 by Contributors
* \file
tvm
/runtime/threading_backend.h
* \file
dgl
/runtime/threading_backend.h
* \brief Utilities for manipulating thread pool threads.
* \brief Utilities for manipulating thread pool threads.
*/
*/
#ifndef
TVM
_RUNTIME_THREADING_BACKEND_H_
#ifndef
DGL
_RUNTIME_THREADING_BACKEND_H_
#define
TVM
_RUNTIME_THREADING_BACKEND_H_
#define
DGL
_RUNTIME_THREADING_BACKEND_H_
#include <functional>
#include <functional>
#include <memory>
#include <memory>
...
@@ -82,4 +82,4 @@ int MaxConcurrency();
...
@@ -82,4 +82,4 @@ int MaxConcurrency();
}
// namespace runtime
}
// namespace runtime
}
// namespace tvm
}
// namespace tvm
#endif //
TVM
_RUNTIME_THREADING_BACKEND_H_
#endif //
DGL
_RUNTIME_THREADING_BACKEND_H_
include/dgl/runtime/util.h
View file @
820c6b9e
/*!
/*!
* Copyright (c) 2017 by Contributors
* Copyright (c) 2017 by Contributors
* \file
tvm
/runtime/util.h
* \file
dgl
/runtime/util.h
* \brief Useful runtime util.
* \brief Useful runtime util.
*/
*/
#ifndef
TVM
_RUNTIME_UTIL_H_
#ifndef
DGL
_RUNTIME_UTIL_H_
#define
TVM
_RUNTIME_UTIL_H_
#define
DGL
_RUNTIME_UTIL_H_
#include "c_runtime_api.h"
#include "c_runtime_api.h"
...
@@ -50,4 +50,4 @@ enum TVMStructFieldKind : int {
...
@@ -50,4 +50,4 @@ enum TVMStructFieldKind : int {
}
// namespace intrinsic
}
// namespace intrinsic
}
// namespace ir
}
// namespace ir
}
// namespace tvm
}
// namespace tvm
#endif //
TVM
_RUNTIME_UTIL_H_
#endif //
DGL
_RUNTIME_UTIL_H_
include/dgl/scheduler.h
View file @
820c6b9e
// DGL Scheduler interface
/*!
* Copyright (c) 2018 by Contributors
* \file dgl/scheduler.h
* \brief Operations on graph index.
*/
#ifndef DGL_SCHEDULER_H_
#ifndef DGL_SCHEDULER_H_
#define DGL_SCHEDULER_H_
#define DGL_SCHEDULER_H_
#include "runtime/ndarray.h"
#include <vector>
#include <vector>
#include "runtime/ndarray.h"
namespace
dgl
{
namespace
dgl
{
...
@@ -25,8 +29,8 @@ namespace sched {
...
@@ -25,8 +29,8 @@ namespace sched {
*/
*/
std
::
vector
<
IdArray
>
DegreeBucketing
(
const
IdArray
&
vids
);
std
::
vector
<
IdArray
>
DegreeBucketing
(
const
IdArray
&
vids
);
}
// namespace sched
}
// namespace sched
}
// namespace dgl
}
// namespace dgl
#endif // DGL_SCHEDULER_H_
#endif
// DGL_SCHEDULER_H_
src/c_api_common.cc
View file @
820c6b9e
/*!
* Copyright (c) 2018 by Contributors
* \file c_runtime_api.cc
* \brief DGL C API common implementations
*/
#include "c_api_common.h"
#include "c_api_common.h"
using
tvm
::
runtime
::
TVMArgs
;
using
tvm
::
runtime
::
TVMArgs
;
...
@@ -29,5 +34,5 @@ PackedFunc ConvertNDArrayVectorToPackedFunc(const std::vector<NDArray>& vec) {
...
@@ -29,5 +34,5 @@ PackedFunc ConvertNDArrayVectorToPackedFunc(const std::vector<NDArray>& vec) {
return
PackedFunc
(
body
);
return
PackedFunc
(
body
);
}
}
}
// namespace dgl
}
// namespace dgl
src/c_api_common.h
View file @
820c6b9e
// DGL C API common util functions
/*!
* Copyright (c) 2018 by Contributors
* \file c_api_common.h
* \brief DGL C API common util functions
*/
#ifndef DGL_C_API_COMMON_H_
#ifndef DGL_C_API_COMMON_H_
#define DGL_C_API_COMMON_H_
#define DGL_C_API_COMMON_H_
...
@@ -12,12 +16,20 @@ namespace dgl {
...
@@ -12,12 +16,20 @@ namespace dgl {
// Graph handler type
// Graph handler type
typedef
void
*
GraphHandle
;
typedef
void
*
GraphHandle
;
// Convert the given DLTensor to a temporary DLManagedTensor that does not own memory.
/*!
DLManagedTensor
*
CreateTmpDLManagedTensor
(
const
tvm
::
runtime
::
TVMArgValue
&
arg
);
* \brief Convert the given DLTensor to DLManagedTensor.
*
* Return a temporary DLManagedTensor that does not own memory.
*/
DLManagedTensor
*
CreateTmpDLManagedTensor
(
const
tvm
::
runtime
::
TVMArgValue
&
arg
);
// Convert a vector of NDArray to PackedFunc
/*!
tvm
::
runtime
::
PackedFunc
ConvertNDArrayVectorToPackedFunc
(
const
std
::
vector
<
tvm
::
runtime
::
NDArray
>&
vec
);
* \brief Convert a vector of NDArray to PackedFunc.
*/
tvm
::
runtime
::
PackedFunc
ConvertNDArrayVectorToPackedFunc
(
const
std
::
vector
<
tvm
::
runtime
::
NDArray
>&
vec
);
}
// namespace dgl
}
// namespace dgl
#endif // DGL_C_API_COMMON_H_
#endif
// DGL_C_API_COMMON_H_
src/graph/graph.cc
View file @
820c6b9e
// Graph class implementation
/*!
* Copyright (c) 2018 by Contributors
* \file graph/graph.cc
* \brief DGL graph index implementation
*/
#include <dgl/graph.h>
#include <algorithm>
#include <algorithm>
#include <unordered_map>
#include <unordered_map>
#include <set>
#include <set>
#include <functional>
#include <functional>
#include <dgl/graph.h>
namespace
dgl
{
namespace
dgl
{
namespace
{
namespace
{
...
@@ -193,9 +197,9 @@ Graph::EdgeArray Graph::EdgeIds(IdArray src_ids, IdArray dst_ids) const {
...
@@ -193,9 +197,9 @@ Graph::EdgeArray Graph::EdgeIds(IdArray src_ids, IdArray dst_ids) const {
const
auto
&
succ
=
adjlist_
[
src_id
].
succ
;
const
auto
&
succ
=
adjlist_
[
src_id
].
succ
;
for
(
size_t
k
=
0
;
k
<
succ
.
size
();
++
k
)
{
for
(
size_t
k
=
0
;
k
<
succ
.
size
();
++
k
)
{
if
(
succ
[
k
]
==
dst_id
)
{
if
(
succ
[
k
]
==
dst_id
)
{
src
.
push_back
(
src_id
);
src
.
push_back
(
src_id
);
dst
.
push_back
(
dst_id
);
dst
.
push_back
(
dst_id
);
eid
.
push_back
(
adjlist_
[
src_id
].
edge_id
[
k
]);
eid
.
push_back
(
adjlist_
[
src_id
].
edge_id
[
k
]);
}
}
}
}
}
}
...
@@ -351,7 +355,7 @@ Graph::EdgeArray Graph::Edges(bool sorted) const {
...
@@ -351,7 +355,7 @@ Graph::EdgeArray Graph::Edges(bool sorted) const {
return
std
::
get
<
0
>
(
t1
)
<
std
::
get
<
0
>
(
t2
)
return
std
::
get
<
0
>
(
t1
)
<
std
::
get
<
0
>
(
t2
)
||
(
std
::
get
<
0
>
(
t1
)
==
std
::
get
<
0
>
(
t2
)
&&
std
::
get
<
1
>
(
t1
)
<
std
::
get
<
1
>
(
t2
));
||
(
std
::
get
<
0
>
(
t1
)
==
std
::
get
<
0
>
(
t2
)
&&
std
::
get
<
1
>
(
t1
)
<
std
::
get
<
1
>
(
t2
));
});
});
// make return arrays
// make return arrays
int64_t
*
src_ptr
=
static_cast
<
int64_t
*>
(
src
->
data
);
int64_t
*
src_ptr
=
static_cast
<
int64_t
*>
(
src
->
data
);
int64_t
*
dst_ptr
=
static_cast
<
int64_t
*>
(
dst
->
data
);
int64_t
*
dst_ptr
=
static_cast
<
int64_t
*>
(
dst
->
data
);
...
@@ -461,7 +465,8 @@ Subgraph Graph::EdgeSubgraph(IdArray eids) const {
...
@@ -461,7 +465,8 @@ Subgraph Graph::EdgeSubgraph(IdArray eids) const {
rst
.
graph
.
AddEdge
(
oldv2newv
[
src_id
],
oldv2newv
[
dst_id
]);
rst
.
graph
.
AddEdge
(
oldv2newv
[
src_id
],
oldv2newv
[
dst_id
]);
}
}
rst
.
induced_vertices
=
IdArray
::
Empty
({
static_cast
<
int64_t
>
(
nodes
.
size
())},
eids
->
dtype
,
eids
->
ctx
);
rst
.
induced_vertices
=
IdArray
::
Empty
(
{
static_cast
<
int64_t
>
(
nodes
.
size
())},
eids
->
dtype
,
eids
->
ctx
);
std
::
copy
(
nodes
.
begin
(),
nodes
.
end
(),
static_cast
<
int64_t
*>
(
rst
.
induced_vertices
->
data
));
std
::
copy
(
nodes
.
begin
(),
nodes
.
end
(),
static_cast
<
int64_t
*>
(
rst
.
induced_vertices
->
data
));
return
rst
;
return
rst
;
...
...
src/graph/graph_apis.cc
View file @
820c6b9e
/*!
* Copyright (c) 2018 by Contributors
* \file graph/graph.cc
* \brief DGL graph index APIs
*/
#include <dgl/graph.h>
#include <dgl/graph.h>
#include <dgl/graph_op.h>
#include <dgl/graph_op.h>
#include "../c_api_common.h"
#include "../c_api_common.h"
...
...
src/graph/graph_op.cc
View file @
820c6b9e
// Graph operation implementation
/*!
* Copyright (c) 2018 by Contributors
* \file graph/graph.cc
* \brief Graph operation implementation
*/
#include <dgl/graph_op.h>
#include <dgl/graph_op.h>
#include <algorithm>
#include <algorithm>
namespace
dgl
{
namespace
dgl
{
Graph
GraphOp
::
LineGraph
(
const
Graph
*
g
,
bool
backtracking
){
Graph
GraphOp
::
LineGraph
(
const
Graph
*
g
,
bool
backtracking
)
{
typedef
std
::
pair
<
dgl_id_t
,
dgl_id_t
>
entry
;
typedef
std
::
pair
<
dgl_id_t
,
dgl_id_t
>
entry
;
typedef
std
::
map
<
dgl_id_t
,
std
::
vector
<
entry
>>
csm
;
// Compressed Sparse Matrix
typedef
std
::
map
<
dgl_id_t
,
std
::
vector
<
entry
>>
csm
;
// Compressed Sparse Matrix
csm
adj
;
csm
adj
;
std
::
vector
<
entry
>
vec
;
std
::
vector
<
entry
>
vec
;
...
@@ -67,7 +71,7 @@ std::vector<Graph> GraphOp::DisjointPartitionByNum(const Graph* graph, int64_t n
...
@@ -67,7 +71,7 @@ std::vector<Graph> GraphOp::DisjointPartitionByNum(const Graph* graph, int64_t n
std
::
fill
(
sizes_data
,
sizes_data
+
num
,
graph
->
NumVertices
()
/
num
);
std
::
fill
(
sizes_data
,
sizes_data
+
num
,
graph
->
NumVertices
()
/
num
);
return
DisjointPartitionBySizes
(
graph
,
sizes
);
return
DisjointPartitionBySizes
(
graph
,
sizes
);
}
}
std
::
vector
<
Graph
>
GraphOp
::
DisjointPartitionBySizes
(
const
Graph
*
graph
,
IdArray
sizes
)
{
std
::
vector
<
Graph
>
GraphOp
::
DisjointPartitionBySizes
(
const
Graph
*
graph
,
IdArray
sizes
)
{
const
int64_t
len
=
sizes
->
shape
[
0
];
const
int64_t
len
=
sizes
->
shape
[
0
];
const
int64_t
*
sizes_data
=
static_cast
<
int64_t
*>
(
sizes
->
data
);
const
int64_t
*
sizes_data
=
static_cast
<
int64_t
*>
(
sizes
->
data
);
...
@@ -117,32 +121,6 @@ std::vector<Graph> GraphOp::DisjointPartitionBySizes(const Graph* graph, IdArray
...
@@ -117,32 +121,6 @@ std::vector<Graph> GraphOp::DisjointPartitionBySizes(const Graph* graph, IdArray
node_offset
+=
sizes_data
[
i
];
node_offset
+=
sizes_data
[
i
];
edge_offset
+=
num_edges
;
edge_offset
+=
num_edges
;
}
}
/*for (int64_t i = 0; i < len; ++i) {
rst[i].AddVertices(sizes_data[i]);
}
for (dgl_id_t eid = 0; eid < graph->num_edges_; ++eid) {
const dgl_id_t src = graph->all_edges_src_[eid];
const dgl_id_t dst = graph->all_edges_dst_[eid];
size_t src_select = 0, dst_select = 0;
for (size_t i = 1; i < cumsum.size(); ++i) { // TODO: replace with binary search
if (cumsum[i] > src) {
src_select = i;
break;
}
}
for (size_t i = 1; i < cumsum.size(); ++i) { // TODO: replace with binary search
if (cumsum[i] > dst) {
dst_select = i;
break;
}
}
if (src_select != dst_select) {
// the edge is ignored if across two partitions
continue;
}
const int64_t offset = cumsum[src_select - 1];
rst[src_select - 1].AddEdge(src - offset, dst - offset);
}*/
return
rst
;
return
rst
;
}
}
...
...
src/runtime/README.md
deleted
100644 → 0
View file @
3e76bcc0
# C API and runtime
Borrowed and adapted from TVM project.
Prev
1
2
Next
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