Esempio n. 1
0
 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
Esempio n. 2
0
File: link.py Progetto: tkng/chainer
    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, intel64.mdarray):
                    value = numpy.array(value)
                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
Esempio n. 3
0
    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, intel64.mdarray):
                    value = numpy.array(value)
                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
Esempio n. 4
0
File: link.py Progetto: tkng/chainer
 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
Esempio n. 5
0
 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
Esempio n. 6
0
 def to_gpu(self, device=None):
     with cuda._get_device(device):
         super(NegativeSampling, self).to_gpu()
         self.sampler.to_gpu()
Esempio n. 7
0
 def to_gpu(self, device=None):
     with cuda._get_device(device):
         super(BinaryHierarchicalSoftmax, self).to_gpu(device)
         self._func.to_gpu(device)
     return self
Esempio n. 8
0
 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)
     return self
Esempio n. 9
0
File: link.py Progetto: tkng/chainer
 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
Esempio n. 10
0
 def to_gpu(self, device=None):
     with cuda._get_device(device):
         super(BinaryHierarchicalSoftmax, self).to_gpu(device)
         self._func.to_gpu(device)
     return self
Esempio n. 11
0
 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)
     return self
Esempio n. 12
0
 def to_gpu(self, device=None):
     with cuda._get_device(device):
         super(NegativeSampling, self).to_gpu()
         self.sampler.to_gpu()
Esempio n. 13
0
 def to_gpu(self, device=None):
     with cuda._get_device(device):
         super(BlackOut, self).to_gpu()
         self.sampler.to_gpu()
Esempio n. 14
0
 def to_gpu(self, device=None):
     with cuda._get_device(device):
         super(BlackOut, self).to_gpu()
         self.sampler.to_gpu()