Commit 8f2d16f5 by xiaotong

rewrite reducesumall

parent 9b0d4df8
...@@ -46,6 +46,22 @@ sum all the items of the tensor (It should be optimized!) ...@@ -46,6 +46,22 @@ sum all the items of the tensor (It should be optimized!)
*/ */
DTYPE _ReduceSumAll(const XTensor * source) DTYPE _ReduceSumAll(const XTensor * source)
{ {
int dims[2] = {1, source->unitNum};
int one = 1;
XTensor * all = NewTensorBuf(2, dims, source->dataType, source->denseRatio, source->devID, source->mem);
XTensor * result = NewTensorBuf(1, &one, source->dataType, 1.0F, source->devID, source->mem);
_CopyValues(source, all);
_ReduceSum(all, result, 1);
DTYPE r = result->Get1D(0);
DelTensorBuf(result);
DelTensorBuf(all);
return r;
int order = source->order; int order = source->order;
DTYPE summation; DTYPE summation;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论