Commit c5fb044c by xiaotong

comments and inferface improvement

parent d4907fe1
...@@ -33,8 +33,8 @@ copy indexed sub-tensors ...@@ -33,8 +33,8 @@ copy indexed sub-tensors
>> s - the source tensor >> s - the source tensor
>> t - the target tensor >> t - the target tensor
>> dim - the leading dimension to define "sub-tensors" >> dim - the leading dimension to define "sub-tensors"
e.g., for a tensor of size (3, 2, 4) and dim = 2, e.g., for a tensor of size (4, 2, 3) and dim = 0,
we have 4 sub-tensors of size (3, 2) we have 4 sub-tensors of size (2, 3)
>> srcIndex - index of the source sub-tensors >> srcIndex - index of the source sub-tensors
>> indexSize - length of srcIndex (and tgtIndex) >> indexSize - length of srcIndex (and tgtIndex)
>> tgtIndex - index of the target sub-tensors >> tgtIndex - index of the target sub-tensors
...@@ -46,11 +46,11 @@ void _CopyIndexed(const XTensor * s, XTensor * t, int dim, ...@@ -46,11 +46,11 @@ void _CopyIndexed(const XTensor * s, XTensor * t, int dim,
int * srcIndex, int indexSize, int * tgtIndex, int * srcIndex, int indexSize, int * tgtIndex,
int copyNum) int copyNum)
{ {
CheckNTErrors((s && t), "Invalid tensors!"); CheckNTErrors(s && t, "Invalid tensors!");
CheckNTErrors((s->devID == t->devID || (s->devID < 0 && t->devID < 0)), CheckNTErrors(s->devID == t->devID || (s->devID < 0 && t->devID < 0),
"the data must be kept on the same device!"); "the data must be kept on the same device!");
CheckNTErrors((dim < s->order && dim < t->order), "A too larget dimension specified!"); CheckNTErrors(dim < s->order && dim < t->order, "A too larget dimension specified!");
CheckNTErrors((s->unitSize == t->unitSize), "Unmatched tensors!"); CheckNTErrors(s->unitSize == t->unitSize, "Unmatched tensors!");
int dimRDI = s->order - dim - 1; int dimRDI = s->order - dim - 1;
int blockSizeSrc = 1; int blockSizeSrc = 1;
...@@ -108,8 +108,8 @@ copy selected sub-tensors where indeces are kept in tensors ...@@ -108,8 +108,8 @@ copy selected sub-tensors where indeces are kept in tensors
>> s - the source tensor >> s - the source tensor
>> t - the target tensor >> t - the target tensor
>> dim - the leading dimension to define "sub-tensors" >> dim - the leading dimension to define "sub-tensors"
e.g., for a tensor of size (3, 2, 4) and dim = 2, e.g., for a tensor of size (4, 2, 3) and dim = 0,
we have 4 sub-tensors of size (3, 2) we have 4 sub-tensors of size (2, 3)
>> srcIndex - the tensor to save the index of the source sub-tensors >> srcIndex - the tensor to save the index of the source sub-tensors
>> tgtIndex - the tensor to save the index of the target sub-tensors >> tgtIndex - the tensor to save the index of the target sub-tensors
>> copyNum - number of the sub-tensors we copy for each source index, >> copyNum - number of the sub-tensors we copy for each source index,
...@@ -124,17 +124,17 @@ void _CopyIndexed(const XTensor * s, XTensor * t, int dim, ...@@ -124,17 +124,17 @@ void _CopyIndexed(const XTensor * s, XTensor * t, int dim,
int indexSize = srcIndex->unitNum; int indexSize = srcIndex->unitNum;
CheckNTErrors(indexSize != 0, "NULL index!") CheckNTErrors(indexSize != 0, "NULL index!")
CheckNTErrors((s && t), "Invalid tensors!"); CheckNTErrors(s && t, "Invalid tensors!");
CheckNTErrors((srcIndex && tgtIndex), "Invalid index tensors!"); CheckNTErrors(srcIndex && tgtIndex, "Invalid index tensors!");
CheckNTErrors((s->devID == t->devID || (s->devID < 0 && t->devID < 0)), CheckNTErrors(s->devID == t->devID || (s->devID < 0 && t->devID < 0),
"the data must be kept on the same device!"); "the data must be kept on the same device!");
CheckNTErrors((srcIndex->devID == srcIndex->devID || (s->devID < 0 && t->devID < 0)), CheckNTErrors(srcIndex->devID == srcIndex->devID || (s->devID < 0 && t->devID < 0),
"the index must be kept on the same device!"); "the index must be kept on the same device!");
CheckNTErrors((s->devID == srcIndex->devID || (s->devID < 0 && t->devID < 0)), CheckNTErrors(s->devID == srcIndex->devID || (s->devID < 0 && t->devID < 0),
"the data and index must be kept on the same device!"); "the data and index must be kept on the same device!");
CheckNTErrors((dim >= 0 && dim < order), "A too larget dimension specified!"); CheckNTErrors(dim >= 0 && dim < order, "A too larget dimension specified!");
CheckNTErrors((s->unitSize == t->unitSize), "Unmatched tensors!"); CheckNTErrors(s->unitSize == t->unitSize, "Unmatched tensors!");
CheckNTErrors((srcIndex->unitNum == tgtIndex->unitNum), "Unmatched index tensors!"); CheckNTErrors(srcIndex->unitNum == tgtIndex->unitNum, "Unmatched index tensors!");
for (int i = 0; i < order; i++) { for (int i = 0; i < order; i++) {
if (i != dim) { if (i != dim) {
...@@ -193,8 +193,8 @@ make a new tensor to keep the result and return it ...@@ -193,8 +193,8 @@ make a new tensor to keep the result and return it
>> s - the source tensor >> s - the source tensor
>> dim - the leading dimension to define "sub-tensors" >> dim - the leading dimension to define "sub-tensors"
e.g., for a tensor of size (3, 2, 4) and dim = 2, e.g., for a tensor of size (4, 2, 3) and dim = 0,
we have 4 sub-tensors of size (3,2) we have 4 sub-tensors of size (2, 3)
>> srcIndex - index of the source sub-tensors >> srcIndex - index of the source sub-tensors
>> indexSize - length of srcIndex (and tgtIndex) >> indexSize - length of srcIndex (and tgtIndex)
>> tgtIndex - index of the target sub-tensors >> tgtIndex - index of the target sub-tensors
...@@ -249,8 +249,8 @@ make a new tensor to keep the result and return it ...@@ -249,8 +249,8 @@ make a new tensor to keep the result and return it
>> s - the source tensor >> s - the source tensor
>> dim - the leading dimension to define "sub-tensors" >> dim - the leading dimension to define "sub-tensors"
e.g., for a tensor of size (3, 2, 4) and dim = 2, e.g., for a tensor of size (4, 2, 3) and dim = 0,
we have 4 sub-tensors of size (3,2) we have 4 sub-tensors of size (2, 3)
>> srcIndex - index of the source sub-tensors >> srcIndex - index of the source sub-tensors
>> indexSize - length of srcIndex (and tgtIndex) >> indexSize - length of srcIndex (and tgtIndex)
>> tgtIndex - index of the target sub-tensors >> tgtIndex - index of the target sub-tensors
......
...@@ -40,7 +40,8 @@ void _CopyIndexed(const XTensor * s, XTensor * t, int dim, ...@@ -40,7 +40,8 @@ void _CopyIndexed(const XTensor * s, XTensor * t, int dim,
copy selected sub-tensors (return a XTensor structure) copy selected sub-tensors (return a XTensor structure)
make a new tensor to keep the result and return it (remove this???) make a new tensor to keep the result and return it (remove this???)
*/ */
XTensor CopyIndexed(const XTensor &s, int dim, int * srcIndex, int indexSize, int * tgtIndex, int copyNum); //XTensor CopyIndexed(const XTensor &s, int dim, int * srcIndex, int indexSize, int * tgtIndex, int copyNum);
/* /*
copy selected sub-tensors where indeces are kept in tensors (return an XTensor structure) copy selected sub-tensors where indeces are kept in tensors (return an XTensor structure)
make a new tensor to keep the result and return it make a new tensor to keep the result and return it
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论