Unverified Commit bcd37684 authored by Hongzhi (Steve), Chen's avatar Hongzhi (Steve), Chen Committed by GitHub
Browse files

[Misc] Replace /*! with /**. (#4823)



* replace

* blabla

* balbla

* blabla
Co-authored-by: default avatarSteve <ubuntu@ip-172-31-34-29.ap-northeast-1.compute.internal>
parent 619d735d
/*! /**
* Copyright (c) 2019 by Contributors * Copyright (c) 2019 by Contributors
* @file dgl/lazy.h * @file dgl/lazy.h
* @brief Lazy object that will be materialized only when being queried. * @brief Lazy object that will be materialized only when being queried.
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
namespace dgl { namespace dgl {
/*! /**
* @brief Lazy object that will be materialized only when being queried. * @brief Lazy object that will be materialized only when being queried.
* *
* The object should be immutable -- no mutation once materialized. * The object should be immutable -- no mutation once materialized.
...@@ -19,18 +19,18 @@ namespace dgl { ...@@ -19,18 +19,18 @@ namespace dgl {
template <typename T> template <typename T>
class Lazy { class Lazy {
public: public:
/*!\brief default constructor to construct a lazy object */ /** @brief default constructor to construct a lazy object */
Lazy() {} Lazy() {}
/*! /**
* @brief constructor to construct an object with given value (non-lazy case) * @brief constructor to construct an object with given value (non-lazy case)
*/ */
explicit Lazy(const T& val) : ptr_(new T(val)) {} explicit Lazy(const T& val) : ptr_(new T(val)) {}
/*!\brief destructor */ /** @brief destructor */
~Lazy() = default; ~Lazy() = default;
/*! /**
* @brief Get the value of this object. If the object has not been * @brief Get the value of this object. If the object has not been
* instantiated, using the provided function to create it. * instantiated, using the provided function to create it.
* @param fn The creator function. * @param fn The creator function.
...@@ -45,7 +45,7 @@ class Lazy { ...@@ -45,7 +45,7 @@ class Lazy {
} }
private: private:
/*!\brief the internal data pointer */ /** @brief the internal data pointer */
std::shared_ptr<T> ptr_{nullptr}; std::shared_ptr<T> ptr_{nullptr};
}; };
......
/*! /**
* Copyright (c) 2019 by Contributors * Copyright (c) 2019 by Contributors
* @file dgl/nodeflow.h * @file dgl/nodeflow.h
* @brief DGL NodeFlow class. * @brief DGL NodeFlow class.
...@@ -17,7 +17,7 @@ namespace dgl { ...@@ -17,7 +17,7 @@ namespace dgl {
class ImmutableGraph; class ImmutableGraph;
/*! /**
* @brief A NodeFlow graph stores the sampling results for a sampler that * @brief A NodeFlow graph stores the sampling results for a sampler that
* samples nodes/edges in layers. * samples nodes/edges in layers.
* *
...@@ -26,21 +26,21 @@ class ImmutableGraph; ...@@ -26,21 +26,21 @@ class ImmutableGraph;
* node and edge mapping from the NodeFlow graph to the parent graph. * node and edge mapping from the NodeFlow graph to the parent graph.
*/ */
struct NodeFlowObject : public runtime::Object { struct NodeFlowObject : public runtime::Object {
/*! @brief The graph. */ /** @brief The graph. */
GraphPtr graph; GraphPtr graph;
/*! /**
* @brief the offsets of each layer. * @brief the offsets of each layer.
*/ */
IdArray layer_offsets; IdArray layer_offsets;
/*! /**
* @brief the offsets of each flow. * @brief the offsets of each flow.
*/ */
IdArray flow_offsets; IdArray flow_offsets;
/*! /**
* @brief The node mapping from the NodeFlow graph to the parent graph. * @brief The node mapping from the NodeFlow graph to the parent graph.
*/ */
IdArray node_mapping; IdArray node_mapping;
/*! /**
* @brief The edge mapping from the NodeFlow graph to the parent graph. * @brief The edge mapping from the NodeFlow graph to the parent graph.
*/ */
IdArray edge_mapping; IdArray edge_mapping;
...@@ -54,13 +54,13 @@ class NodeFlow : public runtime::ObjectRef { ...@@ -54,13 +54,13 @@ class NodeFlow : public runtime::ObjectRef {
public: public:
DGL_DEFINE_OBJECT_REF_METHODS(NodeFlow, runtime::ObjectRef, NodeFlowObject); DGL_DEFINE_OBJECT_REF_METHODS(NodeFlow, runtime::ObjectRef, NodeFlowObject);
/*! @brief create a new nodeflow reference */ /** @brief create a new nodeflow reference */
static NodeFlow Create() { static NodeFlow Create() {
return NodeFlow(std::make_shared<NodeFlowObject>()); return NodeFlow(std::make_shared<NodeFlowObject>());
} }
}; };
/*! /**
* @brief Get a slice on a graph that represents a NodeFlow. * @brief Get a slice on a graph that represents a NodeFlow.
* *
* The entire block has to be taken as a slice. Users have to specify the * The entire block has to be taken as a slice. Users have to specify the
......
/*! /**
* Copyright (c) 2019 by Contributors * Copyright (c) 2019 by Contributors
* @file packed_func_ext.h * @file packed_func_ext.h
* @brief Extension package to PackedFunc * @brief Extension package to PackedFunc
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
namespace dgl { namespace dgl {
namespace runtime { namespace runtime {
/*! /**
* @brief Runtime type checker for node type. * @brief Runtime type checker for node type.
* @tparam T the type to be checked. * @tparam T the type to be checked.
*/ */
......
/*! /**
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* @file dgl/random.h * @file dgl/random.h
* @brief Random number generators * @brief Random number generators
...@@ -35,36 +35,36 @@ inline uint32_t GetThreadId() { ...@@ -35,36 +35,36 @@ inline uint32_t GetThreadId() {
}; // namespace }; // namespace
/*! /**
* @brief Thread-local Random Number Generator class * @brief Thread-local Random Number Generator class
*/ */
class RandomEngine { class RandomEngine {
public: public:
/*! @brief Constructor with default seed */ /** @brief Constructor with default seed */
RandomEngine() { RandomEngine() {
std::random_device rd; std::random_device rd;
SetSeed(rd()); SetSeed(rd());
} }
/*! @brief Constructor with given seed */ /** @brief Constructor with given seed */
explicit RandomEngine(uint32_t seed) { SetSeed(seed); } explicit RandomEngine(uint32_t seed) { SetSeed(seed); }
/*! @brief Get the thread-local random number generator instance */ /** @brief Get the thread-local random number generator instance */
static RandomEngine* ThreadLocal() { static RandomEngine* ThreadLocal() {
return dmlc::ThreadLocalStore<RandomEngine>::Get(); return dmlc::ThreadLocalStore<RandomEngine>::Get();
} }
/*! /**
* @brief Set the seed of this random number generator * @brief Set the seed of this random number generator
*/ */
void SetSeed(uint32_t seed) { rng_.seed(seed + GetThreadId()); } void SetSeed(uint32_t seed) { rng_.seed(seed + GetThreadId()); }
/*! /**
* @brief Generate an arbitrary random 32-bit integer. * @brief Generate an arbitrary random 32-bit integer.
*/ */
int32_t RandInt32() { return static_cast<int32_t>(rng_()); } int32_t RandInt32() { return static_cast<int32_t>(rng_()); }
/*! /**
* @brief Generate a uniform random integer in [0, upper) * @brief Generate a uniform random integer in [0, upper)
*/ */
template <typename T> template <typename T>
...@@ -72,7 +72,7 @@ class RandomEngine { ...@@ -72,7 +72,7 @@ class RandomEngine {
return RandInt<T>(0, upper); return RandInt<T>(0, upper);
} }
/*! /**
* @brief Generate a uniform random integer in [lower, upper) * @brief Generate a uniform random integer in [lower, upper)
*/ */
template <typename T> template <typename T>
...@@ -82,7 +82,7 @@ class RandomEngine { ...@@ -82,7 +82,7 @@ class RandomEngine {
return dist(rng_); return dist(rng_);
} }
/*! /**
* @brief Generate a uniform random float in [0, 1) * @brief Generate a uniform random float in [0, 1)
*/ */
template <typename T> template <typename T>
...@@ -90,7 +90,7 @@ class RandomEngine { ...@@ -90,7 +90,7 @@ class RandomEngine {
return Uniform<T>(0., 1.); return Uniform<T>(0., 1.);
} }
/*! /**
* @brief Generate a uniform random float in [lower, upper) * @brief Generate a uniform random float in [lower, upper)
*/ */
template <typename T> template <typename T>
...@@ -102,7 +102,7 @@ class RandomEngine { ...@@ -102,7 +102,7 @@ class RandomEngine {
return dist(rng_); return dist(rng_);
} }
/*! /**
* @brief Pick a random integer between 0 to N-1 according to given * @brief Pick a random integer between 0 to N-1 according to given
* probabilities. * probabilities.
* @tparam IdxType Return integer type. * @tparam IdxType Return integer type.
...@@ -113,7 +113,7 @@ class RandomEngine { ...@@ -113,7 +113,7 @@ class RandomEngine {
template <typename IdxType> template <typename IdxType>
IdxType Choice(FloatArray prob); IdxType Choice(FloatArray prob);
/*! /**
* @brief Pick random integers between 0 to N-1 according to given * @brief Pick random integers between 0 to N-1 according to given
* probabilities * probabilities
* *
...@@ -130,7 +130,7 @@ class RandomEngine { ...@@ -130,7 +130,7 @@ class RandomEngine {
template <typename IdxType, typename FloatType> template <typename IdxType, typename FloatType>
void Choice(IdxType num, FloatArray prob, IdxType* out, bool replace = true); void Choice(IdxType num, FloatArray prob, IdxType* out, bool replace = true);
/*! /**
* @brief Pick random integers between 0 to N-1 according to given * @brief Pick random integers between 0 to N-1 according to given
* probabilities * probabilities
* *
...@@ -153,7 +153,7 @@ class RandomEngine { ...@@ -153,7 +153,7 @@ class RandomEngine {
return ret; return ret;
} }
/*! /**
* @brief Pick random integers from population by uniform distribution. * @brief Pick random integers from population by uniform distribution.
* *
* If replace is false, num must not be larger than population. * If replace is false, num must not be larger than population.
...@@ -168,7 +168,7 @@ class RandomEngine { ...@@ -168,7 +168,7 @@ class RandomEngine {
void UniformChoice( void UniformChoice(
IdxType num, IdxType population, IdxType* out, bool replace = true); IdxType num, IdxType population, IdxType* out, bool replace = true);
/*! /**
* @brief Pick random integers from population by uniform distribution. * @brief Pick random integers from population by uniform distribution.
* *
* If replace is false, num must not be larger than population. * If replace is false, num must not be larger than population.
...@@ -189,7 +189,7 @@ class RandomEngine { ...@@ -189,7 +189,7 @@ class RandomEngine {
return ret; return ret;
} }
/*! /**
* @brief Pick random integers with different probability for different * @brief Pick random integers with different probability for different
* segments. * segments.
* *
...@@ -223,7 +223,7 @@ class RandomEngine { ...@@ -223,7 +223,7 @@ class RandomEngine {
IdxType num, const IdxType* split, FloatArray bias, IdxType* out, IdxType num, const IdxType* split, FloatArray bias, IdxType* out,
bool replace = true); bool replace = true);
/*! /**
* @brief Pick random integers with different probability for different * @brief Pick random integers with different probability for different
* segments. * segments.
* *
......
/*! /**
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* @file dgl/runtime/c_backend_api.h * @file dgl/runtime/c_backend_api.h
* @brief DGL runtime backend API. * @brief DGL runtime backend API.
...@@ -17,7 +17,7 @@ extern "C" { ...@@ -17,7 +17,7 @@ extern "C" {
#endif #endif
// Backend related functions. // Backend related functions.
/*! /**
* @brief Backend function for modules to get function * @brief Backend function for modules to get function
* from its environment mod_node (its imports and global function). * from its environment mod_node (its imports and global function).
* The user do should not call DGLFuncFree on func. * The user do should not call DGLFuncFree on func.
...@@ -29,7 +29,7 @@ extern "C" { ...@@ -29,7 +29,7 @@ extern "C" {
*/ */
DGL_DLL int DGLBackendGetFuncFromEnv( DGL_DLL int DGLBackendGetFuncFromEnv(
void* mod_node, const char* func_name, DGLFunctionHandle* out); void* mod_node, const char* func_name, DGLFunctionHandle* out);
/*! /**
* @brief Backend function to register system-wide library symbol. * @brief Backend function to register system-wide library symbol.
* *
* @param name The name of the symbol * @param name The name of the symbol
...@@ -38,7 +38,7 @@ DGL_DLL int DGLBackendGetFuncFromEnv( ...@@ -38,7 +38,7 @@ DGL_DLL int DGLBackendGetFuncFromEnv(
*/ */
DGL_DLL int DGLBackendRegisterSystemLibSymbol(const char* name, void* ptr); DGL_DLL int DGLBackendRegisterSystemLibSymbol(const char* name, void* ptr);
/*! /**
* @brief Backend function to allocate temporal workspace. * @brief Backend function to allocate temporal workspace.
* *
* @note The result allocate spaced is ensured to be aligned to * @note The result allocate spaced is ensured to be aligned to
...@@ -57,7 +57,7 @@ DGL_DLL void* DGLBackendAllocWorkspace( ...@@ -57,7 +57,7 @@ DGL_DLL void* DGLBackendAllocWorkspace(
int device_type, int device_id, uint64_t nbytes, int dtype_code_hint, int device_type, int device_id, uint64_t nbytes, int dtype_code_hint,
int dtype_bits_hint); int dtype_bits_hint);
/*! /**
* @brief Backend function to free temporal workspace. * @brief Backend function to free temporal workspace.
* *
* @param ptr The result allocated space pointer. * @param ptr The result allocated space pointer.
...@@ -69,19 +69,19 @@ DGL_DLL void* DGLBackendAllocWorkspace( ...@@ -69,19 +69,19 @@ DGL_DLL void* DGLBackendAllocWorkspace(
*/ */
DGL_DLL int DGLBackendFreeWorkspace(int device_type, int device_id, void* ptr); DGL_DLL int DGLBackendFreeWorkspace(int device_type, int device_id, void* ptr);
/*! /**
* @brief Environment for DGL parallel task. * @brief Environment for DGL parallel task.
*/ */
typedef struct { typedef struct {
/*! /**
* @brief Auxiliary used for synchronization * @brief Auxiliary used for synchronization
*/ */
void* sync_handle; void* sync_handle;
/*! @brief total amount of task */ /** @brief total amount of task */
int32_t num_task; int32_t num_task;
} DGLParallelGroupEnv; } DGLParallelGroupEnv;
/*! /**
* @brief The callback function to execute a parallel lambda * @brief The callback function to execute a parallel lambda
* @param task_id the task id of the function. * @param task_id the task id of the function.
* @param penv The parallel environment backs the execution. * @param penv The parallel environment backs the execution.
...@@ -90,7 +90,7 @@ typedef struct { ...@@ -90,7 +90,7 @@ typedef struct {
typedef int (*FDGLParallelLambda)( typedef int (*FDGLParallelLambda)(
int task_id, DGLParallelGroupEnv* penv, void* cdata); int task_id, DGLParallelGroupEnv* penv, void* cdata);
/*! /**
* @brief Backend function for running parallel jobs. * @brief Backend function for running parallel jobs.
* *
* @param flambda The parallel function to be launched. * @param flambda The parallel function to be launched.
...@@ -103,7 +103,7 @@ typedef int (*FDGLParallelLambda)( ...@@ -103,7 +103,7 @@ typedef int (*FDGLParallelLambda)(
DGL_DLL int DGLBackendParallelLaunch( DGL_DLL int DGLBackendParallelLaunch(
FDGLParallelLambda flambda, void* cdata, int num_task); FDGLParallelLambda flambda, void* cdata, int num_task);
/*! /**
* @brief BSP barrrier between parallel threads * @brief BSP barrrier between parallel threads
* @param task_id the task id of the function. * @param task_id the task id of the function.
* @param penv The parallel environment backs the execution. * @param penv The parallel environment backs the execution.
...@@ -111,7 +111,7 @@ DGL_DLL int DGLBackendParallelLaunch( ...@@ -111,7 +111,7 @@ DGL_DLL int DGLBackendParallelLaunch(
*/ */
DGL_DLL int DGLBackendParallelBarrier(int task_id, DGLParallelGroupEnv* penv); DGL_DLL int DGLBackendParallelBarrier(int task_id, DGLParallelGroupEnv* penv);
/*! /**
* @brief Simple static initialization fucntion. * @brief Simple static initialization fucntion.
* Run f once and set handle to be not null. * Run f once and set handle to be not null.
* This function is mainly used for test purpose. * This function is mainly used for test purpose.
......
/*! /**
* Copyright (c) 2019 by Contributors * Copyright (c) 2019 by Contributors
* @file dgl/runtime/c_object_api.h * @file dgl/runtime/c_object_api.h
* *
...@@ -16,17 +16,17 @@ ...@@ -16,17 +16,17 @@
extern "C" { extern "C" {
#endif #endif
/*! @brief handle to object */ /** @brief handle to object */
typedef void* ObjectHandle; typedef void* ObjectHandle;
/*! /**
* @brief free the object handle * @brief free the object handle
* @param handle The object handle to be freed. * @param handle The object handle to be freed.
* @return 0 when success, -1 when failure happens * @return 0 when success, -1 when failure happens
*/ */
DGL_DLL int DGLObjectFree(ObjectHandle handle); DGL_DLL int DGLObjectFree(ObjectHandle handle);
/*! /**
* @brief Convert type key to type index. * @brief Convert type key to type index.
* @param type_key The key of the type. * @param type_key The key of the type.
* @param out_index the corresponding type index. * @param out_index the corresponding type index.
...@@ -34,7 +34,7 @@ DGL_DLL int DGLObjectFree(ObjectHandle handle); ...@@ -34,7 +34,7 @@ DGL_DLL int DGLObjectFree(ObjectHandle handle);
*/ */
DGL_DLL int DGLObjectTypeKey2Index(const char* type_key, int* out_index); DGL_DLL int DGLObjectTypeKey2Index(const char* type_key, int* out_index);
/*! /**
* @brief Get runtime type index of the object. * @brief Get runtime type index of the object.
* @param handle the object handle. * @param handle the object handle.
* @param out_index the corresponding type index. * @param out_index the corresponding type index.
...@@ -42,7 +42,7 @@ DGL_DLL int DGLObjectTypeKey2Index(const char* type_key, int* out_index); ...@@ -42,7 +42,7 @@ DGL_DLL int DGLObjectTypeKey2Index(const char* type_key, int* out_index);
*/ */
DGL_DLL int DGLObjectGetTypeIndex(ObjectHandle handle, int* out_index); DGL_DLL int DGLObjectGetTypeIndex(ObjectHandle handle, int* out_index);
/*! /**
* @brief get attributes given key * @brief get attributes given key
* @param handle The object handle * @param handle The object handle
* @param key The attribute name * @param key The attribute name
...@@ -56,7 +56,7 @@ DGL_DLL int DGLObjectGetAttr( ...@@ -56,7 +56,7 @@ DGL_DLL int DGLObjectGetAttr(
ObjectHandle handle, const char* key, DGLValue* out_value, ObjectHandle handle, const char* key, DGLValue* out_value,
int* out_type_code, int* out_success); int* out_type_code, int* out_success);
/*! /**
* @brief get attributes names in the object. * @brief get attributes names in the object.
* @param handle The object handle * @param handle The object handle
* @param out_size The number of functions * @param out_size The number of functions
......
/*! /**
* Copyright (c) 2016-2022 by Contributors * Copyright (c) 2016-2022 by Contributors
* @file dgl/runtime/c_runtime_api.h * @file dgl/runtime/c_runtime_api.h
* @brief DGL runtime library. * @brief DGL runtime library.
...@@ -41,10 +41,10 @@ extern "C" { ...@@ -41,10 +41,10 @@ extern "C" {
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
/*! @brief type of array index. */ /** @brief type of array index. */
typedef int64_t dgl_index_t; typedef int64_t dgl_index_t;
/*! /**
* @brief The device type in DGLContext. * @brief The device type in DGLContext.
*/ */
#ifdef __cplusplus #ifdef __cplusplus
...@@ -52,14 +52,14 @@ typedef enum : int32_t { ...@@ -52,14 +52,14 @@ typedef enum : int32_t {
#else #else
typedef enum { typedef enum {
#endif #endif
/*! @brief CPU device */ /** @brief CPU device */
kDGLCPU = 1, kDGLCPU = 1,
/*! @brief CUDA GPU device */ /** @brief CUDA GPU device */
kDGLCUDA = 2, kDGLCUDA = 2,
// add more devices once supported // add more devices once supported
} DGLDeviceType; } DGLDeviceType;
/*! /**
* @brief The object type code is used in DGL FFI to indicate the types of * @brief The object type code is used in DGL FFI to indicate the types of
* objects passed between C and Python. * objects passed between C and Python.
*/ */
...@@ -90,22 +90,22 @@ typedef enum { ...@@ -90,22 +90,22 @@ typedef enum {
kExtEnd = 128U kExtEnd = 128U
} DGLObjectTypeCode; } DGLObjectTypeCode;
/*! /**
* @brief The type code options DGLDataType. * @brief The type code options DGLDataType.
*/ */
typedef enum { typedef enum {
/*! @brief signed integer */ /** @brief signed integer */
kDGLInt = 0U, kDGLInt = 0U,
/*! @brief unsigned integer */ /** @brief unsigned integer */
kDGLUInt = 1U, kDGLUInt = 1U,
/*! @brief IEEE floating point */ /** @brief IEEE floating point */
kDGLFloat = 2U, kDGLFloat = 2U,
/*! @brief bfloat16 */ /** @brief bfloat16 */
kDGLBfloat = 4U, kDGLBfloat = 4U,
// add more data types if we are going to support them // add more data types if we are going to support them
} DGLDataTypeCode; } DGLDataTypeCode;
/*! /**
* @brief The data type the tensor can hold. The data type is assumed to follow * @brief The data type the tensor can hold. The data type is assumed to follow
* the native endian-ness. An explicit error message should be raised when * the native endian-ness. An explicit error message should be raised when
* attempting to export an array with non-native endianness * attempting to export an array with non-native endianness
...@@ -116,39 +116,39 @@ typedef enum { ...@@ -116,39 +116,39 @@ typedef enum {
* - int8: type_code = 0, bits = 8, lanes=1 * - int8: type_code = 0, bits = 8, lanes=1
*/ */
typedef struct { typedef struct {
/*! /**
* @brief Type code of base types. * @brief Type code of base types.
* We keep it uint8_t instead of DGLDataTypeCode for minimal memory * We keep it uint8_t instead of DGLDataTypeCode for minimal memory
* footprint, but the value should be one of DGLDataTypeCode enum values. * footprint, but the value should be one of DGLDataTypeCode enum values.
* */ * */
uint8_t code; uint8_t code;
/*! /**
* @brief Number of bits, common choices are 8, 16, 32. * @brief Number of bits, common choices are 8, 16, 32.
*/ */
uint8_t bits; uint8_t bits;
/*! @brief Number of lanes in the type, used for vector types. */ /** @brief Number of lanes in the type, used for vector types. */
uint16_t lanes; uint16_t lanes;
} DGLDataType; } DGLDataType;
/*! /**
* @brief The Device information, abstract away common device types. * @brief The Device information, abstract away common device types.
*/ */
typedef struct { typedef struct {
/*! @brief The device type used in the device. */ /** @brief The device type used in the device. */
DGLDeviceType device_type; DGLDeviceType device_type;
/*! /**
* @brief The device index. * @brief The device index.
* For vanilla CPU memory, pinned memory, or managed memory, this is set to 0. * For vanilla CPU memory, pinned memory, or managed memory, this is set to 0.
*/ */
int32_t device_id; int32_t device_id;
} DGLContext; } DGLContext;
/*! /**
* @brief The tensor array stucture to DGL API. * @brief The tensor array stucture to DGL API.
* The structure is heavily inspired by DLTensor from DLPack. * The structure is heavily inspired by DLTensor from DLPack.
*/ */
typedef struct { typedef struct {
/*! /**
* @brief The data pointer points to the allocated data. * @brief The data pointer points to the allocated data.
* *
* Depending on the device context, it can be a CPU pointer, or a CUDA * Depending on the device context, it can be a CPU pointer, or a CUDA
...@@ -178,27 +178,27 @@ typedef struct { ...@@ -178,27 +178,27 @@ typedef struct {
* @endcode * @endcode
*/ */
void* data; void* data;
/*! @brief The device of the tensor */ /** @brief The device of the tensor */
DGLContext ctx; DGLContext ctx;
/*! @brief Number of dimensions */ /** @brief Number of dimensions */
int32_t ndim; int32_t ndim;
/*! @brief The data type of the pointer*/ /** @brief The data type of the pointer*/
DGLDataType dtype; DGLDataType dtype;
/*! @brief The shape of the tensor */ /** @brief The shape of the tensor */
int64_t* shape; int64_t* shape;
/*! /**
* @brief strides of the tensor (in number of elements, not bytes) * @brief strides of the tensor (in number of elements, not bytes)
* can be NULL, indicating tensor is compact and row-majored. * can be NULL, indicating tensor is compact and row-majored.
*/ */
int64_t* strides; int64_t* strides;
/*! @brief The offset in bytes to the beginning pointer to data */ /** @brief The offset in bytes to the beginning pointer to data */
uint64_t byte_offset; uint64_t byte_offset;
} DGLArray; } DGLArray;
/*! @brief the array handle */ /** @brief the array handle */
typedef DGLArray* DGLArrayHandle; typedef DGLArray* DGLArrayHandle;
/*! /**
* @brief Union type of values * @brief Union type of values
* being passed through API and function calls. * being passed through API and function calls.
*/ */
...@@ -211,7 +211,7 @@ typedef union { ...@@ -211,7 +211,7 @@ typedef union {
DGLContext v_ctx; DGLContext v_ctx;
} DGLValue; } DGLValue;
/*! /**
* @brief Byte array type used to pass in byte array * @brief Byte array type used to pass in byte array
* When kBytes is used as data type. * When kBytes is used as data type.
*/ */
...@@ -220,26 +220,26 @@ typedef struct { ...@@ -220,26 +220,26 @@ typedef struct {
size_t size; size_t size;
} DGLByteArray; } DGLByteArray;
/*! @brief Handle to DGL runtime modules. */ /** @brief Handle to DGL runtime modules. */
typedef void* DGLModuleHandle; typedef void* DGLModuleHandle;
/*! @brief Handle to packed function handle. */ /** @brief Handle to packed function handle. */
typedef void* DGLFunctionHandle; typedef void* DGLFunctionHandle;
/*! @brief Handle to hold return value. */ /** @brief Handle to hold return value. */
typedef void* DGLRetValueHandle; typedef void* DGLRetValueHandle;
/*! /**
* @brief The stream that is specific to device * @brief The stream that is specific to device
* can be NULL, which indicates the default one. * can be NULL, which indicates the default one.
*/ */
typedef void* DGLStreamHandle; typedef void* DGLStreamHandle;
/*! /**
* @brief Used for implementing C API function. * @brief Used for implementing C API function.
* Set last error message before return. * Set last error message before return.
* @param msg The error message to be set. * @param msg The error message to be set.
*/ */
DGL_DLL void DGLAPISetLastError(const char* msg); DGL_DLL void DGLAPISetLastError(const char* msg);
/*! /**
* @brief return str message of the last error * @brief return str message of the last error
* all function in this file will return 0 when success * all function in this file will return 0 when success
* and -1 when an error occured, * and -1 when an error occured,
...@@ -249,7 +249,7 @@ DGL_DLL void DGLAPISetLastError(const char* msg); ...@@ -249,7 +249,7 @@ DGL_DLL void DGLAPISetLastError(const char* msg);
* \return error info * \return error info
*/ */
DGL_DLL const char* DGLGetLastError(void); DGL_DLL const char* DGLGetLastError(void);
/*! /**
* @brief Load module from file. * @brief Load module from file.
* @param file_name The file name to load the module from. * @param file_name The file name to load the module from.
* @param format The format of the module. * @param format The format of the module.
...@@ -262,7 +262,7 @@ DGL_DLL const char* DGLGetLastError(void); ...@@ -262,7 +262,7 @@ DGL_DLL const char* DGLGetLastError(void);
DGL_DLL int DGLModLoadFromFile( DGL_DLL int DGLModLoadFromFile(
const char* file_name, const char* format, DGLModuleHandle* out); const char* file_name, const char* format, DGLModuleHandle* out);
/*! /**
* @brief Add dep to mod's dependency. * @brief Add dep to mod's dependency.
* This allows functions in this module to use modules. * This allows functions in this module to use modules.
* *
...@@ -272,7 +272,7 @@ DGL_DLL int DGLModLoadFromFile( ...@@ -272,7 +272,7 @@ DGL_DLL int DGLModLoadFromFile(
*/ */
DGL_DLL int DGLModImport(DGLModuleHandle mod, DGLModuleHandle dep); DGL_DLL int DGLModImport(DGLModuleHandle mod, DGLModuleHandle dep);
/*! /**
* @brief Get function from the module. * @brief Get function from the module.
* @param mod The module handle. * @param mod The module handle.
* @param func_name The name of the function. * @param func_name The name of the function.
...@@ -284,7 +284,7 @@ DGL_DLL int DGLModGetFunction( ...@@ -284,7 +284,7 @@ DGL_DLL int DGLModGetFunction(
DGLModuleHandle mod, const char* func_name, int query_imports, DGLModuleHandle mod, const char* func_name, int query_imports,
DGLFunctionHandle* out); DGLFunctionHandle* out);
/*! /**
* @brief Free front-end extension type resource. * @brief Free front-end extension type resource.
* @param handle The extension handle. * @param handle The extension handle.
* @param type_code The type of of the extension type. * @param type_code The type of of the extension type.
...@@ -292,7 +292,7 @@ DGL_DLL int DGLModGetFunction( ...@@ -292,7 +292,7 @@ DGL_DLL int DGLModGetFunction(
*/ */
DGL_DLL int DGLExtTypeFree(void* handle, int type_code); DGL_DLL int DGLExtTypeFree(void* handle, int type_code);
/*! /**
* @brief Free the Module * @brief Free the Module
* @param mod The module to be freed. * @param mod The module to be freed.
* *
...@@ -305,14 +305,14 @@ DGL_DLL int DGLExtTypeFree(void* handle, int type_code); ...@@ -305,14 +305,14 @@ DGL_DLL int DGLExtTypeFree(void* handle, int type_code);
*/ */
DGL_DLL int DGLModFree(DGLModuleHandle mod); DGL_DLL int DGLModFree(DGLModuleHandle mod);
/*! /**
* @brief Free the function when it is no longer needed. * @brief Free the function when it is no longer needed.
* @param func The function handle * @param func The function handle
* @return 0 when success, -1 when failure happens * @return 0 when success, -1 when failure happens
*/ */
DGL_DLL int DGLFuncFree(DGLFunctionHandle func); DGL_DLL int DGLFuncFree(DGLFunctionHandle func);
/*! /**
* @brief Call a Packed DGL Function. * @brief Call a Packed DGL Function.
* *
* @param func node handle of the function. * @param func node handle of the function.
...@@ -336,7 +336,7 @@ DGL_DLL int DGLFuncCall( ...@@ -336,7 +336,7 @@ DGL_DLL int DGLFuncCall(
DGLFunctionHandle func, DGLValue* arg_values, int* type_codes, int num_args, DGLFunctionHandle func, DGLValue* arg_values, int* type_codes, int num_args,
DGLValue* ret_val, int* ret_type_code); DGLValue* ret_val, int* ret_type_code);
/*! /**
* @brief Set the return value of DGLPackedCFunc. * @brief Set the return value of DGLPackedCFunc.
* *
* This function is called by DGLPackedCFunc to set the return value. * This function is called by DGLPackedCFunc to set the return value.
...@@ -350,7 +350,7 @@ DGL_DLL int DGLFuncCall( ...@@ -350,7 +350,7 @@ DGL_DLL int DGLFuncCall(
DGL_DLL int DGLCFuncSetReturn( DGL_DLL int DGLCFuncSetReturn(
DGLRetValueHandle ret, DGLValue* value, int* type_code, int num_ret); DGLRetValueHandle ret, DGLValue* value, int* type_code, int num_ret);
/*! /**
* @brief Inplace translate callback argument value to return value. * @brief Inplace translate callback argument value to return value.
* This is only needed for non-POD arguments. * This is only needed for non-POD arguments.
* *
...@@ -362,7 +362,7 @@ DGL_DLL int DGLCFuncSetReturn( ...@@ -362,7 +362,7 @@ DGL_DLL int DGLCFuncSetReturn(
*/ */
DGL_DLL int DGLCbArgToReturn(DGLValue* value, int code); DGL_DLL int DGLCbArgToReturn(DGLValue* value, int code);
/*! /**
* @brief C type of packed function. * @brief C type of packed function.
* *
* @param args The arguments * @param args The arguments
...@@ -378,13 +378,13 @@ typedef int (*DGLPackedCFunc)( ...@@ -378,13 +378,13 @@ typedef int (*DGLPackedCFunc)(
DGLValue* args, int* type_codes, int num_args, DGLRetValueHandle ret, DGLValue* args, int* type_codes, int num_args, DGLRetValueHandle ret,
void* resource_handle); void* resource_handle);
/*! /**
* @brief C callback to free the resource handle in C packed function. * @brief C callback to free the resource handle in C packed function.
* @param resource_handle The handle additional resouce handle from fron-end. * @param resource_handle The handle additional resouce handle from fron-end.
*/ */
typedef void (*DGLPackedCFuncFinalizer)(void* resource_handle); typedef void (*DGLPackedCFuncFinalizer)(void* resource_handle);
/*! /**
* @brief Signature for extension function declarer. * @brief Signature for extension function declarer.
* *
* DGL call this function to get the extension functions * DGL call this function to get the extension functions
...@@ -395,7 +395,7 @@ typedef void (*DGLPackedCFuncFinalizer)(void* resource_handle); ...@@ -395,7 +395,7 @@ typedef void (*DGLPackedCFuncFinalizer)(void* resource_handle);
*/ */
typedef int (*DGLExtensionFuncDeclarer)(DGLFunctionHandle register_func_handle); typedef int (*DGLExtensionFuncDeclarer)(DGLFunctionHandle register_func_handle);
/*! /**
* @brief Wrap a DGLPackedCFunc to become a FunctionHandle. * @brief Wrap a DGLPackedCFunc to become a FunctionHandle.
* *
* The resource_handle will be managed by DGL API, until the function is no * The resource_handle will be managed by DGL API, until the function is no
...@@ -412,7 +412,7 @@ DGL_DLL int DGLFuncCreateFromCFunc( ...@@ -412,7 +412,7 @@ DGL_DLL int DGLFuncCreateFromCFunc(
DGLPackedCFunc func, void* resource_handle, DGLPackedCFuncFinalizer fin, DGLPackedCFunc func, void* resource_handle, DGLPackedCFuncFinalizer fin,
DGLFunctionHandle* out); DGLFunctionHandle* out);
/*! /**
* @brief Register the function to runtime's global table. * @brief Register the function to runtime's global table.
* *
* The registered function then can be pulled by the backend by the name. * The registered function then can be pulled by the backend by the name.
...@@ -424,7 +424,7 @@ DGL_DLL int DGLFuncCreateFromCFunc( ...@@ -424,7 +424,7 @@ DGL_DLL int DGLFuncCreateFromCFunc(
DGL_DLL int DGLFuncRegisterGlobal( DGL_DLL int DGLFuncRegisterGlobal(
const char* name, DGLFunctionHandle f, int override); const char* name, DGLFunctionHandle f, int override);
/*! /**
* @brief Get a global function. * @brief Get a global function.
* *
* @param name The name of the function. * @param name The name of the function.
...@@ -435,7 +435,7 @@ DGL_DLL int DGLFuncRegisterGlobal( ...@@ -435,7 +435,7 @@ DGL_DLL int DGLFuncRegisterGlobal(
*/ */
DGL_DLL int DGLFuncGetGlobal(const char* name, DGLFunctionHandle* out); DGL_DLL int DGLFuncGetGlobal(const char* name, DGLFunctionHandle* out);
/*! /**
* @brief List all the globally registered function name * @brief List all the globally registered function name
* @param out_size The number of functions * @param out_size The number of functions
* @param out_array The array of function names. * @param out_array The array of function names.
...@@ -444,7 +444,7 @@ DGL_DLL int DGLFuncGetGlobal(const char* name, DGLFunctionHandle* out); ...@@ -444,7 +444,7 @@ DGL_DLL int DGLFuncGetGlobal(const char* name, DGLFunctionHandle* out);
DGL_DLL int DGLFuncListGlobalNames(int* out_size, const char*** out_array); DGL_DLL int DGLFuncListGlobalNames(int* out_size, const char*** out_array);
// Array related apis for quick proptyping // Array related apis for quick proptyping
/*! /**
* @brief Allocate a nd-array's memory, * @brief Allocate a nd-array's memory,
* including space of shape, of given spec. * including space of shape, of given spec.
* *
...@@ -462,7 +462,7 @@ DGL_DLL int DGLArrayAlloc( ...@@ -462,7 +462,7 @@ DGL_DLL int DGLArrayAlloc(
const dgl_index_t* shape, int ndim, int dtype_code, int dtype_bits, const dgl_index_t* shape, int ndim, int dtype_code, int dtype_bits,
int dtype_lanes, int device_type, int device_id, DGLArrayHandle* out); int dtype_lanes, int device_type, int device_id, DGLArrayHandle* out);
/*! /**
* @brief Allocate a nd-array's with shared memory, * @brief Allocate a nd-array's with shared memory,
* including space of shape, of given spec. * including space of shape, of given spec.
* *
...@@ -480,14 +480,14 @@ int DGLArrayAllocSharedMem( ...@@ -480,14 +480,14 @@ int DGLArrayAllocSharedMem(
const char* mem_name, const dgl_index_t* shape, int ndim, int dtype_code, const char* mem_name, const dgl_index_t* shape, int ndim, int dtype_code,
int dtype_bits, int dtype_lanes, bool is_create, DGLArrayHandle* out); int dtype_bits, int dtype_lanes, bool is_create, DGLArrayHandle* out);
/*! /**
* @brief Free the DGL Array. * @brief Free the DGL Array.
* @param handle The array handle to be freed. * @param handle The array handle to be freed.
* @return 0 when success, -1 when failure happens * @return 0 when success, -1 when failure happens
*/ */
DGL_DLL int DGLArrayFree(DGLArrayHandle handle); DGL_DLL int DGLArrayFree(DGLArrayHandle handle);
/*! /**
* @brief Copy array data from CPU byte array. * @brief Copy array data from CPU byte array.
* @param handle The array handle. * @param handle The array handle.
* @param data the data pointer * @param data the data pointer
...@@ -497,7 +497,7 @@ DGL_DLL int DGLArrayFree(DGLArrayHandle handle); ...@@ -497,7 +497,7 @@ DGL_DLL int DGLArrayFree(DGLArrayHandle handle);
DGL_DLL int DGLArrayCopyFromBytes( DGL_DLL int DGLArrayCopyFromBytes(
DGLArrayHandle handle, void* data, size_t nbytes); DGLArrayHandle handle, void* data, size_t nbytes);
/*! /**
* @brief Copy array data to CPU byte array. * @brief Copy array data to CPU byte array.
* @param handle The array handle. * @param handle The array handle.
* @param data the data pointer * @param data the data pointer
...@@ -507,7 +507,7 @@ DGL_DLL int DGLArrayCopyFromBytes( ...@@ -507,7 +507,7 @@ DGL_DLL int DGLArrayCopyFromBytes(
DGL_DLL int DGLArrayCopyToBytes( DGL_DLL int DGLArrayCopyToBytes(
DGLArrayHandle handle, void* data, size_t nbytes); DGLArrayHandle handle, void* data, size_t nbytes);
/*! /**
* @brief Copy the array, both from and to must be valid during the copy. * @brief Copy the array, both from and to must be valid during the copy.
* @param from The array to be copied from. * @param from The array to be copied from.
* @param to The target space. * @param to The target space.
...@@ -515,7 +515,7 @@ DGL_DLL int DGLArrayCopyToBytes( ...@@ -515,7 +515,7 @@ DGL_DLL int DGLArrayCopyToBytes(
*/ */
DGL_DLL int DGLArrayCopyFromTo(DGLArrayHandle from, DGLArrayHandle to); DGL_DLL int DGLArrayCopyFromTo(DGLArrayHandle from, DGLArrayHandle to);
/*! /**
* @brief Create a new runtime stream. * @brief Create a new runtime stream.
* *
* @param device_type The device type of context * @param device_type The device type of context
...@@ -526,7 +526,7 @@ DGL_DLL int DGLArrayCopyFromTo(DGLArrayHandle from, DGLArrayHandle to); ...@@ -526,7 +526,7 @@ DGL_DLL int DGLArrayCopyFromTo(DGLArrayHandle from, DGLArrayHandle to);
DGL_DLL int DGLStreamCreate( DGL_DLL int DGLStreamCreate(
int device_type, int device_id, DGLStreamHandle* out); int device_type, int device_id, DGLStreamHandle* out);
/*! /**
* @brief Free a created stream handle. * @brief Free a created stream handle.
* *
* @param device_type The device type of context * @param device_type The device type of context
...@@ -537,7 +537,7 @@ DGL_DLL int DGLStreamCreate( ...@@ -537,7 +537,7 @@ DGL_DLL int DGLStreamCreate(
DGL_DLL int DGLStreamFree( DGL_DLL int DGLStreamFree(
int device_type, int device_id, DGLStreamHandle stream); int device_type, int device_id, DGLStreamHandle stream);
/*! /**
* @brief Set the runtime stream of current thread to be stream. * @brief Set the runtime stream of current thread to be stream.
* The subsequent calls to the same device_type * The subsequent calls to the same device_type
* will use the setted stream handle. * will use the setted stream handle.
...@@ -551,7 +551,7 @@ DGL_DLL int DGLStreamFree( ...@@ -551,7 +551,7 @@ DGL_DLL int DGLStreamFree(
DGL_DLL int DGLSetStream( DGL_DLL int DGLSetStream(
int device_type, int device_id, DGLStreamHandle handle); int device_type, int device_id, DGLStreamHandle handle);
/*! /**
* @brief Get the runtime stream of current thread. * @brief Get the runtime stream of current thread.
* *
* @param device_type The device type of context * @param device_type The device type of context
...@@ -562,7 +562,7 @@ DGL_DLL int DGLSetStream( ...@@ -562,7 +562,7 @@ DGL_DLL int DGLSetStream(
DGL_DLL int DGLGetStream( DGL_DLL int DGLGetStream(
int device_type, int device_id, DGLStreamHandle* handle); int device_type, int device_id, DGLStreamHandle* handle);
/*! /**
* @brief Wait until all computations on stream completes. * @brief Wait until all computations on stream completes.
* *
* @param device_type The device type of context * @param device_type The device type of context
...@@ -573,7 +573,7 @@ DGL_DLL int DGLGetStream( ...@@ -573,7 +573,7 @@ DGL_DLL int DGLGetStream(
DGL_DLL int DGLSynchronize( DGL_DLL int DGLSynchronize(
int device_type, int device_id, DGLStreamHandle stream); int device_type, int device_id, DGLStreamHandle stream);
/*! /**
* @brief Synchronize two streams of execution. * @brief Synchronize two streams of execution.
* *
* @param device_type The device type of context * @param device_type The device type of context
...@@ -585,28 +585,28 @@ DGL_DLL int DGLSynchronize( ...@@ -585,28 +585,28 @@ DGL_DLL int DGLSynchronize(
DGL_DLL int DGLStreamStreamSynchronize( DGL_DLL int DGLStreamStreamSynchronize(
int device_type, int device_id, DGLStreamHandle src, DGLStreamHandle dst); int device_type, int device_id, DGLStreamHandle src, DGLStreamHandle dst);
/*! /**
* @brief Load tensor adapter. * @brief Load tensor adapter.
* @return 0 when success, -1 when failure happens. * @return 0 when success, -1 when failure happens.
*/ */
DGL_DLL int DGLLoadTensorAdapter(const char* path); DGL_DLL int DGLLoadTensorAdapter(const char* path);
/*! /**
* @brief Pin host memory. * @brief Pin host memory.
*/ */
int DGLArrayPinData(DGLArrayHandle handle, DGLContext ctx); int DGLArrayPinData(DGLArrayHandle handle, DGLContext ctx);
/*! /**
* @brief Unpin host memory. * @brief Unpin host memory.
*/ */
int DGLArrayUnpinData(DGLArrayHandle handle, DGLContext ctx); int DGLArrayUnpinData(DGLArrayHandle handle, DGLContext ctx);
/*! /**
* @brief Record the stream that's using this tensor. * @brief Record the stream that's using this tensor.
*/ */
int DGLArrayRecordStream(DGLArrayHandle handle, DGLStreamHandle stream); int DGLArrayRecordStream(DGLArrayHandle handle, DGLStreamHandle stream);
/*! /**
* @brief Bug report macro. * @brief Bug report macro.
* *
* This serves as a sanity check on system side to make sure the code is correct * This serves as a sanity check on system side to make sure the code is correct
......
/*! /**
* Copyright (c) 2019 by Contributors * Copyright (c) 2019 by Contributors
* @file runtime/config.h * @file runtime/config.h
* @brief DGL runtime config * @brief DGL runtime config
......
/*! /**
* Copyright (c) 2019 by Contributors * Copyright (c) 2019 by Contributors
* @file runtime/container.h * @file runtime/container.h
* @brief Defines the container object data structures. * @brief Defines the container object data structures.
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
namespace dgl { namespace dgl {
namespace runtime { namespace runtime {
/*! /**
* @brief value object. * @brief value object.
* *
* It is typically used to wrap a non-Object type to Object type. * It is typically used to wrap a non-Object type to Object type.
...@@ -26,14 +26,14 @@ namespace runtime { ...@@ -26,14 +26,14 @@ namespace runtime {
*/ */
class ValueObject : public Object { class ValueObject : public Object {
public: public:
/*! @brief the value data */ /** @brief the value data */
DGLRetValue data; DGLRetValue data;
static constexpr const char* _type_key = "Value"; static constexpr const char* _type_key = "Value";
DGL_DECLARE_OBJECT_TYPE_INFO(ValueObject, Object); DGL_DECLARE_OBJECT_TYPE_INFO(ValueObject, Object);
}; };
/*! @brief Construct a value object. */ /** @brief Construct a value object. */
template <typename T> template <typename T>
inline std::shared_ptr<ValueObject> MakeValue(T&& val) { inline std::shared_ptr<ValueObject> MakeValue(T&& val) {
auto obj = std::make_shared<ValueObject>(); auto obj = std::make_shared<ValueObject>();
...@@ -41,7 +41,7 @@ inline std::shared_ptr<ValueObject> MakeValue(T&& val) { ...@@ -41,7 +41,7 @@ inline std::shared_ptr<ValueObject> MakeValue(T&& val) {
return obj; return obj;
} }
/*! @brief Vallue reference type */ /** @brief Vallue reference type */
class Value : public ObjectRef { class Value : public ObjectRef {
public: public:
Value() {} Value() {}
...@@ -54,10 +54,10 @@ class Value : public ObjectRef { ...@@ -54,10 +54,10 @@ class Value : public ObjectRef {
using ContainerType = ValueObject; using ContainerType = ValueObject;
}; };
/*! @brief list obj content in list */ /** @brief list obj content in list */
class ListObject : public Object { class ListObject : public Object {
public: public:
/*! @brief the data content */ /** @brief the data content */
std::vector<std::shared_ptr<Object> > data; std::vector<std::shared_ptr<Object> > data;
void VisitAttrs(AttrVisitor* visitor) final { void VisitAttrs(AttrVisitor* visitor) final {
...@@ -68,7 +68,7 @@ class ListObject : public Object { ...@@ -68,7 +68,7 @@ class ListObject : public Object {
DGL_DECLARE_OBJECT_TYPE_INFO(ListObject, Object); DGL_DECLARE_OBJECT_TYPE_INFO(ListObject, Object);
}; };
/*! @brief map obj content */ /** @brief map obj content */
class MapObject : public Object { class MapObject : public Object {
public: public:
void VisitAttrs(AttrVisitor* visitor) final { void VisitAttrs(AttrVisitor* visitor) final {
...@@ -89,35 +89,35 @@ class MapObject : public Object { ...@@ -89,35 +89,35 @@ class MapObject : public Object {
} }
}; };
/*! @brief The corresponding conatiner type */ /** @brief The corresponding conatiner type */
using ContainerType = std::unordered_map< using ContainerType = std::unordered_map<
std::shared_ptr<Object>, std::shared_ptr<Object>, Hash, Equal>; std::shared_ptr<Object>, std::shared_ptr<Object>, Hash, Equal>;
/*! @brief the data content */ /** @brief the data content */
ContainerType data; ContainerType data;
static constexpr const char* _type_key = "Map"; static constexpr const char* _type_key = "Map";
DGL_DECLARE_OBJECT_TYPE_INFO(MapObject, Object); DGL_DECLARE_OBJECT_TYPE_INFO(MapObject, Object);
}; };
/*! @brief specialized map obj with string as key */ /** @brief specialized map obj with string as key */
class StrMapObject : public Object { class StrMapObject : public Object {
public: public:
void VisitAttrs(AttrVisitor* visitor) final { void VisitAttrs(AttrVisitor* visitor) final {
// Visitor to map have no effect. // Visitor to map have no effect.
} }
/*! @brief The corresponding conatiner type */ /** @brief The corresponding conatiner type */
using ContainerType = using ContainerType =
std::unordered_map<std::string, std::shared_ptr<Object> >; std::unordered_map<std::string, std::shared_ptr<Object> >;
/*! @brief the data content */ /** @brief the data content */
ContainerType data; ContainerType data;
static constexpr const char* _type_key = "StrMap"; static constexpr const char* _type_key = "StrMap";
DGL_DECLARE_OBJECT_TYPE_INFO(StrMapObject, Object); DGL_DECLARE_OBJECT_TYPE_INFO(StrMapObject, Object);
}; };
/*! /**
* @brief iterator adapter that adapts TIter to return another type. * @brief iterator adapter that adapts TIter to return another type.
* @tparam Converter a struct that contains converting function * @tparam Converter a struct that contains converting function
* @tparam TIter the content iterator type. * @tparam TIter the content iterator type.
...@@ -149,7 +149,7 @@ class IterAdapter { ...@@ -149,7 +149,7 @@ class IterAdapter {
TIter iter_; TIter iter_;
}; };
/*! /**
* @brief List container of ObjectRef. * @brief List container of ObjectRef.
* *
* List implements copy on write semantics, which means list is mutable * List implements copy on write semantics, which means list is mutable
...@@ -187,29 +187,29 @@ template < ...@@ -187,29 +187,29 @@ template <
typename std::enable_if<std::is_base_of<ObjectRef, T>::value>::type> typename std::enable_if<std::is_base_of<ObjectRef, T>::value>::type>
class List : public ObjectRef { class List : public ObjectRef {
public: public:
/*! /**
* @brief default constructor * @brief default constructor
*/ */
List() { obj_ = std::make_shared<ListObject>(); } List() { obj_ = std::make_shared<ListObject>(); }
/*! /**
* @brief move constructor * @brief move constructor
* @param other source * @param other source
*/ */
List(List<T>&& other) { // NOLINT(*) List(List<T>&& other) { // NOLINT(*)
obj_ = std::move(other.obj_); obj_ = std::move(other.obj_);
} }
/*! /**
* @brief copy constructor * @brief copy constructor
* @param other source * @param other source
*/ */
List(const List<T>& other) : ObjectRef(other.obj_) { // NOLINT(*) List(const List<T>& other) : ObjectRef(other.obj_) { // NOLINT(*)
} }
/*! /**
* @brief constructor from pointer * @brief constructor from pointer
* @param n the container pointer * @param n the container pointer
*/ */
explicit List(std::shared_ptr<Object> n) : ObjectRef(n) {} explicit List(std::shared_ptr<Object> n) : ObjectRef(n) {}
/*! /**
* @brief constructor from iterator * @brief constructor from iterator
* @param begin begin of iterator * @param begin begin of iterator
* @param end end of iterator * @param end end of iterator
...@@ -219,21 +219,21 @@ class List : public ObjectRef { ...@@ -219,21 +219,21 @@ class List : public ObjectRef {
List(IterType begin, IterType end) { List(IterType begin, IterType end) {
assign(begin, end); assign(begin, end);
} }
/*! /**
* @brief constructor from initializer list * @brief constructor from initializer list
* @param init The initalizer list * @param init The initalizer list
*/ */
List(std::initializer_list<T> init) { // NOLINT(*) List(std::initializer_list<T> init) { // NOLINT(*)
assign(init.begin(), init.end()); assign(init.begin(), init.end());
} }
/*! /**
* @brief constructor from vector * @brief constructor from vector
* @param init The vector * @param init The vector
*/ */
List(const std::vector<T>& init) { // NOLINT(*) List(const std::vector<T>& init) { // NOLINT(*)
assign(init.begin(), init.end()); assign(init.begin(), init.end());
} }
/*! /**
* @brief Constructs a container with n elements. Each element is a copy of * @brief Constructs a container with n elements. Each element is a copy of
* val \param n The size of the container \param val The init value * val \param n The size of the container \param val The init value
*/ */
...@@ -244,7 +244,7 @@ class List : public ObjectRef { ...@@ -244,7 +244,7 @@ class List : public ObjectRef {
} }
obj_ = std::move(tmp_obj); obj_ = std::move(tmp_obj);
} }
/*! /**
* @brief move assign operator * @brief move assign operator
* @param other The source of assignment * @param other The source of assignment
* @return reference to self. * @return reference to self.
...@@ -253,7 +253,7 @@ class List : public ObjectRef { ...@@ -253,7 +253,7 @@ class List : public ObjectRef {
obj_ = std::move(other.obj_); obj_ = std::move(other.obj_);
return *this; return *this;
} }
/*! /**
* @brief copy assign operator * @brief copy assign operator
* @param other The source of assignment * @param other The source of assignment
* @return reference to self. * @return reference to self.
...@@ -262,7 +262,7 @@ class List : public ObjectRef { ...@@ -262,7 +262,7 @@ class List : public ObjectRef {
obj_ = other.obj_; obj_ = other.obj_;
return *this; return *this;
} }
/*! /**
* @brief reset the list to content from iterator. * @brief reset the list to content from iterator.
* @param begin begin of iterator * @param begin begin of iterator
* @param end end of iterator * @param end end of iterator
...@@ -276,7 +276,7 @@ class List : public ObjectRef { ...@@ -276,7 +276,7 @@ class List : public ObjectRef {
} }
obj_ = std::move(n); obj_ = std::move(n);
} }
/*! /**
* @brief Read i-th element from list. * @brief Read i-th element from list.
* @param i The index * @param i The index
* @return the i-th element. * @return the i-th element.
...@@ -284,12 +284,12 @@ class List : public ObjectRef { ...@@ -284,12 +284,12 @@ class List : public ObjectRef {
inline const T operator[](size_t i) const { inline const T operator[](size_t i) const {
return T(static_cast<const ListObject*>(obj_.get())->data[i]); return T(static_cast<const ListObject*>(obj_.get())->data[i]);
} }
/*! @return The size of the list */ /** @return The size of the list */
inline size_t size() const { inline size_t size() const {
if (obj_.get() == nullptr) return 0; if (obj_.get() == nullptr) return 0;
return static_cast<const ListObject*>(obj_.get())->data.size(); return static_cast<const ListObject*>(obj_.get())->data.size();
} }
/*! /**
* @brief copy on write semantics * @brief copy on write semantics
* Do nothing if current handle is the unique copy of the list. * Do nothing if current handle is the unique copy of the list.
* Otherwise make a new copy of the list to ensure the current handle * Otherwise make a new copy of the list to ensure the current handle
...@@ -304,7 +304,7 @@ class List : public ObjectRef { ...@@ -304,7 +304,7 @@ class List : public ObjectRef {
} }
return static_cast<ListObject*>(obj_.get()); return static_cast<ListObject*>(obj_.get());
} }
/*! /**
* @brief push a new item to the back of the list * @brief push a new item to the back of the list
* @param item The item to be pushed. * @param item The item to be pushed.
*/ */
...@@ -312,7 +312,7 @@ class List : public ObjectRef { ...@@ -312,7 +312,7 @@ class List : public ObjectRef {
ListObject* n = this->CopyOnWrite(); ListObject* n = this->CopyOnWrite();
n->data.push_back(item.obj_); n->data.push_back(item.obj_);
} }
/*! /**
* @brief set i-th element of the list. * @brief set i-th element of the list.
* @param i The index * @param i The index
* @param value The value to be setted. * @param value The value to be setted.
...@@ -321,13 +321,13 @@ class List : public ObjectRef { ...@@ -321,13 +321,13 @@ class List : public ObjectRef {
ListObject* n = this->CopyOnWrite(); ListObject* n = this->CopyOnWrite();
n->data[i] = value.obj_; n->data[i] = value.obj_;
} }
/*! @return whether list is empty */ /** @return whether list is empty */
inline bool empty() const { return size() == 0; } inline bool empty() const { return size() == 0; }
/*! @brief Copy the content to a vector */ /** @brief Copy the content to a vector */
inline std::vector<T> ToVector() const { inline std::vector<T> ToVector() const {
return std::vector<T>(begin(), end()); return std::vector<T>(begin(), end());
} }
/*! @brief specify container obj */ /** @brief specify container obj */
using ContainerType = ListObject; using ContainerType = ListObject;
struct Ptr2ObjectRef { struct Ptr2ObjectRef {
...@@ -341,27 +341,27 @@ class List : public ObjectRef { ...@@ -341,27 +341,27 @@ class List : public ObjectRef {
Ptr2ObjectRef, Ptr2ObjectRef,
std::vector<std::shared_ptr<Object> >::const_reverse_iterator>; std::vector<std::shared_ptr<Object> >::const_reverse_iterator>;
/*! @return begin iterator */ /** @return begin iterator */
inline iterator begin() const { inline iterator begin() const {
return iterator(static_cast<const ListObject*>(obj_.get())->data.begin()); return iterator(static_cast<const ListObject*>(obj_.get())->data.begin());
} }
/*! @return end iterator */ /** @return end iterator */
inline iterator end() const { inline iterator end() const {
return iterator(static_cast<const ListObject*>(obj_.get())->data.end()); return iterator(static_cast<const ListObject*>(obj_.get())->data.end());
} }
/*! @return rbegin iterator */ /** @return rbegin iterator */
inline reverse_iterator rbegin() const { inline reverse_iterator rbegin() const {
return reverse_iterator( return reverse_iterator(
static_cast<const ListObject*>(obj_.get())->data.rbegin()); static_cast<const ListObject*>(obj_.get())->data.rbegin());
} }
/*! @return rend iterator */ /** @return rend iterator */
inline reverse_iterator rend() const { inline reverse_iterator rend() const {
return reverse_iterator( return reverse_iterator(
static_cast<const ListObject*>(obj_.get())->data.rend()); static_cast<const ListObject*>(obj_.get())->data.rend());
} }
}; };
/*! /**
* @brief Map container of ObjectRef->ObjectRef. * @brief Map container of ObjectRef->ObjectRef.
* *
* Map implements copy on write semantics, which means map is mutable * Map implements copy on write semantics, which means map is mutable
...@@ -403,29 +403,29 @@ template < ...@@ -403,29 +403,29 @@ template <
typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type> typename std::enable_if<std::is_base_of<ObjectRef, V>::value>::type>
class Map : public ObjectRef { class Map : public ObjectRef {
public: public:
/*! /**
* @brief default constructor * @brief default constructor
*/ */
Map() { obj_ = std::make_shared<MapObject>(); } Map() { obj_ = std::make_shared<MapObject>(); }
/*! /**
* @brief move constructor * @brief move constructor
* @param other source * @param other source
*/ */
Map(Map<K, V>&& other) { // NOLINT(*) Map(Map<K, V>&& other) { // NOLINT(*)
obj_ = std::move(other.obj_); obj_ = std::move(other.obj_);
} }
/*! /**
* @brief copy constructor * @brief copy constructor
* @param other source * @param other source
*/ */
Map(const Map<K, V>& other) : ObjectRef(other.obj_) { // NOLINT(*) Map(const Map<K, V>& other) : ObjectRef(other.obj_) { // NOLINT(*)
} }
/*! /**
* @brief constructor from pointer * @brief constructor from pointer
* @param n the container pointer * @param n the container pointer
*/ */
explicit Map(std::shared_ptr<Object> n) : ObjectRef(n) {} explicit Map(std::shared_ptr<Object> n) : ObjectRef(n) {}
/*! /**
* @brief constructor from iterator * @brief constructor from iterator
* @param begin begin of iterator * @param begin begin of iterator
* @param end end of iterator * @param end end of iterator
...@@ -435,14 +435,14 @@ class Map : public ObjectRef { ...@@ -435,14 +435,14 @@ class Map : public ObjectRef {
Map(IterType begin, IterType end) { Map(IterType begin, IterType end) {
assign(begin, end); assign(begin, end);
} }
/*! /**
* @brief constructor from initializer list * @brief constructor from initializer list
* @param init The initalizer list * @param init The initalizer list
*/ */
Map(std::initializer_list<std::pair<K, V> > init) { // NOLINT(*) Map(std::initializer_list<std::pair<K, V> > init) { // NOLINT(*)
assign(init.begin(), init.end()); assign(init.begin(), init.end());
} }
/*! /**
* @brief constructor from vector * @brief constructor from vector
* @param init The vector * @param init The vector
*/ */
...@@ -450,7 +450,7 @@ class Map : public ObjectRef { ...@@ -450,7 +450,7 @@ class Map : public ObjectRef {
Map(const std::unordered_map<K, V, Hash, Equal>& init) { // NOLINT(*) Map(const std::unordered_map<K, V, Hash, Equal>& init) { // NOLINT(*)
assign(init.begin(), init.end()); assign(init.begin(), init.end());
} }
/*! /**
* @brief move assign operator * @brief move assign operator
* @param other The source of assignment * @param other The source of assignment
* @return reference to self. * @return reference to self.
...@@ -459,7 +459,7 @@ class Map : public ObjectRef { ...@@ -459,7 +459,7 @@ class Map : public ObjectRef {
obj_ = std::move(other.obj_); obj_ = std::move(other.obj_);
return *this; return *this;
} }
/*! /**
* @brief copy assign operator * @brief copy assign operator
* @param other The source of assignment * @param other The source of assignment
* @return reference to self. * @return reference to self.
...@@ -468,7 +468,7 @@ class Map : public ObjectRef { ...@@ -468,7 +468,7 @@ class Map : public ObjectRef {
obj_ = other.obj_; obj_ = other.obj_;
return *this; return *this;
} }
/*! /**
* @brief reset the list to content from iterator. * @brief reset the list to content from iterator.
* @param begin begin of iterator * @param begin begin of iterator
* @param end end of iterator * @param end end of iterator
...@@ -482,7 +482,7 @@ class Map : public ObjectRef { ...@@ -482,7 +482,7 @@ class Map : public ObjectRef {
} }
obj_ = std::move(n); obj_ = std::move(n);
} }
/*! /**
* @brief Read element from map. * @brief Read element from map.
* @param key The key * @param key The key
* @return the corresonding element. * @return the corresonding element.
...@@ -490,7 +490,7 @@ class Map : public ObjectRef { ...@@ -490,7 +490,7 @@ class Map : public ObjectRef {
inline const V operator[](const K& key) const { inline const V operator[](const K& key) const {
return V(static_cast<const MapObject*>(obj_.get())->data.at(key.obj_)); return V(static_cast<const MapObject*>(obj_.get())->data.at(key.obj_));
} }
/*! /**
* @brief Read element from map. * @brief Read element from map.
* @param key The key * @param key The key
* @return the corresonding element. * @return the corresonding element.
...@@ -498,17 +498,17 @@ class Map : public ObjectRef { ...@@ -498,17 +498,17 @@ class Map : public ObjectRef {
inline const V at(const K& key) const { inline const V at(const K& key) const {
return V(static_cast<const MapObject*>(obj_.get())->data.at(key.obj_)); return V(static_cast<const MapObject*>(obj_.get())->data.at(key.obj_));
} }
/*! @return The size of the list */ /** @return The size of the list */
inline size_t size() const { inline size_t size() const {
if (obj_.get() == nullptr) return 0; if (obj_.get() == nullptr) return 0;
return static_cast<const MapObject*>(obj_.get())->data.size(); return static_cast<const MapObject*>(obj_.get())->data.size();
} }
/*! @return The size of the list */ /** @return The size of the list */
inline size_t count(const K& key) const { inline size_t count(const K& key) const {
if (obj_.get() == nullptr) return 0; if (obj_.get() == nullptr) return 0;
return static_cast<const MapObject*>(obj_.get())->data.count(key.obj_); return static_cast<const MapObject*>(obj_.get())->data.count(key.obj_);
} }
/*! /**
* @brief copy on write semantics * @brief copy on write semantics
* Do nothing if current handle is the unique copy of the list. * Do nothing if current handle is the unique copy of the list.
* Otherwise make a new copy of the list to ensure the current handle * Otherwise make a new copy of the list to ensure the current handle
...@@ -523,7 +523,7 @@ class Map : public ObjectRef { ...@@ -523,7 +523,7 @@ class Map : public ObjectRef {
} }
return static_cast<MapObject*>(obj_.get()); return static_cast<MapObject*>(obj_.get());
} }
/*! /**
* @brief set the Map. * @brief set the Map.
* @param key The index key. * @param key The index key.
* @param value The value to be setted. * @param value The value to be setted.
...@@ -533,9 +533,9 @@ class Map : public ObjectRef { ...@@ -533,9 +533,9 @@ class Map : public ObjectRef {
n->data[key.obj_] = value.obj_; n->data[key.obj_] = value.obj_;
} }
/*! @return whether list is empty */ /** @return whether list is empty */
inline bool empty() const { return size() == 0; } inline bool empty() const { return size() == 0; }
/*! @brief specify container obj */ /** @brief specify container obj */
using ContainerType = MapObject; using ContainerType = MapObject;
struct Ptr2ObjectRef { struct Ptr2ObjectRef {
...@@ -549,15 +549,15 @@ class Map : public ObjectRef { ...@@ -549,15 +549,15 @@ class Map : public ObjectRef {
using iterator = using iterator =
IterAdapter<Ptr2ObjectRef, MapObject::ContainerType::const_iterator>; IterAdapter<Ptr2ObjectRef, MapObject::ContainerType::const_iterator>;
/*! @return begin iterator */ /** @return begin iterator */
inline iterator begin() const { inline iterator begin() const {
return iterator(static_cast<const MapObject*>(obj_.get())->data.begin()); return iterator(static_cast<const MapObject*>(obj_.get())->data.begin());
} }
/*! @return end iterator */ /** @return end iterator */
inline iterator end() const { inline iterator end() const {
return iterator(static_cast<const MapObject*>(obj_.get())->data.end()); return iterator(static_cast<const MapObject*>(obj_.get())->data.end());
} }
/*! @return begin iterator */ /** @return begin iterator */
inline iterator find(const K& key) const { inline iterator find(const K& key) const {
return iterator( return iterator(
static_cast<const MapObject*>(obj_.get())->data.find(key.obj_)); static_cast<const MapObject*>(obj_.get())->data.find(key.obj_));
...@@ -644,22 +644,22 @@ class Map<std::string, V, T1, T2> : public ObjectRef { ...@@ -644,22 +644,22 @@ class Map<std::string, V, T1, T2> : public ObjectRef {
using iterator = using iterator =
IterAdapter<Ptr2ObjectRef, StrMapObject::ContainerType::const_iterator>; IterAdapter<Ptr2ObjectRef, StrMapObject::ContainerType::const_iterator>;
/*! @return begin iterator */ /** @return begin iterator */
inline iterator begin() const { inline iterator begin() const {
return iterator(static_cast<const StrMapObject*>(obj_.get())->data.begin()); return iterator(static_cast<const StrMapObject*>(obj_.get())->data.begin());
} }
/*! @return end iterator */ /** @return end iterator */
inline iterator end() const { inline iterator end() const {
return iterator(static_cast<const StrMapObject*>(obj_.get())->data.end()); return iterator(static_cast<const StrMapObject*>(obj_.get())->data.end());
} }
/*! @return begin iterator */ /** @return begin iterator */
inline iterator find(const std::string& key) const { inline iterator find(const std::string& key) const {
return iterator( return iterator(
static_cast<const StrMapObject*>(obj_.get())->data.find(key)); static_cast<const StrMapObject*>(obj_.get())->data.find(key));
} }
}; };
/*! /**
* @brief Helper function to convert a List<Value> object to a vector. * @brief Helper function to convert a List<Value> object to a vector.
* @tparam T element type * @tparam T element type
* @param list Input list object. * @param list Input list object.
......
/*! /**
* Copyright (c) 2016 by Contributors * Copyright (c) 2016 by Contributors
* @file dgl/runtime/device_api.h * @file dgl/runtime/device_api.h
* @brief Abstract device memory management API * @brief Abstract device memory management API
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
namespace dgl { namespace dgl {
namespace runtime { namespace runtime {
/*! /**
* @brief the query type into GetAttr * @brief the query type into GetAttr
*/ */
enum DeviceAttrKind : int { enum DeviceAttrKind : int {
...@@ -28,34 +28,34 @@ enum DeviceAttrKind : int { ...@@ -28,34 +28,34 @@ enum DeviceAttrKind : int {
kMaxThreadDimensions = 8 kMaxThreadDimensions = 8
}; };
/*! @brief Number of bytes each allocation must align to */ /** @brief Number of bytes each allocation must align to */
constexpr int kAllocAlignment = 64; constexpr int kAllocAlignment = 64;
/*! @brief Number of bytes each allocation must align to in temporary allocation /** @brief Number of bytes each allocation must align to in temporary allocation
*/ */
constexpr int kTempAllocaAlignment = 64; constexpr int kTempAllocaAlignment = 64;
/*! @brief Maximum size that can be allocated on stack */ /** @brief Maximum size that can be allocated on stack */
constexpr int kMaxStackAlloca = 1024; constexpr int kMaxStackAlloca = 1024;
/*! /**
* @brief DGL Runtime Device API, abstracts the device * @brief DGL Runtime Device API, abstracts the device
* specific interface for memory management. * specific interface for memory management.
*/ */
class DeviceAPI { class DeviceAPI {
public: public:
/*! @brief virtual destructor */ /** @brief virtual destructor */
virtual ~DeviceAPI() {} virtual ~DeviceAPI() {}
/*! /**
* @brief Check whether the device is available. * @brief Check whether the device is available.
*/ */
virtual bool IsAvailable() { return true; } virtual bool IsAvailable() { return true; }
/*! /**
* @brief Set the environment device id to ctx * @brief Set the environment device id to ctx
* @param ctx The context to be set. * @param ctx The context to be set.
*/ */
virtual void SetDevice(DGLContext ctx) = 0; virtual void SetDevice(DGLContext ctx) = 0;
/*! /**
* @brief Get attribute of specified device. * @brief Get attribute of specified device.
* @param ctx The device context * @param ctx The device context
* @param kind The result kind * @param kind The result kind
...@@ -64,7 +64,7 @@ class DeviceAPI { ...@@ -64,7 +64,7 @@ class DeviceAPI {
*/ */
virtual void GetAttr( virtual void GetAttr(
DGLContext ctx, DeviceAttrKind kind, DGLRetValue* rv) = 0; DGLContext ctx, DeviceAttrKind kind, DGLRetValue* rv) = 0;
/*! /**
* @brief Allocate a data space on device. * @brief Allocate a data space on device.
* @param ctx The device context to perform operation. * @param ctx The device context to perform operation.
* @param nbytes The number of bytes in memory. * @param nbytes The number of bytes in memory.
...@@ -76,13 +76,13 @@ class DeviceAPI { ...@@ -76,13 +76,13 @@ class DeviceAPI {
virtual void* AllocDataSpace( virtual void* AllocDataSpace(
DGLContext ctx, size_t nbytes, size_t alignment, DGLContext ctx, size_t nbytes, size_t alignment,
DGLDataType type_hint) = 0; DGLDataType type_hint) = 0;
/*! /**
* @brief Free a data space on device. * @brief Free a data space on device.
* @param ctx The device context to perform operation. * @param ctx The device context to perform operation.
* @param ptr The data space. * @param ptr The data space.
*/ */
virtual void FreeDataSpace(DGLContext ctx, void* ptr) = 0; virtual void FreeDataSpace(DGLContext ctx, void* ptr) = 0;
/*! /**
* @brief copy data from one place to another * @brief copy data from one place to another
* @param from The source array. * @param from The source array.
* @param from_offset The byte offeset in the from. * @param from_offset The byte offeset in the from.
...@@ -98,14 +98,14 @@ class DeviceAPI { ...@@ -98,14 +98,14 @@ class DeviceAPI {
const void* from, size_t from_offset, void* to, size_t to_offset, const void* from, size_t from_offset, void* to, size_t to_offset,
size_t num_bytes, DGLContext ctx_from, DGLContext ctx_to, size_t num_bytes, DGLContext ctx_from, DGLContext ctx_to,
DGLDataType type_hint) = 0; DGLDataType type_hint) = 0;
/*! /**
* @brief Create a new stream of execution. * @brief Create a new stream of execution.
* *
* @param ctx The context of allocation. * @param ctx The context of allocation.
*/ */
DGL_DLL virtual DGLStreamHandle CreateStream(DGLContext ctx); DGL_DLL virtual DGLStreamHandle CreateStream(DGLContext ctx);
/*! /**
* @brief Free a stream of execution * @brief Free a stream of execution
* *
* @param ctx The context of the stream * @param ctx The context of the stream
...@@ -113,23 +113,23 @@ class DeviceAPI { ...@@ -113,23 +113,23 @@ class DeviceAPI {
*/ */
DGL_DLL virtual void FreeStream(DGLContext ctx, DGLStreamHandle stream); DGL_DLL virtual void FreeStream(DGLContext ctx, DGLStreamHandle stream);
/*! /**
* @brief Synchronize the stream * @brief Synchronize the stream
* @param ctx The context to perform operation. * @param ctx The context to perform operation.
* @param stream The stream to be sync. * @param stream The stream to be sync.
*/ */
virtual void StreamSync(DGLContext ctx, DGLStreamHandle stream) = 0; virtual void StreamSync(DGLContext ctx, DGLStreamHandle stream) = 0;
/*! /**
* @brief Set the stream * @brief Set the stream
* @param ctx The context to set stream. * @param ctx The context to set stream.
* @param stream The stream to be set. * @param stream The stream to be set.
*/ */
virtual void SetStream(DGLContext ctx, DGLStreamHandle stream) {} virtual void SetStream(DGLContext ctx, DGLStreamHandle stream) {}
/*! /**
* @brief Get the stream * @brief Get the stream
*/ */
virtual DGLStreamHandle GetStream() const { return nullptr; } virtual DGLStreamHandle GetStream() const { return nullptr; }
/*! /**
* @brief Synchronize 2 streams of execution. * @brief Synchronize 2 streams of execution.
* *
* An event is created in event_src stream that the second then * An event is created in event_src stream that the second then
...@@ -144,7 +144,7 @@ class DeviceAPI { ...@@ -144,7 +144,7 @@ class DeviceAPI {
DGL_DLL virtual void SyncStreamFromTo( DGL_DLL virtual void SyncStreamFromTo(
DGLContext ctx, DGLStreamHandle event_src, DGLStreamHandle event_dst); DGLContext ctx, DGLStreamHandle event_src, DGLStreamHandle event_dst);
/*! /**
* @brief Pin host memory using cudaHostRegister(). * @brief Pin host memory using cudaHostRegister().
* *
* @param ptr The host memory pointer to be pinned. * @param ptr The host memory pointer to be pinned.
...@@ -152,19 +152,19 @@ class DeviceAPI { ...@@ -152,19 +152,19 @@ class DeviceAPI {
*/ */
DGL_DLL virtual void PinData(void* ptr, size_t nbytes); DGL_DLL virtual void PinData(void* ptr, size_t nbytes);
/*! /**
* @brief Unpin host memory using cudaHostUnregister(). * @brief Unpin host memory using cudaHostUnregister().
* *
* @param ptr The host memory pointer to be unpinned. * @param ptr The host memory pointer to be unpinned.
*/ */
DGL_DLL virtual void UnpinData(void* ptr); DGL_DLL virtual void UnpinData(void* ptr);
/*! /**
* @brief Check whether the memory is in pinned memory. * @brief Check whether the memory is in pinned memory.
*/ */
DGL_DLL virtual bool IsPinned(const void* ptr) { return false; } DGL_DLL virtual bool IsPinned(const void* ptr) { return false; }
/*! /**
* @brief Allocate temporal workspace for backend execution. * @brief Allocate temporal workspace for backend execution.
* *
* \note We have the following assumption about backend temporal * \note We have the following assumption about backend temporal
...@@ -183,7 +183,7 @@ class DeviceAPI { ...@@ -183,7 +183,7 @@ class DeviceAPI {
*/ */
DGL_DLL virtual void* AllocWorkspace( DGL_DLL virtual void* AllocWorkspace(
DGLContext ctx, size_t nbytes, DGLDataType type_hint = {}); DGLContext ctx, size_t nbytes, DGLDataType type_hint = {});
/*! /**
* @brief Free temporal workspace in backend execution. * @brief Free temporal workspace in backend execution.
* *
* @param ctx The context of allocation. * @param ctx The context of allocation.
...@@ -191,7 +191,7 @@ class DeviceAPI { ...@@ -191,7 +191,7 @@ class DeviceAPI {
*/ */
DGL_DLL virtual void FreeWorkspace(DGLContext ctx, void* ptr); DGL_DLL virtual void FreeWorkspace(DGLContext ctx, void* ptr);
/*! /**
* @brief Get device API based on context. * @brief Get device API based on context.
* @param ctx The context * @param ctx The context
* @param allow_missing Whether allow missing * @param allow_missing Whether allow missing
...@@ -199,7 +199,7 @@ class DeviceAPI { ...@@ -199,7 +199,7 @@ class DeviceAPI {
*/ */
DGL_DLL static DeviceAPI* Get(DGLContext ctx, bool allow_missing = false); DGL_DLL static DeviceAPI* Get(DGLContext ctx, bool allow_missing = false);
/*! /**
* @brief Get device API based on context. * @brief Get device API based on context.
* @param dev_type The device type * @param dev_type The device type
* @param allow_missing Whether allow missing * @param allow_missing Whether allow missing
...@@ -209,7 +209,7 @@ class DeviceAPI { ...@@ -209,7 +209,7 @@ class DeviceAPI {
DGLDeviceType dev_type, bool allow_missing = false); DGLDeviceType dev_type, bool allow_missing = false);
}; };
/*! @brief The device type bigger than this is RPC device */ /** @brief The device type bigger than this is RPC device */
constexpr int kRPCSessMask = 128; constexpr int kRPCSessMask = 128;
} // namespace runtime } // namespace runtime
} // namespace dgl } // namespace dgl
......
/*! /**
* Copyright (c) 2022 by Contributors * Copyright (c) 2022 by Contributors
* @file include/dgl/runtime/dlpack_convert.h * @file include/dgl/runtime/dlpack_convert.h
* @brief Conversion between NDArray and DLPack. * @brief Conversion between NDArray and DLPack.
...@@ -15,7 +15,7 @@ namespace dgl { ...@@ -15,7 +15,7 @@ namespace dgl {
namespace runtime { namespace runtime {
struct DLPackConvert { struct DLPackConvert {
/*! /**
* @brief Create a DGL NDArray from a DLPack tensor. * @brief Create a DGL NDArray from a DLPack tensor.
* *
* This allows us to create a NDArray using the memory * This allows us to create a NDArray using the memory
...@@ -28,7 +28,7 @@ struct DLPackConvert { ...@@ -28,7 +28,7 @@ struct DLPackConvert {
*/ */
static NDArray FromDLPack(DLManagedTensor* tensor); static NDArray FromDLPack(DLManagedTensor* tensor);
/*! /**
* @brief Deleter for NDArray converted from DLPack. * @brief Deleter for NDArray converted from DLPack.
* *
* This is used from data which is passed from external * This is used from data which is passed from external
...@@ -38,7 +38,7 @@ struct DLPackConvert { ...@@ -38,7 +38,7 @@ struct DLPackConvert {
*/ */
static void DLPackDeleter(NDArray::Container* ptr); static void DLPackDeleter(NDArray::Container* ptr);
/*! @brief Convert a DGL NDArray to a DLPack tensor. /** @brief Convert a DGL NDArray to a DLPack tensor.
* *
* @param from The DGL NDArray. * @param from The DGL NDArray.
* @return A DLPack tensor. * @return A DLPack tensor.
...@@ -53,13 +53,13 @@ struct DLPackConvert { ...@@ -53,13 +53,13 @@ struct DLPackConvert {
extern "C" { extern "C" {
#endif #endif
/*! /**
* @brief Delete (free) a DLManagedTensor's data. * @brief Delete (free) a DLManagedTensor's data.
* @param dltensor Pointer to the DLManagedTensor. * @param dltensor Pointer to the DLManagedTensor.
*/ */
DGL_DLL void DGLDLManagedTensorCallDeleter(DLManagedTensor* dltensor); DGL_DLL void DGLDLManagedTensorCallDeleter(DLManagedTensor* dltensor);
/*! /**
* @brief Produce an array from the DLManagedTensor that shares data memory * @brief Produce an array from the DLManagedTensor that shares data memory
* with the DLManagedTensor. * with the DLManagedTensor.
* @param from The source DLManagedTensor. * @param from The source DLManagedTensor.
...@@ -68,7 +68,7 @@ DGL_DLL void DGLDLManagedTensorCallDeleter(DLManagedTensor* dltensor); ...@@ -68,7 +68,7 @@ DGL_DLL void DGLDLManagedTensorCallDeleter(DLManagedTensor* dltensor);
*/ */
DGL_DLL int DGLArrayFromDLPack(DLManagedTensor* from, DGLArrayHandle* out); DGL_DLL int DGLArrayFromDLPack(DLManagedTensor* from, DGLArrayHandle* out);
/*! /**
* @brief Produce a DLMangedTensor from the array that shares data memory with * @brief Produce a DLMangedTensor from the array that shares data memory with
* the array. * the array.
* @param from The source array. * @param from The source array.
......
/*! /**
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* @file dgl/runtime/module.h * @file dgl/runtime/module.h
* @brief Runtime container of the functions generated by DGL, * @brief Runtime container of the functions generated by DGL,
...@@ -24,7 +24,7 @@ namespace runtime { ...@@ -24,7 +24,7 @@ namespace runtime {
class ModuleNode; class ModuleNode;
class PackedFunc; class PackedFunc;
/*! /**
* @brief Module container of DGL. * @brief Module container of DGL.
*/ */
class Module { class Module {
...@@ -32,7 +32,7 @@ class Module { ...@@ -32,7 +32,7 @@ class Module {
Module() {} Module() {}
// constructor from container. // constructor from container.
explicit Module(std::shared_ptr<ModuleNode> n) : node_(n) {} explicit Module(std::shared_ptr<ModuleNode> n) : node_(n) {}
/*! /**
* @brief Get packed function from current module by name. * @brief Get packed function from current module by name.
* *
* @param name The name of the function. * @param name The name of the function.
...@@ -43,12 +43,12 @@ class Module { ...@@ -43,12 +43,12 @@ class Module {
*/ */
inline PackedFunc GetFunction( inline PackedFunc GetFunction(
const std::string& name, bool query_imports = false); const std::string& name, bool query_imports = false);
/*! @return internal container */ /** @return internal container */
inline ModuleNode* operator->(); inline ModuleNode* operator->();
/*! @return internal container */ /** @return internal container */
inline const ModuleNode* operator->() const; inline const ModuleNode* operator->() const;
// The following functions requires link with runtime. // The following functions requires link with runtime.
/*! /**
* @brief Import another module into this module. * @brief Import another module into this module.
* @param other The module to be imported. * @param other The module to be imported.
* *
...@@ -56,7 +56,7 @@ class Module { ...@@ -56,7 +56,7 @@ class Module {
* An error will be thrown when cyclic dependency is detected. * An error will be thrown when cyclic dependency is detected.
*/ */
DGL_DLL void Import(Module other); DGL_DLL void Import(Module other);
/*! /**
* @brief Load a module from file. * @brief Load a module from file.
* @param file_name The name of the host function module. * @param file_name The name of the host function module.
* @param format The format of the file. * @param format The format of the file.
...@@ -70,17 +70,17 @@ class Module { ...@@ -70,17 +70,17 @@ class Module {
std::shared_ptr<ModuleNode> node_; std::shared_ptr<ModuleNode> node_;
}; };
/*! /**
* @brief Base node container of module. * @brief Base node container of module.
* Do not create this directly, instead use Module. * Do not create this directly, instead use Module.
*/ */
class ModuleNode { class ModuleNode {
public: public:
/*! @brief virtual destructor */ /** @brief virtual destructor */
virtual ~ModuleNode() {} virtual ~ModuleNode() {}
/*! @return The module type key */ /** @return The module type key */
virtual const char* type_key() const = 0; virtual const char* type_key() const = 0;
/*! /**
* @brief Get a PackedFunc from module. * @brief Get a PackedFunc from module.
* *
* The PackedFunc may not be fully initialized, * The PackedFunc may not be fully initialized,
...@@ -100,14 +100,14 @@ class ModuleNode { ...@@ -100,14 +100,14 @@ class ModuleNode {
virtual PackedFunc GetFunction( virtual PackedFunc GetFunction(
const std::string& name, const std::string& name,
const std::shared_ptr<ModuleNode>& sptr_to_self) = 0; const std::shared_ptr<ModuleNode>& sptr_to_self) = 0;
/*! /**
* @brief Save the module to file. * @brief Save the module to file.
* @param file_name The file to be saved to. * @param file_name The file to be saved to.
* @param format The format of the file. * @param format The format of the file.
*/ */
virtual void SaveToFile( virtual void SaveToFile(
const std::string& file_name, const std::string& format); const std::string& file_name, const std::string& format);
/*! /**
* @brief Save the module to binary stream. * @brief Save the module to binary stream.
* @param stream The binary stream to save to. * @param stream The binary stream to save to.
* @note It is recommended to implement this for device modules, * @note It is recommended to implement this for device modules,
...@@ -115,13 +115,13 @@ class ModuleNode { ...@@ -115,13 +115,13 @@ class ModuleNode {
* We can use this to do AOT loading of bundled device functions. * We can use this to do AOT loading of bundled device functions.
*/ */
DGL_DLL virtual void SaveToBinary(dmlc::Stream* stream); DGL_DLL virtual void SaveToBinary(dmlc::Stream* stream);
/*! /**
* @brief Get the source code of module, when available. * @brief Get the source code of module, when available.
* @param format Format of the source code, can be empty by default. * @param format Format of the source code, can be empty by default.
* @return Possible source code when available. * @return Possible source code when available.
*/ */
DGL_DLL virtual std::string GetSource(const std::string& format = ""); DGL_DLL virtual std::string GetSource(const std::string& format = "");
/*! /**
* @brief Get a function from current environment * @brief Get a function from current environment
* The environment includes all the imports as well as Global functions. * The environment includes all the imports as well as Global functions.
* *
...@@ -129,37 +129,37 @@ class ModuleNode { ...@@ -129,37 +129,37 @@ class ModuleNode {
* @return The corresponding function. * @return The corresponding function.
*/ */
DGL_DLL const PackedFunc* GetFuncFromEnv(const std::string& name); DGL_DLL const PackedFunc* GetFuncFromEnv(const std::string& name);
/*! @return The module it imports from */ /** @return The module it imports from */
const std::vector<Module>& imports() const { return imports_; } const std::vector<Module>& imports() const { return imports_; }
protected: protected:
friend class Module; friend class Module;
/*! @brief The modules this module depend on */ /** @brief The modules this module depend on */
std::vector<Module> imports_; std::vector<Module> imports_;
private: private:
/*! @brief Cache used by GetImport */ /** @brief Cache used by GetImport */
std::unordered_map<std::string, std::unique_ptr<PackedFunc> > import_cache_; std::unordered_map<std::string, std::unique_ptr<PackedFunc> > import_cache_;
}; };
/*! @brief namespace for constant symbols */ /** @brief namespace for constant symbols */
namespace symbol { namespace symbol {
/*! @brief Global variable to store module context. */ /** @brief Global variable to store module context. */
constexpr const char* dgl_module_ctx = "__dgl_module_ctx"; constexpr const char* dgl_module_ctx = "__dgl_module_ctx";
/*! @brief Global variable to store device module blob */ /** @brief Global variable to store device module blob */
constexpr const char* dgl_dev_mblob = "__dgl_dev_mblob"; constexpr const char* dgl_dev_mblob = "__dgl_dev_mblob";
/*! @brief Number of bytes of device module blob. */ /** @brief Number of bytes of device module blob. */
constexpr const char* dgl_dev_mblob_nbytes = "__dgl_dev_mblob_nbytes"; constexpr const char* dgl_dev_mblob_nbytes = "__dgl_dev_mblob_nbytes";
/*! @brief global function to set device */ /** @brief global function to set device */
constexpr const char* dgl_set_device = "__dgl_set_device"; constexpr const char* dgl_set_device = "__dgl_set_device";
/*! @brief Auxiliary counter to global barrier. */ /** @brief Auxiliary counter to global barrier. */
constexpr const char* dgl_global_barrier_state = "__dgl_global_barrier_state"; constexpr const char* dgl_global_barrier_state = "__dgl_global_barrier_state";
/*! /**
* @brief Prepare the global barrier before kernels that uses global barrier. * @brief Prepare the global barrier before kernels that uses global barrier.
*/ */
constexpr const char* dgl_prepare_global_barrier = constexpr const char* dgl_prepare_global_barrier =
"__dgl_prepare_global_barrier"; "__dgl_prepare_global_barrier";
/*! @brief Placeholder for the module's entry function. */ /** @brief Placeholder for the module's entry function. */
constexpr const char* dgl_module_main = "__dgl_main__"; constexpr const char* dgl_module_main = "__dgl_main__";
} // namespace symbol } // namespace symbol
......
/*! /**
* Copyright (c) 2017-2022 by Contributors * Copyright (c) 2017-2022 by Contributors
* @file dgl/runtime/ndarray.h * @file dgl/runtime/ndarray.h
* @brief Abstract device memory management API * @brief Abstract device memory management API
...@@ -33,7 +33,7 @@ inline std::ostream& operator << (std::ostream& os, DGLDataType t); ...@@ -33,7 +33,7 @@ inline std::ostream& operator << (std::ostream& os, DGLDataType t);
namespace dgl { namespace dgl {
/*! /**
* @brief Type traits that converts a C type to a DGLDataType. * @brief Type traits that converts a C type to a DGLDataType.
* *
* Usage: * Usage:
...@@ -69,12 +69,12 @@ GEN_DGLDATATYPETRAITS_FOR(double, kDGLFloat, 64); ...@@ -69,12 +69,12 @@ GEN_DGLDATATYPETRAITS_FOR(double, kDGLFloat, 64);
namespace runtime { namespace runtime {
/*! /**
* @brief DLPack converter. * @brief DLPack converter.
*/ */
struct DLPackConvert; struct DLPackConvert;
/*! /**
* @brief Managed NDArray. * @brief Managed NDArray.
* The array is backed by reference counted blocks. * The array is backed by reference counted blocks.
*/ */
...@@ -82,19 +82,19 @@ class NDArray { ...@@ -82,19 +82,19 @@ class NDArray {
public: public:
// internal container type // internal container type
struct Container; struct Container;
/*! @brief default constructor */ /** @brief default constructor */
NDArray() {} NDArray() {}
/*! /**
* @brief cosntruct a NDArray that refers to data * @brief cosntruct a NDArray that refers to data
* @param data The data this NDArray refers to * @param data The data this NDArray refers to
*/ */
explicit inline NDArray(Container* data); explicit inline NDArray(Container* data);
/*! /**
* @brief copy constructor * @brief copy constructor
* @param other The value to be copied * @param other The value to be copied
*/ */
inline NDArray(const NDArray& other); // NOLINT(*) inline NDArray(const NDArray& other); // NOLINT(*)
/*! /**
* @brief move constructor * @brief move constructor
* @param other The value to be moved * @param other The value to be moved
*/ */
...@@ -102,18 +102,18 @@ class NDArray { ...@@ -102,18 +102,18 @@ class NDArray {
: data_(other.data_) { : data_(other.data_) {
other.data_ = nullptr; other.data_ = nullptr;
} }
/*! @brief destructor */ /** @brief destructor */
~NDArray() { ~NDArray() {
this->reset(); this->reset();
} }
/*! /**
* @brief Swap this array with another NDArray * @brief Swap this array with another NDArray
* @param other The other NDArray * @param other The other NDArray
*/ */
void swap(NDArray& other) { // NOLINT(*) void swap(NDArray& other) { // NOLINT(*)
std::swap(data_, other.data_); std::swap(data_, other.data_);
} }
/*! /**
* @brief copy assignmemt * @brief copy assignmemt
* @param other The value to be assigned. * @param other The value to be assigned.
* @return reference to self. * @return reference to self.
...@@ -123,7 +123,7 @@ class NDArray { ...@@ -123,7 +123,7 @@ class NDArray {
NDArray(other).swap(*this); // NOLINT(*) NDArray(other).swap(*this); // NOLINT(*)
return *this; return *this;
} }
/*! /**
* @brief move assignmemt * @brief move assignmemt
* @param other The value to be assigned. * @param other The value to be assigned.
* @return reference to self. * @return reference to self.
...@@ -133,26 +133,26 @@ class NDArray { ...@@ -133,26 +133,26 @@ class NDArray {
NDArray(std::move(other)).swap(*this); // NOLINT(*) NDArray(std::move(other)).swap(*this); // NOLINT(*)
return *this; return *this;
} }
/*! @return If NDArray is defined */ /** @return If NDArray is defined */
bool defined() const { bool defined() const {
return data_ != nullptr; return data_ != nullptr;
} }
/*! @return If both NDArray reference the same container */ /** @return If both NDArray reference the same container */
bool same_as(const NDArray& other) const { bool same_as(const NDArray& other) const {
return data_ == other.data_; return data_ == other.data_;
} }
/*! @brief reset the content of NDArray to be nullptr */ /** @brief reset the content of NDArray to be nullptr */
inline void reset(); inline void reset();
/*! /**
* @return the reference counter * @return the reference counter
* @note this number is approximate in multi-threaded setting. * @note this number is approximate in multi-threaded setting.
*/ */
inline int use_count() const; inline int use_count() const;
/*! @return Pointer to content of DGLArray */ /** @return Pointer to content of DGLArray */
inline const DGLArray* operator->() const; inline const DGLArray* operator->() const;
/*! @return True if the ndarray is contiguous. */ /** @return True if the ndarray is contiguous. */
bool IsContiguous() const; bool IsContiguous() const;
/*! @return the data pointer with type. */ /** @return the data pointer with type. */
template <typename T> template <typename T>
inline T* Ptr() const { inline T* Ptr() const {
if (!defined()) if (!defined())
...@@ -160,7 +160,7 @@ class NDArray { ...@@ -160,7 +160,7 @@ class NDArray {
else else
return static_cast<T*>(operator->()->data); return static_cast<T*>(operator->()->data);
} }
/*! /**
* @brief Copy data content from/into another array. * @brief Copy data content from/into another array.
* @param other The source array to be copied from. * @param other The source array to be copied from.
* @note The copy runs on the dgl internal stream if it involves a GPU context. * @note The copy runs on the dgl internal stream if it involves a GPU context.
...@@ -170,17 +170,17 @@ class NDArray { ...@@ -170,17 +170,17 @@ class NDArray {
inline void CopyTo(DGLArray *other) const; inline void CopyTo(DGLArray *other) const;
inline void CopyTo(const NDArray &other) const; inline void CopyTo(const NDArray &other) const;
/*! /**
* @brief Copy the data to another context. * @brief Copy the data to another context.
* @param ctx The target context. * @param ctx The target context.
* @return The array under another context. * @return The array under another context.
*/ */
inline NDArray CopyTo(const DGLContext &ctx) const; inline NDArray CopyTo(const DGLContext &ctx) const;
/*! /**
* @brief Return a new array with a copy of the content. * @brief Return a new array with a copy of the content.
*/ */
inline NDArray Clone() const; inline NDArray Clone() const;
/*! /**
* @brief In-place method to pin the current array by calling PinContainer * @brief In-place method to pin the current array by calling PinContainer
* on the underlying NDArray:Container. * on the underlying NDArray:Container.
* @note This is an in-place method. Behavior depends on the current context, * @note This is an in-place method. Behavior depends on the current context,
...@@ -189,7 +189,7 @@ class NDArray { ...@@ -189,7 +189,7 @@ class NDArray {
* kDGLCUDA: invalid, will throw an error. * kDGLCUDA: invalid, will throw an error.
*/ */
inline void PinMemory_(); inline void PinMemory_();
/*! /**
* @brief In-place method to unpin the current array by calling UnpinContainer * @brief In-place method to unpin the current array by calling UnpinContainer
* on the underlying NDArray:Container. * on the underlying NDArray:Container.
* @note This is an in-place method. Behavior depends on the current context, * @note This is an in-place method. Behavior depends on the current context,
...@@ -197,27 +197,27 @@ class NDArray { ...@@ -197,27 +197,27 @@ class NDArray {
* others: directly return. * others: directly return.
*/ */
inline void UnpinMemory_(); inline void UnpinMemory_();
/*! /**
* @brief Check if the array is pinned. * @brief Check if the array is pinned.
*/ */
inline bool IsPinned() const; inline bool IsPinned() const;
/*! /**
* @brief Record streams that are using the underlying tensor. * @brief Record streams that are using the underlying tensor.
* @param stream The stream that is using the underlying tensor. * @param stream The stream that is using the underlying tensor.
*/ */
inline void RecordStream(DGLStreamHandle stream) const; inline void RecordStream(DGLStreamHandle stream) const;
/*! /**
* @brief Load NDArray from stream * @brief Load NDArray from stream
* @param stream The input data stream * @param stream The input data stream
* @return Whether load is successful * @return Whether load is successful
*/ */
bool Load(dmlc::Stream* stream); bool Load(dmlc::Stream* stream);
/*! /**
* @brief Save NDArray to stream * @brief Save NDArray to stream
* @param stream The output data stream * @param stream The output data stream
*/ */
void Save(dmlc::Stream* stream) const; void Save(dmlc::Stream* stream) const;
/*! /**
* @brief Create a NDArray that shares the data memory with the current one. * @brief Create a NDArray that shares the data memory with the current one.
* @param shape The shape of the new array. * @param shape The shape of the new array.
* @param dtype The data type of the new array. * @param dtype The data type of the new array.
...@@ -226,7 +226,7 @@ class NDArray { ...@@ -226,7 +226,7 @@ class NDArray {
*/ */
DGL_DLL NDArray CreateView( DGL_DLL NDArray CreateView(
std::vector<int64_t> shape, DGLDataType dtype, int64_t offset = 0); std::vector<int64_t> shape, DGLDataType dtype, int64_t offset = 0);
/*! /**
* @brief Create an empty NDArray. * @brief Create an empty NDArray.
* @param shape The shape of the new array. * @param shape The shape of the new array.
* @param dtype The data type of the new array. * @param dtype The data type of the new array.
...@@ -236,7 +236,7 @@ class NDArray { ...@@ -236,7 +236,7 @@ class NDArray {
DGL_DLL static NDArray Empty(std::vector<int64_t> shape, DGL_DLL static NDArray Empty(std::vector<int64_t> shape,
DGLDataType dtype, DGLDataType dtype,
DGLContext ctx); DGLContext ctx);
/*! /**
* @brief Create an empty NDArray with shared memory. * @brief Create an empty NDArray with shared memory.
* @param name The name of shared memory. * @param name The name of shared memory.
* @param shape The shape of the new array. * @param shape The shape of the new array.
...@@ -250,17 +250,17 @@ class NDArray { ...@@ -250,17 +250,17 @@ class NDArray {
DGLDataType dtype, DGLDataType dtype,
DGLContext ctx, DGLContext ctx,
bool is_create); bool is_create);
/*! /**
* @brief Get the size of the array in the number of bytes. * @brief Get the size of the array in the number of bytes.
*/ */
size_t GetSize() const; size_t GetSize() const;
/*! /**
* @brief Get the number of elements in this array. * @brief Get the number of elements in this array.
*/ */
int64_t NumElements() const; int64_t NumElements() const;
/*! /**
* @brief Create a NDArray by copying from std::vector. * @brief Create a NDArray by copying from std::vector.
* @tparam T Type of vector data. Determines the dtype of returned array. * @tparam T Type of vector data. Determines the dtype of returned array.
*/ */
...@@ -268,13 +268,13 @@ class NDArray { ...@@ -268,13 +268,13 @@ class NDArray {
DGL_DLL static NDArray FromVector( DGL_DLL static NDArray FromVector(
const std::vector<T>& vec, DGLContext ctx = DGLContext{kDGLCPU, 0}); const std::vector<T>& vec, DGLContext ctx = DGLContext{kDGLCPU, 0});
/*! /**
* @brief Create a NDArray from a raw pointer. * @brief Create a NDArray from a raw pointer.
*/ */
DGL_DLL static NDArray CreateFromRaw(const std::vector<int64_t>& shape, DGL_DLL static NDArray CreateFromRaw(const std::vector<int64_t>& shape,
DGLDataType dtype, DGLContext ctx, void* raw, bool auto_free); DGLDataType dtype, DGLContext ctx, void* raw, bool auto_free);
/*! /**
* @brief Create a std::vector from a 1D NDArray. * @brief Create a std::vector from a 1D NDArray.
* @tparam T Type of vector data. * @tparam T Type of vector data.
* @note Type casting is NOT performed. The caller has to make sure that the vector * @note Type casting is NOT performed. The caller has to make sure that the vector
...@@ -285,7 +285,7 @@ class NDArray { ...@@ -285,7 +285,7 @@ class NDArray {
std::shared_ptr<SharedMemory> GetSharedMem() const; std::shared_ptr<SharedMemory> GetSharedMem() const;
/*! /**
* @brief Function to copy data from one array to another. * @brief Function to copy data from one array to another.
* @param from The source array. * @param from The source array.
* @param to The target array. * @param to The target array.
...@@ -296,7 +296,7 @@ class NDArray { ...@@ -296,7 +296,7 @@ class NDArray {
DGL_DLL static void CopyFromTo( DGL_DLL static void CopyFromTo(
DGLArray* from, DGLArray* to, DGLStreamHandle stream); DGLArray* from, DGLArray* to, DGLStreamHandle stream);
/*! /**
* @brief Function to pin the DGLArray of a Container. * @brief Function to pin the DGLArray of a Container.
* @param ptr The container to be pinned. * @param ptr The container to be pinned.
* @note Data of the given array will be pinned inplace. * @note Data of the given array will be pinned inplace.
...@@ -307,7 +307,7 @@ class NDArray { ...@@ -307,7 +307,7 @@ class NDArray {
*/ */
DGL_DLL static void PinContainer(Container* ptr); DGL_DLL static void PinContainer(Container* ptr);
/*! /**
* @brief Function to unpin the DGLArray of a Container. * @brief Function to unpin the DGLArray of a Container.
* @param ptr The container to be unpinned. * @param ptr The container to be unpinned.
* @note Data of the given array will be unpinned inplace. * @note Data of the given array will be unpinned inplace.
...@@ -317,14 +317,14 @@ class NDArray { ...@@ -317,14 +317,14 @@ class NDArray {
*/ */
DGL_DLL static void UnpinContainer(Container* ptr); DGL_DLL static void UnpinContainer(Container* ptr);
/*! /**
* @brief Function check if the DGLArray of a Container is pinned. * @brief Function check if the DGLArray of a Container is pinned.
* @param ptr The container to be checked. * @param ptr The container to be checked.
* @return true if pinned. * @return true if pinned.
*/ */
DGL_DLL static bool IsContainerPinned(Container* ptr); DGL_DLL static bool IsContainerPinned(Container* ptr);
/*! /**
* @brief Record streams that are using this tensor. * @brief Record streams that are using this tensor.
* @param ptr Pointer of the tensor to be recorded. * @param ptr Pointer of the tensor to be recorded.
* @param stream The stream that is using this tensor. * @param stream The stream that is using this tensor.
...@@ -344,7 +344,7 @@ class NDArray { ...@@ -344,7 +344,7 @@ class NDArray {
}; };
private: private:
/*! @brief Internal Data content */ /** @brief Internal Data content */
Container* data_{nullptr}; Container* data_{nullptr};
// enable internal functions // enable internal functions
friend struct Internal; friend struct Internal;
...@@ -353,7 +353,7 @@ class NDArray { ...@@ -353,7 +353,7 @@ class NDArray {
friend class DGLArgsSetter; friend class DGLArgsSetter;
}; };
/*! /**
* @brief Save a DGLArray to stream * @brief Save a DGLArray to stream
* @param strm The outpu stream * @param strm The outpu stream
* @param tensor The tensor to be saved. * @param tensor The tensor to be saved.
...@@ -361,7 +361,7 @@ class NDArray { ...@@ -361,7 +361,7 @@ class NDArray {
inline bool SaveDGLArray(dmlc::Stream* strm, const DGLArray* tensor); inline bool SaveDGLArray(dmlc::Stream* strm, const DGLArray* tensor);
/*! /**
* @brief Reference counted Container object used to back NDArray. * @brief Reference counted Container object used to back NDArray.
* *
* This object is DGLArray compatible: * This object is DGLArray compatible:
...@@ -372,25 +372,25 @@ inline bool SaveDGLArray(dmlc::Stream* strm, const DGLArray* tensor); ...@@ -372,25 +372,25 @@ inline bool SaveDGLArray(dmlc::Stream* strm, const DGLArray* tensor);
*/ */
struct NDArray::Container { struct NDArray::Container {
public: public:
/*! NOTE: the first part of this structure is the same as /** NOTE: the first part of this structure is the same as
* DLManagedTensor, note that, however, the deleter * DLManagedTensor, note that, however, the deleter
* is only called when the reference counter goes to 0 * is only called when the reference counter goes to 0
*/ */
/*! /**
* @brief Tensor structure. * @brief Tensor structure.
* @note it is important that the first field is DGLArray * @note it is important that the first field is DGLArray
* So that this data structure is DGLArray compatible. * So that this data structure is DGLArray compatible.
* The head ptr of this struct can be viewed as DGLArray*. * The head ptr of this struct can be viewed as DGLArray*.
*/ */
DGLArray dl_tensor; DGLArray dl_tensor;
/*! /**
* @brief addtional context, reserved for recycling * @brief addtional context, reserved for recycling
* @note We can attach additional content here * @note We can attach additional content here
* which the current container depend on * which the current container depend on
* (e.g. reference to original memory when creating views). * (e.g. reference to original memory when creating views).
*/ */
void* manager_ctx{nullptr}; void* manager_ctx{nullptr};
/*! /**
* @brief Customized deleter * @brief Customized deleter
* *
* @note The customized deleter is helpful to enable * @note The customized deleter is helpful to enable
...@@ -398,7 +398,7 @@ struct NDArray::Container { ...@@ -398,7 +398,7 @@ struct NDArray::Container {
* currently defined by the system. * currently defined by the system.
*/ */
void (*deleter)(Container* self) = nullptr; void (*deleter)(Container* self) = nullptr;
/*! @brief default constructor */ /** @brief default constructor */
Container() { Container() {
dl_tensor.data = nullptr; dl_tensor.data = nullptr;
dl_tensor.ndim = 0; dl_tensor.ndim = 0;
...@@ -406,13 +406,13 @@ struct NDArray::Container { ...@@ -406,13 +406,13 @@ struct NDArray::Container {
dl_tensor.strides = nullptr; dl_tensor.strides = nullptr;
dl_tensor.byte_offset = 0; dl_tensor.byte_offset = 0;
} }
/*! @brief pointer to shared memory */ /** @brief pointer to shared memory */
std::shared_ptr<SharedMemory> mem; std::shared_ptr<SharedMemory> mem;
/*! @brief developer function, increases reference counter */ /** @brief developer function, increases reference counter */
void IncRef() { void IncRef() {
ref_counter_.fetch_add(1, std::memory_order_relaxed); ref_counter_.fetch_add(1, std::memory_order_relaxed);
} }
/*! @brief developer function, decrease reference counter */ /** @brief developer function, decrease reference counter */
void DecRef() { void DecRef() {
if (ref_counter_.fetch_sub(1, std::memory_order_release) == 1) { if (ref_counter_.fetch_sub(1, std::memory_order_release) == 1) {
std::atomic_thread_fence(std::memory_order_acquire); std::atomic_thread_fence(std::memory_order_acquire);
...@@ -426,17 +426,17 @@ struct NDArray::Container { ...@@ -426,17 +426,17 @@ struct NDArray::Container {
friend struct DLPackConvert; friend struct DLPackConvert;
friend class NDArray; friend class NDArray;
friend class RPCWrappedFunc; friend class RPCWrappedFunc;
/*! /**
* @brief The shape container, * @brief The shape container,
* can be used for shape data. * can be used for shape data.
*/ */
std::vector<int64_t> shape_; std::vector<int64_t> shape_;
/*! /**
* @brief The stride container, * @brief The stride container,
* can be used for stride data. * can be used for stride data.
*/ */
std::vector<int64_t> stride_; std::vector<int64_t> stride_;
/*! @brief The internal array object */ /** @brief The internal array object */
std::atomic<int> ref_counter_{0}; std::atomic<int> ref_counter_{0};
bool pinned_by_dgl_{false}; bool pinned_by_dgl_{false};
...@@ -527,7 +527,7 @@ inline const DGLArray* NDArray::operator->() const { ...@@ -527,7 +527,7 @@ inline const DGLArray* NDArray::operator->() const {
return &(data_->dl_tensor); return &(data_->dl_tensor);
} }
/*! @brief Magic number for NDArray file */ /** @brief Magic number for NDArray file */
constexpr uint64_t kDGLNDArrayMagic = 0xDD5E40F096B4A13F; constexpr uint64_t kDGLNDArrayMagic = 0xDD5E40F096B4A13F;
inline bool SaveDGLArray(dmlc::Stream* strm, inline bool SaveDGLArray(dmlc::Stream* strm,
...@@ -579,7 +579,7 @@ inline bool SaveDGLArray(dmlc::Stream* strm, ...@@ -579,7 +579,7 @@ inline bool SaveDGLArray(dmlc::Stream* strm,
return true; return true;
} }
/*! /**
* @brief Convert type code to its name * @brief Convert type code to its name
* @param type_code The type code . * @param type_code The type code .
* @return The name of type code. * @return The name of type code.
...@@ -605,7 +605,7 @@ inline const char* TypeCode2Str(int type_code) { ...@@ -605,7 +605,7 @@ inline const char* TypeCode2Str(int type_code) {
} }
} }
/*! /**
* @brief Convert device type code to its name * @brief Convert device type code to its name
* @param device_type The device type code. * @param device_type The device type code.
* @return The name of the device. * @return The name of the device.
...@@ -619,7 +619,7 @@ inline const char* DeviceTypeCode2Str(DGLDeviceType device_type) { ...@@ -619,7 +619,7 @@ inline const char* DeviceTypeCode2Str(DGLDeviceType device_type) {
} }
} }
/*! /**
* @brief convert a string to DGL type. * @brief convert a string to DGL type.
* @param s The string to be converted. * @param s The string to be converted.
* @return The corresponding dgl type. * @return The corresponding dgl type.
...@@ -651,7 +651,7 @@ inline DGLDataType String2DGLDataType(std::string s) { ...@@ -651,7 +651,7 @@ inline DGLDataType String2DGLDataType(std::string s) {
return t; return t;
} }
/*! /**
* @brief convert a DGL type to string. * @brief convert a DGL type to string.
* @param t The type to be converted. * @param t The type to be converted.
* @return The corresponding dgl type in string. * @return The corresponding dgl type in string.
...@@ -737,12 +737,12 @@ std::ostream& operator << (std::ostream& os, dgl::runtime::NDArray array); ...@@ -737,12 +737,12 @@ std::ostream& operator << (std::ostream& os, dgl::runtime::NDArray array);
///////////////// Operator overloading for DGLDataType ///////////////// ///////////////// Operator overloading for DGLDataType /////////////////
/*! @brief Check whether two data types are the same.*/ /** @brief Check whether two data types are the same.*/
inline bool operator == (const DGLDataType& ty1, const DGLDataType& ty2) { inline bool operator == (const DGLDataType& ty1, const DGLDataType& ty2) {
return ty1.code == ty2.code && ty1.bits == ty2.bits && ty1.lanes == ty2.lanes; return ty1.code == ty2.code && ty1.bits == ty2.bits && ty1.lanes == ty2.lanes;
} }
/*! @brief Check whether two data types are different.*/ /** @brief Check whether two data types are different.*/
inline bool operator != (const DGLDataType& ty1, const DGLDataType& ty2) { inline bool operator != (const DGLDataType& ty1, const DGLDataType& ty2) {
return !(ty1 == ty2); return !(ty1 == ty2);
} }
...@@ -761,12 +761,12 @@ inline std::ostream& operator << (std::ostream& os, DGLDataType t) { ...@@ -761,12 +761,12 @@ inline std::ostream& operator << (std::ostream& os, DGLDataType t) {
///////////////// Operator overloading for DGLContext ///////////////// ///////////////// Operator overloading for DGLContext /////////////////
/*! @brief Check whether two device contexts are the same.*/ /** @brief Check whether two device contexts are the same.*/
inline bool operator == (const DGLContext& ctx1, const DGLContext& ctx2) { inline bool operator == (const DGLContext& ctx1, const DGLContext& ctx2) {
return ctx1.device_type == ctx2.device_type && ctx1.device_id == ctx2.device_id; return ctx1.device_type == ctx2.device_type && ctx1.device_id == ctx2.device_id;
} }
/*! @brief Check whether two device contexts are different.*/ /** @brief Check whether two device contexts are different.*/
inline bool operator != (const DGLContext& ctx1, const DGLContext& ctx2) { inline bool operator != (const DGLContext& ctx1, const DGLContext& ctx2) {
return !(ctx1 == ctx2); return !(ctx1 == ctx2);
} }
......
/*! /**
* Copyright (c) 2019 by Contributors * Copyright (c) 2019 by Contributors
* @file runtime/object.h * @file runtime/object.h
* @brief Defines the Object data structures. * @brief Defines the Object data structures.
...@@ -21,7 +21,7 @@ class Object; ...@@ -21,7 +21,7 @@ class Object;
class ObjectRef; class ObjectRef;
class NDArray; class NDArray;
/*! /**
* @brief Visitor class to each object attribute. * @brief Visitor class to each object attribute.
* The content is going to be called for each field. * The content is going to be called for each field.
*/ */
...@@ -48,26 +48,26 @@ class AttrVisitor { ...@@ -48,26 +48,26 @@ class AttrVisitor {
//! \endcond //! \endcond
}; };
/*! /**
* @brief base class of object container. * @brief base class of object container.
* All object's internal is stored as std::shared_ptr<Object> * All object's internal is stored as std::shared_ptr<Object>
*/ */
class Object { class Object {
public: public:
/*! @brief virtual destructor */ /** @brief virtual destructor */
virtual ~Object() {} virtual ~Object() {}
/*! @return The unique type key of the object */ /** @return The unique type key of the object */
virtual const char* type_key() const = 0; virtual const char* type_key() const = 0;
/*! /**
* @brief Apply visitor to each field of the Object * @brief Apply visitor to each field of the Object
* Visitor could mutate the content of the object. * Visitor could mutate the content of the object.
* override if Object contains attribute fields. * override if Object contains attribute fields.
* @param visitor The visitor * @param visitor The visitor
*/ */
virtual void VisitAttrs(AttrVisitor* visitor) {} virtual void VisitAttrs(AttrVisitor* visitor) {}
/*! @return the type index of the object */ /** @return the type index of the object */
virtual uint32_t type_index() const = 0; virtual uint32_t type_index() const = 0;
/*! /**
* @brief Whether this object derives from object with type_index=tid. * @brief Whether this object derives from object with type_index=tid.
* Implemented by DGL_DECLARE_OBJECT_TYPE_INFO * Implemented by DGL_DECLARE_OBJECT_TYPE_INFO
* *
...@@ -75,24 +75,24 @@ class Object { ...@@ -75,24 +75,24 @@ class Object {
* @return the check result. * @return the check result.
*/ */
virtual bool _DerivedFrom(uint32_t tid) const; virtual bool _DerivedFrom(uint32_t tid) const;
/*! /**
* @brief get a runtime unique type index given a type key * @brief get a runtime unique type index given a type key
* @param type_key Type key of a type. * @param type_key Type key of a type.
* @return the corresponding type index. * @return the corresponding type index.
*/ */
static uint32_t TypeKey2Index(const char* type_key); static uint32_t TypeKey2Index(const char* type_key);
/*! /**
* @brief get type key from type index. * @brief get type key from type index.
* @param index The type index * @param index The type index
* @return the corresponding type key. * @return the corresponding type key.
*/ */
static const char* TypeIndex2Key(uint32_t index); static const char* TypeIndex2Key(uint32_t index);
/*! /**
* @return whether the type is derived from * @return whether the type is derived from
*/ */
template <typename T> template <typename T>
inline bool derived_from() const; inline bool derived_from() const;
/*! /**
* @return whether the object is of type T * @return whether the object is of type T
* @tparam The type to be checked. * @tparam The type to be checked.
*/ */
...@@ -103,12 +103,12 @@ class Object { ...@@ -103,12 +103,12 @@ class Object {
static constexpr const char* _type_key = "Object"; static constexpr const char* _type_key = "Object";
}; };
/*! @brief base class of all reference object */ /** @brief base class of all reference object */
class ObjectRef { class ObjectRef {
public: public:
/*! @brief type indicate the container type */ /** @brief type indicate the container type */
using ContainerType = Object; using ContainerType = Object;
/*! /**
* @brief Comparator * @brief Comparator
* *
* Compare with the two are referencing to the same object (compare by * Compare with the two are referencing to the same object (compare by
...@@ -119,7 +119,7 @@ class ObjectRef { ...@@ -119,7 +119,7 @@ class ObjectRef {
* @sa same_as * @sa same_as
*/ */
inline bool operator==(const ObjectRef& other) const; inline bool operator==(const ObjectRef& other) const;
/*! /**
* @brief Comparator * @brief Comparator
* *
* Compare with the two are referencing to the same object (compare by * Compare with the two are referencing to the same object (compare by
...@@ -129,7 +129,7 @@ class ObjectRef { ...@@ -129,7 +129,7 @@ class ObjectRef {
* @return the compare result. * @return the compare result.
*/ */
inline bool same_as(const ObjectRef& other) const; inline bool same_as(const ObjectRef& other) const;
/*! /**
* @brief Comparator * @brief Comparator
* *
* The operator overload allows ObjectRef be used in std::map. * The operator overload allows ObjectRef be used in std::map.
...@@ -138,24 +138,24 @@ class ObjectRef { ...@@ -138,24 +138,24 @@ class ObjectRef {
* @return the compare result. * @return the compare result.
*/ */
inline bool operator<(const ObjectRef& other) const; inline bool operator<(const ObjectRef& other) const;
/*! /**
* @brief Comparator * @brief Comparator
* @param other Another object ref. * @param other Another object ref.
* @return the compare result. * @return the compare result.
* @sa same_as * @sa same_as
*/ */
inline bool operator!=(const ObjectRef& other) const; inline bool operator!=(const ObjectRef& other) const;
/*! @return the hash function for ObjectRef */ /** @return the hash function for ObjectRef */
inline size_t hash() const; inline size_t hash() const;
/*! @return whether the expression is null */ /** @return whether the expression is null */
inline bool defined() const; inline bool defined() const;
/*! @return the internal type index of Object */ /** @return the internal type index of Object */
inline uint32_t type_index() const; inline uint32_t type_index() const;
/*! @return the internal object pointer */ /** @return the internal object pointer */
inline const Object* get() const; inline const Object* get() const;
/*! @return the internal object pointer */ /** @return the internal object pointer */
inline const Object* operator->() const; inline const Object* operator->() const;
/*! /**
* @brief Downcast this object to its actual type. * @brief Downcast this object to its actual type.
* This returns nullptr if the object is not of the requested type. * This returns nullptr if the object is not of the requested type.
* Example usage: * Example usage:
...@@ -168,15 +168,15 @@ class ObjectRef { ...@@ -168,15 +168,15 @@ class ObjectRef {
template <typename T> template <typename T>
inline const T* as() const; inline const T* as() const;
/*! @brief default constructor */ /** @brief default constructor */
ObjectRef() = default; ObjectRef() = default;
explicit ObjectRef(std::shared_ptr<Object> obj) : obj_(obj) {} explicit ObjectRef(std::shared_ptr<Object> obj) : obj_(obj) {}
/*! @brief the internal object, do not touch */ /** @brief the internal object, do not touch */
std::shared_ptr<Object> obj_; std::shared_ptr<Object> obj_;
}; };
/*! /**
* @brief helper macro to declare type information in a base object. * @brief helper macro to declare type information in a base object.
* *
* This is macro should be used in abstract base class definition * This is macro should be used in abstract base class definition
...@@ -189,7 +189,7 @@ class ObjectRef { ...@@ -189,7 +189,7 @@ class ObjectRef {
return Parent::_DerivedFrom(tid); \ return Parent::_DerivedFrom(tid); \
} }
/*! /**
* @brief helper macro to declare type information in a terminal class * @brief helper macro to declare type information in a terminal class
* *
* This is macro should be used in terminal class definition. * This is macro should be used in terminal class definition.
...@@ -222,7 +222,7 @@ class ObjectRef { ...@@ -222,7 +222,7 @@ class ObjectRef {
return Parent::_DerivedFrom(tid); \ return Parent::_DerivedFrom(tid); \
} }
/*! @brief Macro to generate common object reference class method definition */ /** @brief Macro to generate common object reference class method definition */
#define DGL_DEFINE_OBJECT_REF_METHODS(TypeName, BaseTypeName, ObjectName) \ #define DGL_DEFINE_OBJECT_REF_METHODS(TypeName, BaseTypeName, ObjectName) \
TypeName() {} \ TypeName() {} \
explicit TypeName(std::shared_ptr<runtime::Object> obj) \ explicit TypeName(std::shared_ptr<runtime::Object> obj) \
...@@ -237,7 +237,7 @@ class ObjectRef { ...@@ -237,7 +237,7 @@ class ObjectRef {
operator bool() const { return this->defined(); } \ operator bool() const { return this->defined(); } \
using ContainerType = ObjectName using ContainerType = ObjectName
/*! @brief Macro to generate object reference class definition */ /** @brief Macro to generate object reference class definition */
#define DGL_DEFINE_OBJECT_REF(TypeName, ObjectName) \ #define DGL_DEFINE_OBJECT_REF(TypeName, ObjectName) \
class TypeName : public ::dgl::runtime::ObjectRef { \ class TypeName : public ::dgl::runtime::ObjectRef { \
public: \ public: \
...@@ -300,12 +300,12 @@ inline const T* ObjectRef::as() const { ...@@ -300,12 +300,12 @@ inline const T* ObjectRef::as() const {
return nullptr; return nullptr;
} }
/*! @brief The hash function for nodes */ /** @brief The hash function for nodes */
struct ObjectHash { struct ObjectHash {
size_t operator()(const ObjectRef& a) const { return a.hash(); } size_t operator()(const ObjectRef& a) const { return a.hash(); }
}; };
/*! @brief The equal comparator for nodes */ /** @brief The equal comparator for nodes */
struct ObjectEqual { struct ObjectEqual {
bool operator()(const ObjectRef& a, const ObjectRef& b) const { bool operator()(const ObjectRef& a, const ObjectRef& b) const {
return a.get() == b.get(); return a.get() == b.get();
......
/*! /**
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* @file dgl/runtime/packed_func.h * @file dgl/runtime/packed_func.h
* @brief Type-erased function used across DGL API. * @brief Type-erased function used across DGL API.
...@@ -41,7 +41,7 @@ class DGLArgValue; ...@@ -41,7 +41,7 @@ class DGLArgValue;
class DGLRetValue; class DGLRetValue;
class DGLArgsSetter; class DGLArgsSetter;
/*! /**
* @brief Packed function is a type-erased function. * @brief Packed function is a type-erased function.
* The arguments are passed by packed format. * The arguments are passed by packed format.
* *
...@@ -51,7 +51,7 @@ class DGLArgsSetter; ...@@ -51,7 +51,7 @@ class DGLArgsSetter;
*/ */
class PackedFunc { class PackedFunc {
public: public:
/*! /**
* @brief The internal std::function * @brief The internal std::function
* @param args The arguments to the function. * @param args The arguments to the function.
* @param rv The return value. * @param rv The return value.
...@@ -70,14 +70,14 @@ class PackedFunc { ...@@ -70,14 +70,14 @@ class PackedFunc {
* @endcode * @endcode
*/ */
using FType = std::function<void(DGLArgs args, DGLRetValue* rv)>; using FType = std::function<void(DGLArgs args, DGLRetValue* rv)>;
/*! @brief default constructor */ /** @brief default constructor */
PackedFunc() {} PackedFunc() {}
/*! /**
* @brief constructing a packed function from a std::function. * @brief constructing a packed function from a std::function.
* @param body the internal container of packed function. * @param body the internal container of packed function.
*/ */
explicit PackedFunc(FType body) : body_(body) {} explicit PackedFunc(FType body) : body_(body) {}
/*! /**
* @brief Call packed function by directly passing in unpacked format. * @brief Call packed function by directly passing in unpacked format.
* @param args Arguments to be passed. * @param args Arguments to be passed.
* @tparam Args arguments to be passed. * @tparam Args arguments to be passed.
...@@ -93,32 +93,32 @@ class PackedFunc { ...@@ -93,32 +93,32 @@ class PackedFunc {
*/ */
template <typename... Args> template <typename... Args>
inline DGLRetValue operator()(Args&&... args) const; inline DGLRetValue operator()(Args&&... args) const;
/*! /**
* @brief Call the function in packed format. * @brief Call the function in packed format.
* @param args The arguments * @param args The arguments
* @param rv The return value. * @param rv The return value.
*/ */
inline void CallPacked(DGLArgs args, DGLRetValue* rv) const; inline void CallPacked(DGLArgs args, DGLRetValue* rv) const;
/*! @return the internal body function */ /** @return the internal body function */
inline FType body() const; inline FType body() const;
/*! @return Whether the packed function is nullptr */ /** @return Whether the packed function is nullptr */
bool operator==(std::nullptr_t null) const { return body_ == nullptr; } bool operator==(std::nullptr_t null) const { return body_ == nullptr; }
/*! @return Whether the packed function is not nullptr */ /** @return Whether the packed function is not nullptr */
bool operator!=(std::nullptr_t null) const { return body_ != nullptr; } bool operator!=(std::nullptr_t null) const { return body_ != nullptr; }
private: private:
/*! @brief internal container of packed function */ /** @brief internal container of packed function */
FType body_; FType body_;
}; };
/*! /**
* @brief Please refer to \ref TypedPackedFuncAnchor * @brief Please refer to \ref TypedPackedFuncAnchor
* "TypedPackedFunc<R(Args..)>" * "TypedPackedFunc<R(Args..)>"
*/ */
template <typename FType> template <typename FType>
class TypedPackedFunc; class TypedPackedFunc;
/*! /**
* @anchor TypedPackedFuncAnchor * @anchor TypedPackedFuncAnchor
* @brief A PackedFunc wrapper to provide typed function signature. * @brief A PackedFunc wrapper to provide typed function signature.
* It is backed by a PackedFunc internally. * It is backed by a PackedFunc internally.
...@@ -153,11 +153,11 @@ class TypedPackedFunc; ...@@ -153,11 +153,11 @@ class TypedPackedFunc;
template <typename R, typename... Args> template <typename R, typename... Args>
class TypedPackedFunc<R(Args...)> { class TypedPackedFunc<R(Args...)> {
public: public:
/*! @brief short hand for this function type */ /** @brief short hand for this function type */
using TSelf = TypedPackedFunc<R(Args...)>; using TSelf = TypedPackedFunc<R(Args...)>;
/*! @brief default constructor */ /** @brief default constructor */
TypedPackedFunc() {} TypedPackedFunc() {}
/*! /**
* @brief construct by wrap a PackedFunc * @brief construct by wrap a PackedFunc
* *
* Example usage: * Example usage:
...@@ -175,7 +175,7 @@ class TypedPackedFunc<R(Args...)> { ...@@ -175,7 +175,7 @@ class TypedPackedFunc<R(Args...)> {
* @param packed The packed function * @param packed The packed function
*/ */
inline explicit TypedPackedFunc(PackedFunc packed); inline explicit TypedPackedFunc(PackedFunc packed);
/*! /**
* @brief construct from a lambda function with the same signature. * @brief construct from a lambda function with the same signature.
* *
* Example usage: * Example usage:
...@@ -196,7 +196,7 @@ class TypedPackedFunc<R(Args...)> { ...@@ -196,7 +196,7 @@ class TypedPackedFunc<R(Args...)> {
explicit TypedPackedFunc(const FLambda& typed_lambda) { explicit TypedPackedFunc(const FLambda& typed_lambda) {
this->AssignTypedLambda(typed_lambda); this->AssignTypedLambda(typed_lambda);
} }
/*! /**
* @brief copy assignment operator from typed lambda * @brief copy assignment operator from typed lambda
* *
* Example usage: * Example usage:
...@@ -220,7 +220,7 @@ class TypedPackedFunc<R(Args...)> { ...@@ -220,7 +220,7 @@ class TypedPackedFunc<R(Args...)> {
this->AssignTypedLambda(typed_lambda); this->AssignTypedLambda(typed_lambda);
return *this; return *this;
} }
/*! /**
* @brief copy assignment operator from PackedFunc. * @brief copy assignment operator from PackedFunc.
* @param packed The packed function. * @param packed The packed function.
* @returns reference to self. * @returns reference to self.
...@@ -229,27 +229,27 @@ class TypedPackedFunc<R(Args...)> { ...@@ -229,27 +229,27 @@ class TypedPackedFunc<R(Args...)> {
packed_ = packed; packed_ = packed;
return *this; return *this;
} }
/*! /**
* @brief Invoke the operator. * @brief Invoke the operator.
* @param args The arguments * @param args The arguments
* @returns The return value. * @returns The return value.
*/ */
inline R operator()(Args... args) const; inline R operator()(Args... args) const;
/*! /**
* @brief convert to PackedFunc * @brief convert to PackedFunc
* @return the internal PackedFunc * @return the internal PackedFunc
*/ */
operator PackedFunc() const { return packed(); } operator PackedFunc() const { return packed(); }
/*! /**
* @return reference the internal PackedFunc * @return reference the internal PackedFunc
*/ */
const PackedFunc& packed() const { return packed_; } const PackedFunc& packed() const { return packed_; }
private: private:
friend class DGLRetValue; friend class DGLRetValue;
/*! @brief The internal packed function */ /** @brief The internal packed function */
PackedFunc packed_; PackedFunc packed_;
/*! /**
* @brief Assign the packed field using a typed lambda function. * @brief Assign the packed field using a typed lambda function.
* *
* @param flambda The lambda function. * @param flambda The lambda function.
...@@ -260,13 +260,13 @@ class TypedPackedFunc<R(Args...)> { ...@@ -260,13 +260,13 @@ class TypedPackedFunc<R(Args...)> {
inline void AssignTypedLambda(FLambda flambda); inline void AssignTypedLambda(FLambda flambda);
}; };
/*! @brief Arguments into DGL functions. */ /** @brief Arguments into DGL functions. */
class DGLArgs { class DGLArgs {
public: public:
const DGLValue* values; const DGLValue* values;
const int* type_codes; const int* type_codes;
int num_args; int num_args;
/*! /**
* @brief constructor * @brief constructor
* @param values The argument values * @param values The argument values
* @param type_codes The argument type codes * @param type_codes The argument type codes
...@@ -274,9 +274,9 @@ class DGLArgs { ...@@ -274,9 +274,9 @@ class DGLArgs {
*/ */
DGLArgs(const DGLValue* values, const int* type_codes, int num_args) DGLArgs(const DGLValue* values, const int* type_codes, int num_args)
: values(values), type_codes(type_codes), num_args(num_args) {} : values(values), type_codes(type_codes), num_args(num_args) {}
/*! @return size of the arguments */ /** @return size of the arguments */
inline int size() const; inline int size() const;
/*! /**
* @brief Get i-th argument * @brief Get i-th argument
* @param i the index. * @param i the index.
* @return the ith argument. * @return the ith argument.
...@@ -284,7 +284,7 @@ class DGLArgs { ...@@ -284,7 +284,7 @@ class DGLArgs {
inline DGLArgValue operator[](int i) const; inline DGLArgValue operator[](int i) const;
}; };
/*! /**
* @brief Type traits to mark if a class is dgl extension type. * @brief Type traits to mark if a class is dgl extension type.
* *
* To enable extension type in C++ must be register () ed via marco. * To enable extension type in C++ must be register () ed via marco.
...@@ -300,23 +300,23 @@ struct extension_class_info { ...@@ -300,23 +300,23 @@ struct extension_class_info {
static const int code = 0; static const int code = 0;
}; };
/*! /**
* @brief Runtime function table about extension type. * @brief Runtime function table about extension type.
*/ */
class ExtTypeVTable { class ExtTypeVTable {
public: public:
/*! @brief function to be called to delete a handle */ /** @brief function to be called to delete a handle */
void (*destroy)(void* handle); void (*destroy)(void* handle);
/*! @brief function to be called when clone a handle */ /** @brief function to be called when clone a handle */
void* (*clone)(void* handle); void* (*clone)(void* handle);
/*! /**
* @brief Register type * @brief Register type
* @tparam T The type to be register. * @tparam T The type to be register.
* @return The registered vtable. * @return The registered vtable.
*/ */
template <typename T> template <typename T>
static inline ExtTypeVTable* Register_(); static inline ExtTypeVTable* Register_();
/*! /**
* @brief Get a vtable based on type code. * @brief Get a vtable based on type code.
* @param type_code The type code * @param type_code The type code
* @return The registered vtable. * @return The registered vtable.
...@@ -329,7 +329,7 @@ class ExtTypeVTable { ...@@ -329,7 +329,7 @@ class ExtTypeVTable {
int type_code, const ExtTypeVTable& vt); int type_code, const ExtTypeVTable& vt);
}; };
/*! /**
* @brief Internal base class to * @brief Internal base class to
* handle conversion to POD values. * handle conversion to POD values.
*/ */
...@@ -393,7 +393,7 @@ class DGLPODValue_ { ...@@ -393,7 +393,7 @@ class DGLPODValue_ {
return static_cast<TExtension*>(value_.v_handle)[0]; return static_cast<TExtension*>(value_.v_handle)[0];
} }
int type_code() const { return type_code_; } int type_code() const { return type_code_; }
/*! /**
* @brief return handle as specific pointer type. * @brief return handle as specific pointer type.
* @tparam T the data type. * @tparam T the data type.
* @return The pointer type. * @return The pointer type.
...@@ -410,13 +410,13 @@ class DGLPODValue_ { ...@@ -410,13 +410,13 @@ class DGLPODValue_ {
DGLPODValue_(DGLValue value, int type_code) DGLPODValue_(DGLValue value, int type_code)
: value_(value), type_code_(type_code) {} : value_(value), type_code_(type_code) {}
/*! @brief The value */ /** @brief The value */
DGLValue value_; DGLValue value_;
/*! @brief the type code */ /** @brief the type code */
int type_code_; int type_code_;
}; };
/*! /**
* @brief A single argument value to PackedFunc. * @brief A single argument value to PackedFunc.
* Containing both type_code and DGLValue * Containing both type_code and DGLValue
* *
...@@ -424,9 +424,9 @@ class DGLPODValue_ { ...@@ -424,9 +424,9 @@ class DGLPODValue_ {
*/ */
class DGLArgValue : public DGLPODValue_ { class DGLArgValue : public DGLPODValue_ {
public: public:
/*! @brief default constructor */ /** @brief default constructor */
DGLArgValue() {} DGLArgValue() {}
/*! /**
* @brief constructor * @brief constructor
* @param value of the function * @param value of the function
* @param type_code The type code. * @param type_code The type code.
...@@ -497,7 +497,7 @@ class DGLArgValue : public DGLPODValue_ { ...@@ -497,7 +497,7 @@ class DGLArgValue : public DGLPODValue_ {
inline std::shared_ptr<Object>& obj_sptr(); inline std::shared_ptr<Object>& obj_sptr();
}; };
/*! /**
* @brief Return Value container, * @brief Return Value container,
* Unlike DGLArgValue, which only holds reference and do not delete * Unlike DGLArgValue, which only holds reference and do not delete
* the underlying container during destruction. * the underlying container during destruction.
...@@ -507,9 +507,9 @@ class DGLArgValue : public DGLPODValue_ { ...@@ -507,9 +507,9 @@ class DGLArgValue : public DGLPODValue_ {
*/ */
class DGLRetValue : public DGLPODValue_ { class DGLRetValue : public DGLPODValue_ {
public: public:
/*! @brief default constructor */ /** @brief default constructor */
DGLRetValue() {} DGLRetValue() {}
/*! /**
* @brief move constructor from anoter return value. * @brief move constructor from anoter return value.
* @param other The other return value. * @param other The other return value.
*/ */
...@@ -518,7 +518,7 @@ class DGLRetValue : public DGLPODValue_ { ...@@ -518,7 +518,7 @@ class DGLRetValue : public DGLPODValue_ {
other.value_.v_handle = nullptr; other.value_.v_handle = nullptr;
other.type_code_ = kNull; other.type_code_ = kNull;
} }
/*! @brief destructor */ /** @brief destructor */
~DGLRetValue() { this->Clear(); } ~DGLRetValue() { this->Clear(); }
// reuse converter from parent // reuse converter from parent
using DGLPODValue_::operator double; using DGLPODValue_::operator double;
...@@ -652,7 +652,7 @@ class DGLRetValue : public DGLPODValue_ { ...@@ -652,7 +652,7 @@ class DGLRetValue : public DGLPODValue_ {
this->SwitchToClass<T>(extension_class_info<T>::code, other); this->SwitchToClass<T>(extension_class_info<T>::code, other);
return *this; return *this;
} }
/*! /**
* @brief Move the value back to front-end via C API. * @brief Move the value back to front-end via C API.
* This marks the current container as null. * This marks the current container as null.
* The managed resources is moved to front-end and * The managed resources is moved to front-end and
...@@ -668,7 +668,7 @@ class DGLRetValue : public DGLPODValue_ { ...@@ -668,7 +668,7 @@ class DGLRetValue : public DGLPODValue_ {
*ret_type_code = type_code_; *ret_type_code = type_code_;
type_code_ = kNull; type_code_ = kNull;
} }
/*! @return The value field, if the data is POD */ /** @return The value field, if the data is POD */
const DGLValue& value() const { const DGLValue& value() const {
CHECK( CHECK(
type_code_ != kObjectHandle && type_code_ != kFuncHandle && type_code_ != kObjectHandle && type_code_ != kFuncHandle &&
...@@ -920,9 +920,9 @@ class DGLArgsSetter { ...@@ -920,9 +920,9 @@ class DGLArgsSetter {
inline void operator()(size_t i, const ObjectRef& other) const; // NOLINT(*) inline void operator()(size_t i, const ObjectRef& other) const; // NOLINT(*)
private: private:
/*! @brief The values fields */ /** @brief The values fields */
DGLValue* values_; DGLValue* values_;
/*! @brief The type code fields */ /** @brief The type code fields */
int* type_codes_; int* type_codes_;
}; };
......
/*! /**
* Copyright (c) 2021 by Contributors * Copyright (c) 2021 by Contributors
* @file runtime/container.h * @file runtime/container.h
* @brief Defines the container object data structures. * @brief Defines the container object data structures.
...@@ -56,7 +56,7 @@ inline size_t compute_num_threads(size_t begin, size_t end, size_t grain_size) { ...@@ -56,7 +56,7 @@ inline size_t compute_num_threads(size_t begin, size_t end, size_t grain_size) {
static DefaultGrainSizeT default_grain_size; static DefaultGrainSizeT default_grain_size;
/*! /**
* @brief OpenMP-based parallel for loop. * @brief OpenMP-based parallel for loop.
* *
* It requires each thread's workload to have at least \a grain_size elements. * It requires each thread's workload to have at least \a grain_size elements.
...@@ -101,7 +101,7 @@ void parallel_for( ...@@ -101,7 +101,7 @@ void parallel_for(
#endif #endif
} }
/*! /**
* @brief OpenMP-based parallel for loop with default grain size. * @brief OpenMP-based parallel for loop with default grain size.
* *
* parallel_for with grain size to default value, either 1 or controlled through * parallel_for with grain size to default value, either 1 or controlled through
...@@ -117,7 +117,7 @@ void parallel_for( ...@@ -117,7 +117,7 @@ void parallel_for(
parallel_for(begin, end, default_grain_size(), std::forward<F>(f)); parallel_for(begin, end, default_grain_size(), std::forward<F>(f));
} }
/*! /**
* @brief OpenMP-based two-stage parallel reduction. * @brief OpenMP-based two-stage parallel reduction.
* *
* The first-stage reduction function \a f works in parallel. Each thread's workload has * The first-stage reduction function \a f works in parallel. Each thread's workload has
......
/*! /**
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* @file dgl/runtime/registry.h * @file dgl/runtime/registry.h
* @brief This file defines the DGL global function registry. * @brief This file defines the DGL global function registry.
...@@ -33,22 +33,22 @@ ...@@ -33,22 +33,22 @@
namespace dgl { namespace dgl {
namespace runtime { namespace runtime {
/*! @brief Registry for global function */ /** @brief Registry for global function */
class Registry { class Registry {
public: public:
/*! /**
* @brief set the body of the function to be f * @brief set the body of the function to be f
* @param f The body of the function. * @param f The body of the function.
*/ */
DGL_DLL Registry& set_body(PackedFunc f); // NOLINT(*) DGL_DLL Registry& set_body(PackedFunc f); // NOLINT(*)
/*! /**
* @brief set the body of the function to be f * @brief set the body of the function to be f
* @param f The body of the function. * @param f The body of the function.
*/ */
Registry& set_body(PackedFunc::FType f) { // NOLINT(*) Registry& set_body(PackedFunc::FType f) { // NOLINT(*)
return set_body(PackedFunc(f)); return set_body(PackedFunc(f));
} }
/*! /**
* @brief set the body of the function to be TypedPackedFunc. * @brief set the body of the function to be TypedPackedFunc.
* *
* @code * @code
...@@ -66,7 +66,7 @@ class Registry { ...@@ -66,7 +66,7 @@ class Registry {
Registry& set_body_typed(FLambda f) { Registry& set_body_typed(FLambda f) {
return set_body(TypedPackedFunc<FType>(f).packed()); return set_body(TypedPackedFunc<FType>(f).packed());
} }
/*! /**
* @brief Register a function with given name * @brief Register a function with given name
* @param name The name of the function. * @param name The name of the function.
* @param override Whether allow oveeride existing function. * @param override Whether allow oveeride existing function.
...@@ -74,20 +74,20 @@ class Registry { ...@@ -74,20 +74,20 @@ class Registry {
*/ */
DGL_DLL static Registry& Register( DGL_DLL static Registry& Register(
const std::string& name, bool override = false); // NOLINT(*) const std::string& name, bool override = false); // NOLINT(*)
/*! /**
* @brief Erase global function from registry, if exist. * @brief Erase global function from registry, if exist.
* @param name The name of the function. * @param name The name of the function.
* @return Whether function exist. * @return Whether function exist.
*/ */
DGL_DLL static bool Remove(const std::string& name); DGL_DLL static bool Remove(const std::string& name);
/*! /**
* @brief Get the global function by name. * @brief Get the global function by name.
* @param name The name of the function. * @param name The name of the function.
* @return pointer to the registered function, * @return pointer to the registered function,
* nullptr if it does not exist. * nullptr if it does not exist.
*/ */
DGL_DLL static const PackedFunc* Get(const std::string& name); // NOLINT(*) DGL_DLL static const PackedFunc* Get(const std::string& name); // NOLINT(*)
/*! /**
* @brief Get the names of currently registered global function. * @brief Get the names of currently registered global function.
* @return The names * @return The names
*/ */
...@@ -97,14 +97,14 @@ class Registry { ...@@ -97,14 +97,14 @@ class Registry {
struct Manager; struct Manager;
protected: protected:
/*! @brief name of the function */ /** @brief name of the function */
std::string name_; std::string name_;
/*! @brief internal packed function */ /** @brief internal packed function */
PackedFunc func_; PackedFunc func_;
friend struct Manager; friend struct Manager;
}; };
/*! @brief helper macro to supress unused warning */ /** @brief helper macro to supress unused warning */
#if defined(__GNUC__) #if defined(__GNUC__)
#define DGL_ATTRIBUTE_UNUSED __attribute__((unused)) #define DGL_ATTRIBUTE_UNUSED __attribute__((unused))
#else #else
...@@ -120,7 +120,7 @@ class Registry { ...@@ -120,7 +120,7 @@ class Registry {
#define DGL_TYPE_REG_VAR_DEF \ #define DGL_TYPE_REG_VAR_DEF \
static DGL_ATTRIBUTE_UNUSED ::dgl::runtime::ExtTypeVTable* __mk_##DGLT static DGL_ATTRIBUTE_UNUSED ::dgl::runtime::ExtTypeVTable* __mk_##DGLT
/*! /**
* @brief Register a function globally. * @brief Register a function globally.
* @code * @code
* DGL_REGISTER_GLOBAL("MyPrint") * DGL_REGISTER_GLOBAL("MyPrint")
...@@ -132,7 +132,7 @@ class Registry { ...@@ -132,7 +132,7 @@ class Registry {
DGL_STR_CONCAT(DGL_FUNC_REG_VAR_DEF, __COUNTER__) = \ DGL_STR_CONCAT(DGL_FUNC_REG_VAR_DEF, __COUNTER__) = \
::dgl::runtime::Registry::Register(OpName) ::dgl::runtime::Registry::Register(OpName)
/*! /**
* @brief Macro to register extension type. * @brief Macro to register extension type.
* This must be registered in a cc file * This must be registered in a cc file
* after the trait extension_class_info is defined. * after the trait extension_class_info is defined.
......
/*! /**
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* @file dgl/runtime/serializer.h * @file dgl/runtime/serializer.h
* @brief Serializer extension to support DGL data types * @brief Serializer extension to support DGL data types
......
/*! /**
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* @file dgl/runtime/ndarray.h * @file dgl/runtime/ndarray.h
* @brief shared memory management. * @brief shared memory management.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
namespace dgl { namespace dgl {
namespace runtime { namespace runtime {
/* /**
* @brief This class owns shared memory. * @brief This class owns shared memory.
* *
* When the object is gone, the shared memory will also be destroyed. * When the object is gone, the shared memory will also be destroyed.
...@@ -22,7 +22,7 @@ namespace runtime { ...@@ -22,7 +22,7 @@ namespace runtime {
* the shared memory is removed. * the shared memory is removed.
*/ */
class SharedMemory { class SharedMemory {
/* /**
* @brief whether the shared memory is owned by the object. * @brief whether the shared memory is owned by the object.
* *
* If shared memory is created in the object, it'll be owned by the object * If shared memory is created in the object, it'll be owned by the object
...@@ -41,7 +41,7 @@ class SharedMemory { ...@@ -41,7 +41,7 @@ class SharedMemory {
/* @brief the size of the shared memory. */ /* @brief the size of the shared memory. */
size_t size_; size_t size_;
/* /**
* @brief the name of the object. * @brief the name of the object.
* *
* In Unix, shared memory is identified by a file. Thus, `name` is actually * In Unix, shared memory is identified by a file. Thus, `name` is actually
...@@ -54,31 +54,31 @@ class SharedMemory { ...@@ -54,31 +54,31 @@ class SharedMemory {
*/ */
std::string GetName() const { return name; } std::string GetName() const { return name; }
/* /**
* @brief constructor of the shared memory. * @brief constructor of the shared memory.
* @param name The file corresponding to the shared memory. * @param name The file corresponding to the shared memory.
*/ */
explicit SharedMemory(const std::string &name); explicit SharedMemory(const std::string &name);
/* /**
* @brief destructor of the shared memory. * @brief destructor of the shared memory.
* It deallocates the shared memory and removes the corresponding file. * It deallocates the shared memory and removes the corresponding file.
*/ */
~SharedMemory(); ~SharedMemory();
/* /**
* @brief create shared memory. * @brief create shared memory.
* It creates the file and shared memory. * It creates the file and shared memory.
* @param sz the size of the shared memory. * @param sz the size of the shared memory.
* @return the address of the shared memory * @return the address of the shared memory
*/ */
void *CreateNew(size_t sz); void *CreateNew(size_t sz);
/* /**
* @brief allocate shared memory that has been created. * @brief allocate shared memory that has been created.
* @param sz the size of the shared memory. * @param sz the size of the shared memory.
* @return the address of the shared memory * @return the address of the shared memory
*/ */
void *Open(size_t sz); void *Open(size_t sz);
/* /**
* @brief check if the shared memory exist. * @brief check if the shared memory exist.
* @param name the name of the shared memory. * @param name the name of the shared memory.
* @return a boolean value to indicate if the shared memory exists. * @return a boolean value to indicate if the shared memory exists.
......
/*! /**
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* @file dgl/runtime/serializer.h * @file dgl/runtime/serializer.h
* @brief Serializer extension to support DGL data types * @brief Serializer extension to support DGL data types
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment