singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-singa] chrishkchris commented on a change in pull request #535: SINGA-490 Optimize performance of stochastic gradient descent (SGD)
Date Thu, 19 Sep 2019 06:46:51 GMT
chrishkchris commented on a change in pull request #535: SINGA-490 Optimize performance of
stochastic gradient descent (SGD)
URL: https://github.com/apache/incubator-singa/pull/535#discussion_r326004398
 
 

 ##########
 File path: src/core/tensor/tensor_math_cuda.h
 ##########
 @@ -324,12 +324,8 @@ void EltwiseMult<float, lang::Cuda>(const Tensor& in,
                                     const float x, Tensor* out, Context* ctx) {
   const float* inPtr = static_cast<const float*>(in.block()->data());
   float* outPtr = static_cast<float*>(out->block()->mutable_data());
-
-  float alpha = x, beta = 0.0;
-  check_cudnn(cudnnAddTensor(ctx->cudnn_handle,
-                             (void*)(&alpha), generate_tensor_nd_desc(in), inPtr,
-                             (void*)(&beta), generate_tensor_nd_desc(*out), outPtr
-                            ));
+  const size_t num = in.Size();
 
 Review comment:
   Yes, must be. It is because cudnnAddTensor add two tensors alphaX+betaY and write the result
to Y. Meanwhile, cuda::mult is for purely elementwise multiply. The computational cost of
cudnnAddTensor is hence much higher than cuda::mult (when the two inputs are tensor and scalar,
respectively). We do not need to use a tensor add function to perform scalar multiply purpose
for the consideration of computation cost. Our function is just to multiply a tensor with
a scalar.
   

----------------------------------------------------------------
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