singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [singa] chrishkchris opened a new pull request #577: SINGA-502 Avoid moving data between host and gpu in SoftmaxCrossEntropy
Date Tue, 21 Jan 2020 08:45:25 GMT
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message