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