"src/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "86becea77f3630b0e65525e4ebd2b10c26113763"
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.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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