singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [singa] chrishkchris edited a comment on issue #555: SINGA-490 Optimization on GPU Malloc and Cudastream
Date Thu, 07 Nov 2019 04:45:04 GMT
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

Mime
View raw message