Пример #1
0
    def __pow__(self, other):
        """pow function::
 
           example:
                   array = pow(array)
                   array = pow(array,4)
                   array = pow(array,array)

        """

        if isinstance(other, GPUArray):
            assert self.shape == other.shape

            result = self._new_like_me(_get_common_dtype(self, other))

            func = elementwise.get_pow_array_kernel(
                    self.dtype, other.dtype, result.dtype)

            func.set_block_shape(*self._block)
            func.prepared_async_call(self._grid, None,
                    self.gpudata, other.gpudata, result.gpudata,
                    self.mem_size)
            
            return result
        else:
            result = self._new_like_me()
            func = elementwise.get_pow_kernel(self.dtype)
            func.set_block_shape(*self._block)
            func.prepared_async_call(self._grid, None,
                    other, self.gpudata, result.gpudata,
                    self.mem_size)

            return result
Пример #2
0
    def __pow__(self, other):
        """pow function::

           example:
                   array = pow(array)
                   array = pow(array,4)
                   array = pow(array,array)

        """

        if isinstance(other, GPUArray):
            if not self.flags.forc or not other.flags.forc:
                raise RuntimeError("only contiguous arrays may " "be used as arguments to this operation")

            assert self.shape == other.shape

            result = self._new_like_me(_get_common_dtype(self, other))

            func = elementwise.get_pow_array_kernel(self.dtype, other.dtype, result.dtype)

            func.prepared_async_call(
                self._grid, self._block, None, self.gpudata, other.gpudata, result.gpudata, self.mem_size
            )

            return result
        else:
            if not self.flags.forc:
                raise RuntimeError("only contiguous arrays may " "be used as arguments to this operation")

            result = self._new_like_me()
            func = elementwise.get_pow_kernel(self.dtype)
            func.prepared_async_call(self._grid, self._block, None, other, self.gpudata, result.gpudata, self.mem_size)

            return result
Пример #3
0
    def __pow__(self, other):
        """pow function::

           example:
                   array = pow(array)
                   array = pow(array,4)
                   array = pow(array,array)

        """

        if isinstance(other, GPUArray):
            if not self.flags.forc or not other.flags.forc:
                raise RuntimeError("only contiguous arrays may "
                        "be used as arguments to this operation")

            assert self.shape == other.shape

            result = self._new_like_me(_get_common_dtype(self, other))

            func = elementwise.get_pow_array_kernel(
                    self.dtype, other.dtype, result.dtype)

            func.prepared_async_call(self._grid, self._block, None,
                    self.gpudata, other.gpudata, result.gpudata,
                    self.mem_size)

            return result
        else:
            if not self.flags.forc:
                raise RuntimeError("only contiguous arrays may "
                        "be used as arguments to this operation")

            result = self._new_like_me()
            func = elementwise.get_pow_kernel(self.dtype)
            func.prepared_async_call(self._grid, self._block, None,
                    other, self.gpudata, result.gpudata,
                    self.mem_size)

            return result
Пример #4
0
 def _inplace_pow(x_gpu, p, stream):
     func = elementwise.get_pow_kernel(x_gpu.dtype)
     func.prepared_async_call(x_gpu._grid, x_gpu._block, stream,
                 p, x_gpu.gpudata, x_gpu.gpudata, x_gpu.mem_size)
Пример #5
0
 def _inplace_pow(x_gpu, p, stream):
     func = elementwise.get_pow_kernel(x_gpu.dtype)
     func.prepared_async_call(x_gpu._grid, x_gpu._block, stream, p,
                              x_gpu.gpudata, x_gpu.gpudata, x_gpu.mem_size)