Skip to content

Commit

Permalink
[Misc] Replace \xxx with @xxx in structured comment. (dmlc#4822)
Browse files Browse the repository at this point in the history
* param

* brief

* note

* return

* tparam

* brief2

* file

* return2

* return

* blabla

* all

Co-authored-by: Steve <[email protected]>
  • Loading branch information
frozenbugs and Steve authored Nov 6, 2022
1 parent 96297fb commit 619d735
Show file tree
Hide file tree
Showing 277 changed files with 2,634 additions and 2,632 deletions.
144 changes: 72 additions & 72 deletions include/dgl/aten/array_ops.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* Copyright (c) 2020 by Contributors
* \file dgl/aten/array_ops.h
* \brief Common array operations required by DGL.
* @file dgl/aten/array_ops.h
* @brief Common array operations required by DGL.
*
* Note that this is not meant for a full support of array library such as ATen.
* Only a limited set of operators required by DGL are implemented.
Expand All @@ -23,79 +23,79 @@ namespace aten {
// ID array
//////////////////////////////////////////////////////////////////////

/*! \return A special array to represent null. */
/*! @return A special array to represent null. */
inline NDArray NullArray(const DGLDataType& dtype = DGLDataType{kDGLInt, 64, 1},
const DGLContext& ctx = DGLContext{kDGLCPU, 0}) {
return NDArray::Empty({0}, dtype, ctx);
}

/*!
* \return Whether the input array is a null array.
* @return Whether the input array is a null array.
*/
inline bool IsNullArray(NDArray array) {
return array->shape[0] == 0;
}

/*!
* \brief Create a new id array with given length
* \param length The array length
* \param ctx The array context
* \param nbits The number of integer bits
* \return id array
* @brief Create a new id array with given length
* @param length The array length
* @param ctx The array context
* @param nbits The number of integer bits
* @return id array
*/
IdArray NewIdArray(int64_t length,
DGLContext ctx = DGLContext{kDGLCPU, 0},
uint8_t nbits = 64);

/*!
* \brief Create a new id array using the given vector data
* \param vec The vector data
* \param nbits The integer bits of the returned array
* \param ctx The array context
* \return the id array
* @brief Create a new id array using the given vector data
* @param vec The vector data
* @param nbits The integer bits of the returned array
* @param ctx The array context
* @return the id array
*/
template <typename T>
IdArray VecToIdArray(const std::vector<T>& vec,
uint8_t nbits = 64,
DGLContext ctx = DGLContext{kDGLCPU, 0});

/*!
* \brief Return an array representing a 1D range.
* \param low Lower bound (inclusive).
* \param high Higher bound (exclusive).
* \param nbits result array's bits (32 or 64)
* \param ctx Device context
* \return range array
* @brief Return an array representing a 1D range.
* @param low Lower bound (inclusive).
* @param high Higher bound (exclusive).
* @param nbits result array's bits (32 or 64)
* @param ctx Device context
* @return range array
*/
IdArray Range(int64_t low, int64_t high, uint8_t nbits, DGLContext ctx);

/*!
* \brief Return an array full of the given value
* \param val The value to fill.
* \param length Number of elements.
* \param nbits result array's bits (32 or 64)
* \param ctx Device context
* \return the result array
* @brief Return an array full of the given value
* @param val The value to fill.
* @param length Number of elements.
* @param nbits result array's bits (32 or 64)
* @param ctx Device context
* @return the result array
*/
IdArray Full(int64_t val, int64_t length, uint8_t nbits, DGLContext ctx);

/*!
* \brief Return an array full of the given value with the given type.
* \param val The value to fill.
* \param length Number of elements.
* \param ctx Device context
* \return the result array
* @brief Return an array full of the given value with the given type.
* @param val The value to fill.
* @param length Number of elements.
* @param ctx Device context
* @return the result array
*/
template <typename DType>
NDArray Full(DType val, int64_t length, DGLContext ctx);

/*! \brief Create a deep copy of the given array */
/*! @brief Create a deep copy of the given array */
IdArray Clone(IdArray arr);

/*! \brief Convert the idarray to the given bit width */
/*! @brief Convert the idarray to the given bit width */
IdArray AsNumBits(IdArray arr, uint8_t bits);

/*! \brief Arithmetic functions */
/*! @brief Arithmetic functions */
IdArray Add(IdArray lhs, IdArray rhs);
IdArray Sub(IdArray lhs, IdArray rhs);
IdArray Mul(IdArray lhs, IdArray rhs);
Expand Down Expand Up @@ -138,31 +138,31 @@ IdArray LE(int64_t lhs, IdArray rhs);
IdArray EQ(int64_t lhs, IdArray rhs);
IdArray NE(int64_t lhs, IdArray rhs);

/*! \brief Stack two arrays (of len L) into a 2*L length array */
/*! @brief Stack two arrays (of len L) into a 2*L length array */
IdArray HStack(IdArray arr1, IdArray arr2);

/*! \brief Return the indices of the elements that are non-zero. */
/*! @brief Return the indices of the elements that are non-zero. */
IdArray NonZero(BoolArray bool_arr);

/*!
* \brief Return the data under the index. In numpy notation, A[I]
* \tparam ValueType The type of return value.
* @brief Return the data under the index. In numpy notation, A[I]
* @tparam ValueType The type of return value.
*/
template<typename ValueType>
ValueType IndexSelect(NDArray array, int64_t index);

/*!
* \brief Return the data under the index. In numpy notation, A[I]
* @brief Return the data under the index. In numpy notation, A[I]
*/
NDArray IndexSelect(NDArray array, IdArray index);

/*!
* \brief Return the data from `start` (inclusive) to `end` (exclusive).
* @brief Return the data from `start` (inclusive) to `end` (exclusive).
*/
NDArray IndexSelect(NDArray array, int64_t start, int64_t end);

/*!
* \brief Permute the elements of an array according to given indices.
* @brief Permute the elements of an array according to given indices.
*
* Only support 1D arrays.
*
Expand All @@ -176,7 +176,7 @@ NDArray IndexSelect(NDArray array, int64_t start, int64_t end);
NDArray Scatter(NDArray array, IdArray indices);

/*!
* \brief Scatter data into the output array.
* @brief Scatter data into the output array.
*
* Equivalent to:
*
Expand All @@ -187,15 +187,15 @@ NDArray Scatter(NDArray array, IdArray indices);
void Scatter_(IdArray index, NDArray value, NDArray out);

/*!
* \brief Repeat each element a number of times. Equivalent to np.repeat(array, repeats)
* \param array A 1D vector
* \param repeats A 1D integer vector for number of times to repeat for each element in
* @brief Repeat each element a number of times. Equivalent to np.repeat(array, repeats)
* @param array A 1D vector
* @param repeats A 1D integer vector for number of times to repeat for each element in
* \c array. Must have the same shape as \c array.
*/
NDArray Repeat(NDArray array, IdArray repeats);

/*!
* \brief Relabel the given ids to consecutive ids.
* @brief Relabel the given ids to consecutive ids.
*
* Relabeling is done inplace. The mapping is created from the union
* of the give arrays.
Expand All @@ -206,21 +206,21 @@ NDArray Repeat(NDArray array, IdArray repeats);
* mapping is [2, 3, 10, 4, 0, 5], meaning the new ID 0 maps to the old ID
* 2, 1 maps to 3, so on and so forth.
*
* \param arrays The id arrays to relabel.
* \return mapping array M from new id to old id.
* @param arrays The id arrays to relabel.
* @return mapping array M from new id to old id.
*/
IdArray Relabel_(const std::vector<IdArray>& arrays);

/*!
* \brief concatenate the given id arrays to one array
* @brief concatenate the given id arrays to one array
*
* Example:
*
* Given two IdArrays [2, 3, 10, 0, 2] and [4, 10, 5]
* Return [2, 3, 10, 0, 2, 4, 10, 5]
*
* \param arrays The id arrays to concatenate.
* \return concatenated array.
* @param arrays The id arrays to concatenate.
* @return concatenated array.
*/
NDArray Concat(const std::vector<IdArray>& arrays);

Expand All @@ -230,7 +230,7 @@ inline bool IsValidIdArray(const dgl::runtime::NDArray& arr) {
}

/*!
* \brief Packs a tensor containing padded sequences of variable length.
* @brief Packs a tensor containing padded sequences of variable length.
*
* Similar to \c pack_padded_sequence in PyTorch, except that
*
Expand All @@ -240,11 +240,11 @@ inline bool IsValidIdArray(const dgl::runtime::NDArray& arr) {
* 3. Along with the tensor containing the packed sequence, it returns both the
* length, as well as the offsets to the packed tensor, of each sequence.
*
* \param array The tensor containing sequences padded to the same length
* \param pad_value The padding value
* \return A triplet of packed tensor, the length tensor, and the offset tensor
* @param array The tensor containing sequences padded to the same length
* @param pad_value The padding value
* @return A triplet of packed tensor, the length tensor, and the offset tensor
*
* \note Example: consider the following array with padding value -1:
* @note Example: consider the following array with padding value -1:
*
* <code>
* [[1, 2, -1, -1],
Expand All @@ -262,7 +262,7 @@ template<typename ValueType>
std::tuple<NDArray, IdArray, IdArray> Pack(NDArray array, ValueType pad_value);

/*!
* \brief Batch-slice a 1D or 2D array, and then pack the list of sliced arrays
* @brief Batch-slice a 1D or 2D array, and then pack the list of sliced arrays
* by concatenation.
*
* If a 2D array is given, then the function is equivalent to:
Expand All @@ -285,14 +285,14 @@ std::tuple<NDArray, IdArray, IdArray> Pack(NDArray array, ValueType pad_value);
* return packed, offsets
* </code>
*
* \param array A 1D or 2D tensor for slicing
* \param lengths A 1D tensor indicating the number of elements to slice
* \return The tensor with packed slices along with the offsets.
* @param array A 1D or 2D tensor for slicing
* @param lengths A 1D tensor indicating the number of elements to slice
* @return The tensor with packed slices along with the offsets.
*/
std::pair<NDArray, IdArray> ConcatSlices(NDArray array, IdArray lengths);

/*!
* \brief Return the cumulative summation (or inclusive sum) of the input array.
* @brief Return the cumulative summation (or inclusive sum) of the input array.
*
* The first element out[0] is equal to the first element of the input array
* array[0]. The rest elements are defined recursively, out[i] = out[i-1] + array[i].
Expand All @@ -302,40 +302,40 @@ std::pair<NDArray, IdArray> ConcatSlices(NDArray array, IdArray lengths);
* length is the input array length plus one. This is useful for creating
* an indptr array over a count array.
*
* \param array The 1D input array.
* \return Array after cumsum.
* @param array The 1D input array.
* @return Array after cumsum.
*/
IdArray CumSum(IdArray array, bool prepend_zero = false);

/*!
* \brief Return the nonzero index.
* @brief Return the nonzero index.
*
* Only support 1D array. The result index array is in int64.
*
* \param array The input array.
* \return A 1D index array storing the positions of the non zero values.
* @param array The input array.
* @return A 1D index array storing the positions of the non zero values.
*/
IdArray NonZero(NDArray array);

/*!
* \brief Sort the ID vector in ascending order.
* @brief Sort the ID vector in ascending order.
*
* It performs both sort and arg_sort (returning the sorted index). The sorted index
* is always in int64.
*
* \param array Input array.
* \param num_bits The number of bits used in key comparison. For example, if the data type
* @param array Input array.
* @param num_bits The number of bits used in key comparison. For example, if the data type
* of the input array is int32_t and `num_bits = 8`, it only uses bits in index
* range [0, 8) for sorting. Setting it to a small value could
* speed up the sorting if the underlying sorting algorithm is radix sort (e.g., on GPU).
* Setting it to zero (default value) means using all the bits for comparison.
* On CPU, it currently has no effect.
* \return A pair of arrays: sorted values and sorted index to the original position.
* @return A pair of arrays: sorted values and sorted index to the original position.
*/
std::pair<IdArray, IdArray> Sort(IdArray array, int num_bits = 0);

/*!
* \brief Return a string that prints out some debug information.
* @brief Return a string that prints out some debug information.
*/
std::string ToDebugString(NDArray array);

Expand All @@ -356,7 +356,7 @@ IdArray VecToIdArray(const std::vector<T>& vec,
}

/*!
* \brief Get the context of the first array, and check if the non-null arrays'
* @brief Get the context of the first array, and check if the non-null arrays'
* contexts are the same.
*/
inline DGLContext GetContextOf(const std::vector<IdArray>& arrays) {
Expand Down
Loading

0 comments on commit 619d735

Please sign in to comment.