def to_gpu(self, device=None): """Copies parameter variables and persistent values to GPU. This method does not handle non-registered attributes. If some of such attributes must be copied to GPU, the link implementation must override this method to do so. Args: device: Target device specifier. If omitted, the current device is used. Returns: self """ cuda.check_cuda_available() if not self._cpu: return self d = self.__dict__ with cuda._get_device(device): for name in self._params: d[name].to_gpu() for name in self._persistent: value = d[name] if isinstance(value, numpy.ndarray): d[name] = cuda.to_gpu(value) self._device_id = cuda.cupy.cuda.get_device_id() self._cpu = False return self
def to_gpu(self, device=None): with cuda._get_device(device): super(Chain, self).to_gpu() d = self.__dict__ for name in self._children: d[name].to_gpu() return self
def to_gpu(self, device=None): """Copies parameter variables and persistent values to GPU. This method does not handle non-registered attributes. If some of such attributes must be copied to GPU, the link implementation must override this method to do so. Args: device: Target device specifier. If omitted, the current device is used. Returns: self """ cuda.check_cuda_available() if not self._cpu: return self d = self.__dict__ with cuda._get_device(device): for name in self._params: d[name].to_gpu() for name in self._persistent: value = d[name] if isinstance(value, numpy.ndarray): d[name] = cuda.to_gpu(value) self._device_id = cuda.cupy.cuda.get_device_id() self._cpu = False return self
def to_gpu(self, device=None): with cuda._get_device(device): super(Chain, self).to_gpu() d = self.__dict__ for name in self._children: d[name].to_gpu() return self
def to_gpu(self, device=None): with cuda._get_device(device): super(ChainList, self).to_gpu() for link in self._children: link.to_gpu() return self
def to_gpu(self, device=None): with cuda._get_device(device): super(BlackOut, self).to_gpu() self.sampler.to_gpu() self.log_q = cuda.to_gpu(self.log_q)
def to_gpu(self, device=None): with cuda._get_device(device): super(ChainList, self).to_gpu() for link in self._children: link.to_gpu() return self
def to_gpu(self, device=None): with cuda._get_device(device): self.paths = cuda.to_gpu(self.paths) self.codes = cuda.to_gpu(self.codes) self.begins = cuda.to_gpu(self.begins)
def to_gpu(self, device=None): with cuda._get_device(device): super(BinaryHierarchicalSoftmax, self).to_gpu(device) self._func.to_gpu(device)
def to_gpu(self, device=None): with cuda._get_device(device): super(BlackOut, self).to_gpu() self.sampler.to_gpu()
def to_gpu(self, device=None): with cuda._get_device(device): super(BinaryHierarchicalSoftmax, self).to_gpu(device) self._func.to_gpu(device)
def to_gpu(self, device=None): with cuda._get_device(device): self.paths = cuda.to_gpu(self.paths) self.codes = cuda.to_gpu(self.codes) self.begins = cuda.to_gpu(self.begins)
def to_gpu(self, device=None): with cuda._get_device(device): super(NegativeSampling, self).to_gpu() self.sampler.to_gpu()
def to_gpu(self, device=None): with cuda._get_device(device): super(NegativeSampling, self).to_gpu() self.sampler.to_gpu()