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.
......
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