You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@singa.apache.org by GitBox <gi...@apache.org> on 2019/11/07 04:45:04 UTC

[GitHub] [singa] chrishkchris edited a comment on issue #555: SINGA-490 Optimization on GPU Malloc and Cudastream

chrishkchris edited a comment on issue #555: SINGA-490 Optimization on GPU Malloc and Cudastream
URL: https://github.com/apache/singa/pull/555#issuecomment-550738649
 
 
   I checked the source code of unit test which covers the value check for functions like sumrow and sumcolumn, so the value should be no problem:
   
   ```cpp
   TEST_F(TensorMath, SumRowsCuda) {
     auto dev = std::make_shared<singa::CudaGPU>();
     Tensor t(Shape{2}, dev);
     d.CopyDataFromHostPtr(dat1, 6);
     d.ToDevice(dev);
     SumRows(d, &t);
     t.ToHost();
     const float *tptr = t.data<float>();
     for (int i = 0; i < 2; i++) {
       float tmp = 0;
       for (int j = 0; j < 3; j++) {
         tmp += dat1[j * 2 + i];
       }
       EXPECT_FLOAT_EQ(tptr[i], tmp);
     }
     d.ToHost();
   }
   TEST_F(TensorMath, SumColumnCuda) {
     auto dev = std::make_shared<singa::CudaGPU>();
     Tensor t(Shape{3}, dev);
     d.CopyDataFromHostPtr(dat1, 6);
     d.ToDevice(dev);
     SumColumns(d, &t);
     t.ToHost();
     const float *tptr = t.data<float>();
     for (int i = 0; i < 3; i++) {
       float tmp = 0;
       for (int j = 0; j < 2; j++) {
         tmp += dat1[i * 2 + j];
       }
       EXPECT_FLOAT_EQ(tptr[i], tmp);
     }
     d.ToHost();
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services