chrishkchris opened a new pull request #577: SINGA-502 Avoid moving data 
between host and gpu in SoftmaxCrossEntropy
URL: https://github.com/apache/singa/pull/577
 
 
   The softmax_cross_entropy move to data to host and then back to gpu, so the 
whole function needed to be changed for many reasons such as efficiency and 
asynchronization (and buffering operation in the future). :
   
   class SoftMaxCrossEntropy(Operation): 
   
   def _init_(self, t): 
     super(SoftMaxCrossEntropy, self)._init_() 
     self.t = t.data
   
   def forward(self, x): 
     self.p = singa.SoftMax 
     loss = CTensor((1,), self.p.device()) 
     ret = singa.CrossEntropyFwd(self.p, self.t) 
     loss.SetFloatValue(singa.SumAsFloat(ret) / x.shape()[0]) 
     return loss
   
   Here the SumAsFloat return a c++ float value, and this value is read back to 
gpu in the SetFloatValue function.
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to