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
Show 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_
#define DGL_DGLGRAPH_H_
/*!
* Copyright (c) 2018 by Contributors
* \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"
namespace
dgl
{
...
...
@@ -17,7 +22,7 @@ class GraphOp;
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
* are uniquely identified by the two endpoints. Multi-edge is currently not
...
...
@@ -41,7 +46,7 @@ class Graph {
}
EdgeArray
;
/*! \brief default constructor */
Graph
(
bool
multigraph
=
false
)
:
is_multigraph_
(
multigraph
)
{}
explicit
Graph
(
bool
multigraph
=
false
)
:
is_multigraph_
(
multigraph
)
{}
/*! \brief default copy constructor */
Graph
(
const
Graph
&
other
)
=
default
;
...
...
@@ -347,4 +352,4 @@ struct Subgraph {
}
// 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_
#define DGL_GRAPH_OP_H_
#include <vector>
#include "graph.h"
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 @@
* used by compiled tvm operators, usually user do not need to use these
* function directly.
*/
#ifndef
TVM
_RUNTIME_C_BACKEND_API_H_
#define
TVM
_RUNTIME_C_BACKEND_API_H_
#ifndef
DGL
_RUNTIME_C_BACKEND_API_H_
#define
DGL
_RUNTIME_C_BACKEND_API_H_
#include "c_runtime_api.h"
...
...
@@ -136,4 +136,4 @@ TVM_DLL int TVMBackendRunOnce(void** handle,
#ifdef __cplusplus
}
// TVM_EXTERN_C
#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
* \file
tvm
/runtime/c_runtime_api.h
* \file
dgl
/runtime/c_runtime_api.h
* \brief TVM runtime library.
*
* The philosophy of TVM project is to customize the compilation
...
...
@@ -15,8 +15,8 @@
* - Use TVMFuncListGlobalNames to get global function name
* - Use TVMFuncCall to call these functions.
*/
#ifndef
TVM
_RUNTIME_C_RUNTIME_API_H_
#define
TVM
_RUNTIME_C_RUNTIME_API_H_
#ifndef
DGL
_RUNTIME_C_RUNTIME_API_H_
#define
DGL
_RUNTIME_C_RUNTIME_API_H_
// Macros to do weak linking
#ifdef _MSC_VER
...
...
@@ -530,4 +530,4 @@ TVM_DLL int TVMStreamStreamSynchronize(int device_type,
#ifdef __cplusplus
}
// TVM_EXTERN_C
#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
* \file
tvm
/runtime/device_api.h
* \file
dgl
/runtime/device_api.h
* \brief Abstract device memory management API
*/
#ifndef
TVM
_RUNTIME_DEVICE_API_H_
#define
TVM
_RUNTIME_DEVICE_API_H_
#ifndef
DGL
_RUNTIME_DEVICE_API_H_
#define
DGL
_RUNTIME_DEVICE_API_H_
#include <string>
#include "packed_func.h"
...
...
@@ -180,4 +180,4 @@ class DeviceAPI {
constexpr
int
kRPCSessMask
=
128
;
}
// namespace runtime
}
// 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
* \file
tvm
/runtime/module.h
* \file
dgl
/runtime/module.h
* \brief Runtime container of the functions generated by TVM,
* This is used to support dynamically link, load and save
* functions from different convention under unified API.
*/
#ifndef
TVM
_RUNTIME_MODULE_H_
#define
TVM
_RUNTIME_MODULE_H_
#ifndef
DGL
_RUNTIME_MODULE_H_
#define
DGL
_RUNTIME_MODULE_H_
#include <dmlc/io.h>
#include <memory>
...
...
@@ -174,4 +174,4 @@ inline const ModuleNode* Module::operator->() const {
}
// namespace tvm
#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
* \file
tvm
/runtime/ndarray.h
* \file
dgl
/runtime/ndarray.h
* \brief Abstract device memory management API
*/
#ifndef
TVM
_RUNTIME_NDARRAY_H_
#define
TVM
_RUNTIME_NDARRAY_H_
#ifndef
DGL
_RUNTIME_NDARRAY_H_
#define
DGL
_RUNTIME_NDARRAY_H_
#include <atomic>
#include <vector>
...
...
@@ -422,4 +422,4 @@ inline bool NDArray::Load(dmlc::Stream* strm) {
}
// namespace runtime
}
// 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
* \file
tvm
/runtime/packed_func.h
* \file
dgl
/runtime/packed_func.h
* \brief Type-erased function used across TVM API.
*/
#ifndef
TVM
_RUNTIME_PACKED_FUNC_H_
#define
TVM
_RUNTIME_PACKED_FUNC_H_
#ifndef
DGL
_RUNTIME_PACKED_FUNC_H_
#define
DGL
_RUNTIME_PACKED_FUNC_H_
#include <dmlc/logging.h>
#include <functional>
...
...
@@ -1212,4 +1212,4 @@ inline PackedFunc Module::GetFunction(const std::string& name, bool query_import
}
}
// namespace runtime
}
// 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
* \file
tvm
/runtime/registry.h
* \file
dgl
/runtime/registry.h
* \brief This file defines the TVM global function registry.
*
* The registered functions will be made available to front-end
...
...
@@ -22,8 +22,8 @@
* });
* \endcode
*/
#ifndef
TVM
_RUNTIME_REGISTRY_H_
#define
TVM
_RUNTIME_REGISTRY_H_
#ifndef
DGL
_RUNTIME_REGISTRY_H_
#define
DGL
_RUNTIME_REGISTRY_H_
#include <string>
#include <vector>
...
...
@@ -141,4 +141,4 @@ class Registry {
}
// namespace runtime
}
// 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
* \file
tvm
/runtime/serializer.h
* \file
dgl
/runtime/serializer.h
* \brief Serializer extension to support TVM data types
* Include this file to enable serialization of DLDataType, DLContext
*/
#ifndef
TVM
_RUNTIME_SERIALIZER_H_
#define
TVM
_RUNTIME_SERIALIZER_H_
#ifndef
DGL
_RUNTIME_SERIALIZER_H_
#define
DGL
_RUNTIME_SERIALIZER_H_
#include <dmlc/io.h>
#include <dmlc/serializer.h>
...
...
@@ -48,4 +48,4 @@ struct Handler<DLContext> {
}
// namespace serializer
}
// 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
* \file
tvm
/runtime/threading_backend.h
* \file
dgl
/runtime/threading_backend.h
* \brief Utilities for manipulating thread pool threads.
*/
#ifndef
TVM
_RUNTIME_THREADING_BACKEND_H_
#define
TVM
_RUNTIME_THREADING_BACKEND_H_
#ifndef
DGL
_RUNTIME_THREADING_BACKEND_H_
#define
DGL
_RUNTIME_THREADING_BACKEND_H_
#include <functional>
#include <memory>
...
...
@@ -82,4 +82,4 @@ int MaxConcurrency();
}
// namespace runtime
}
// 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
* \file
tvm
/runtime/util.h
* \file
dgl
/runtime/util.h
* \brief Useful runtime util.
*/
#ifndef
TVM
_RUNTIME_UTIL_H_
#define
TVM
_RUNTIME_UTIL_H_
#ifndef
DGL
_RUNTIME_UTIL_H_
#define
DGL
_RUNTIME_UTIL_H_
#include "c_runtime_api.h"
...
...
@@ -50,4 +50,4 @@ enum TVMStructFieldKind : int {
}
// namespace intrinsic
}
// namespace ir
}
// 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_
#define DGL_SCHEDULER_H_
#include "runtime/ndarray.h"
#include <vector>
#include "runtime/ndarray.h"
namespace
dgl
{
...
...
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"
using
tvm
::
runtime
::
TVMArgs
;
...
...
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_
#define DGL_C_API_COMMON_H_
...
...
@@ -12,11 +16,19 @@ namespace dgl {
// Graph handler type
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
...
...
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 <unordered_map>
#include <set>
#include <functional>
#include <dgl/graph.h>
namespace
dgl
{
namespace
{
...
...
@@ -461,7 +465,8 @@ Subgraph Graph::EdgeSubgraph(IdArray eids) const {
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
));
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_op.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 <algorithm>
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
::
map
<
dgl_id_t
,
std
::
vector
<
entry
>>
csm
;
// Compressed Sparse Matrix
...
...
@@ -117,32 +121,6 @@ std::vector<Graph> GraphOp::DisjointPartitionBySizes(const Graph* graph, IdArray
node_offset
+=
sizes_data
[
i
];
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
;
}
...
...
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