當前位置: 首頁>>代碼示例>>Python>>正文


Python _py.CU類代碼示例

本文整理匯總了Python中cuda4py._py.CU的典型用法代碼示例。如果您正苦於以下問題:Python CU類的具體用法?Python CU怎麽用?Python CU使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CU類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: dgemm

    def dgemm(self, transA, transB,
              rowsCountA, columnCountB, commonSideLength,
              alpha, A, B, beta, C,
              strideA=0, strideB=0, strideC=0):
        """Double precision (double) GEneral Matrix Multiplication.

        Matrices are always in column order.

        C = alpha * dot(A, B) + beta * C
        C = alpha * dot(A^T, B) + beta * C
        C = alpha * dot(A, B^T) + beta * C
        C = alpha * dot(A^T, B^T) + beta * C

        alpha, A, B, beta, C can be numpy array, Memory object,
        cffi pointer or int.

        Parameters:
            transA: how matrix A is to be transposed
                    (CUBLAS_OP_N, CUBLAS_OP_T, CUBLAS_OP_C).
            transB: how matrix B is to be transposed
                    (CUBLAS_OP_N, CUBLAS_OP_T, CUBLAS_OP_C).
            rowsCountA: number of rows in matrix A.
            columnCountB: number of columns in matrix B.
            commonSideLength: length of the common side of the matrices.
            alpha: the factor of matrix A.
            A: matrix A.
            B: matrix B.
            beta: the factor of matrix C.
            C: Buffer object storing matrix C.
            strideA: leading dimension of matrix A:
                     clblasTrans: >= commonSideLength,
                     else: >= rowsCountA.
            strideB: leading dimension of matrix B:
                     clblasTrans: >= columnCountB,
                     else: >= commonSideLength.
            strideC: leading dimension of matrix C: >= rowsCountA.

        Returns:
            None.
        """
        if not strideA:
            strideA = commonSideLength if transA != CUBLAS_OP_N else rowsCountA
        if not strideB:
            strideB = (columnCountB if transB != CUBLAS_OP_N
                       else commonSideLength)
        if not strideC:
            strideC = rowsCountA
        err = self._lib.cublasDgemm_v2(
            self.handle, transA, transB, rowsCountA, columnCountB,
            commonSideLength, CU.extract_ptr(alpha), A, strideA,
            B, strideB, CU.extract_ptr(beta), C, strideC)
        if err:
            raise CU.error("cublasDgemm_v2", err)
開發者ID:Samsung,項目名稱:cuda4py,代碼行數:53,代碼來源:_cublas.py

示例2: pooling_forward

    def pooling_forward(self, pooling_desc, alpha, src_desc, src_data,
                        beta, dest_desc, dest_data):
        """Does pooling forward propagation.

        Parameters:
            alpha: src_data multiplier (numpy array with one element).
            beta: dest_data multiplier (numpy array with one element).
        """
        err = self._lib.cudnnPoolingForward(
            self.handle, pooling_desc, CU.extract_ptr(alpha),
            src_desc, src_data,
            CU.extract_ptr(beta), dest_desc, dest_data)
        if err:
            raise CU.error("cudnnPoolingForward", err)
開發者ID:nagyistge,項目名稱:cuda4py,代碼行數:14,代碼來源:_cudnn.py

示例3: transform_tensor

    def transform_tensor(self, alpha, src_desc, src_data,
                         beta, dest_desc, dest_data):
        """Transforms data from one layout to another
        (interleaved to splitted for example).

        Parameters:
            alpha: src_data multiplier (numpy array with one element).
            beta: dest_data multiplier (numpy array with one element).
        """
        err = self._lib.cudnnTransformTensor(
            self.handle, CU.extract_ptr(alpha), src_desc, src_data,
            CU.extract_ptr(beta), dest_desc, dest_data)
        if err:
            raise CU.error("cudnnTransformTensor", err)
開發者ID:nagyistge,項目名稱:cuda4py,代碼行數:14,代碼來源:_cudnn.py

示例4: convolution_backward_bias

    def convolution_backward_bias(self, alpha, src_desc, src_data,
                                  beta, dest_desc, dest_data):
        """Computes gradient for the bias.

        Parameters:
            alpha: src_data multiplier (numpy array with one element).
            beta: dest_data multiplier (numpy array with one element).
            src_data: error for backpropagation.
            dest_data: gradient for the bias.
        """
        err = self._lib.cudnnConvolutionBackwardBias(
            self.handle, CU.extract_ptr(alpha), src_desc, src_data,
            CU.extract_ptr(beta), dest_desc, dest_data)
        if err:
            raise CU.error("cudnnConvolutionBackwardBias", err)
開發者ID:nagyistge,項目名稱:cuda4py,代碼行數:15,代碼來源:_cudnn.py

示例5: exec_z2z

 def exec_z2z(self, idata, odata, direction):
     """Executes a double-precision complex-to-complex
     cuFFT transform plan.
     """
     err = self._lib.cufftExecZ2Z(self.handle, idata, odata, direction)
     if err:
         raise CU.error("cufftExecZ2Z", err)
開發者ID:nagyistge,項目名稱:cuda4py,代碼行數:7,代碼來源:_cufft.py

示例6: __init__

    def __init__(self, context, rng_type=CURAND_RNG_PSEUDO_DEFAULT):
        """Constructor.

        Parameters:
            context: CUDA context handle or None to use the host generator.
            rng_type: type of the random generator.
        """
        self._context = context
        self._lib = None
        if context is not None:
            context._add_ref(self)
        initialize()
        handle = ffi.new("curandGenerator_t *")
        if context is not None:
            with context:
                err = lib.curandCreateGenerator(handle, int(rng_type))
        else:
            err = lib.curandCreateGeneratorHost(handle, int(rng_type))
        if err:
            self._handle = None
            raise CU.error("curandCreateGenerator" if context is not None
                           else "curandCreateGeneratorHost", err)
        self._lib = lib  # to hold the reference
        self._handle = int(handle[0])
        self._rng_type = int(rng_type)
        self._seed = 0
        self._offset = 0
        self._ordering = 0
        self._dimensions = 0
開發者ID:Samsung,項目名稱:cuda4py,代碼行數:29,代碼來源:_curand.py

示例7: workarea

 def workarea(self, value):
     """Sets workarea for plan execution.
     """
     err = self._lib.cufftSetWorkArea(self.handle, value)
     if err:
         raise CU.error("cufftSetWorkArea", err)
     self._workarea = value
開發者ID:nagyistge,項目名稱:cuda4py,代碼行數:7,代碼來源:_cufft.py

示例8: exec_d2z

 def exec_d2z(self, idata, odata):
     """Executes a double-precision real-to-complex,
     implicitly forward, cuFFT transform plan.
     """
     err = self._lib.cufftExecD2Z(self.handle, idata, odata)
     if err:
         raise CU.error("cufftExecD2Z", err)
開發者ID:nagyistge,項目名稱:cuda4py,代碼行數:7,代碼來源:_cufft.py

示例9: exec_z2d

 def exec_z2d(self, idata, odata):
     """Executes a double-precision complex-to-real,
     implicitly inverse, cuFFT transform plan.
     """
     err = self._lib.cufftExecZ2D(self.handle, idata, odata)
     if err:
         raise CU.error("cufftExecZ2D", err)
開發者ID:nagyistge,項目名稱:cuda4py,代碼行數:7,代碼來源:_cufft.py

示例10: exec_c2c

 def exec_c2c(self, idata, odata, direction):
     """Executes a single-precision complex-to-complex
     cuFFT transform plan.
     """
     err = self._lib.cufftExecC2C(self.handle, idata, odata, direction)
     if err:
         raise CU.error("cufftExecC2C", err)
開發者ID:nagyistge,項目名稱:cuda4py,代碼行數:7,代碼來源:_cufft.py

示例11: version

 def version(self):
     """Returns cuFFT version.
     """
     version = ffi.new("int *")
     err = self._lib.cufftGetVersion(version)
     if err:
         raise CU.error("cufftGetVersion", err)
     return int(version[0])
開發者ID:nagyistge,項目名稱:cuda4py,代碼行數:8,代碼來源:_cufft.py

示例12: ordering

 def ordering(self, value):
     """Sets generator ordering.
     """
     err = self._lib.curandSetGeneratorOrdering(
         self.handle, int(value))
     if err:
         raise CU.error("curandSetGeneratorOrdering", err)
     self._ordering = int(value)
開發者ID:Samsung,項目名稱:cuda4py,代碼行數:8,代碼來源:_curand.py

示例13: dimensions

 def dimensions(self, value):
     """Sets quasirandom generator dimensions.
     """
     err = self._lib.curandSetQuasiRandomGeneratorDimensions(
         self.handle, int(value))
     if err:
         raise CU.error("curandSetQuasiRandomGeneratorDimensions", err)
     self._dimensions = int(value)
開發者ID:Samsung,項目名稱:cuda4py,代碼行數:8,代碼來源:_curand.py

示例14: seed

 def seed(self, value):
     """Sets generator seed as an 64-bit integer.
     """
     err = self._lib.curandSetPseudoRandomGeneratorSeed(
         self.handle, int(value))
     if err:
         raise CU.error("curandSetPseudoRandomGeneratorSeed", err)
     self._seed = int(value)
開發者ID:Samsung,項目名稱:cuda4py,代碼行數:8,代碼來源:_curand.py

示例15: size

 def size(self):
     """Returns actual size of the work area required to support the plan.
     """
     sz = ffi.new("size_t[]", 4)
     err = self._lib.cufftGetSize(self.handle, sz)
     if err:
         raise CU.error("cufftGetSize", err)
     return int(sz[0])
開發者ID:nagyistge,項目名稱:cuda4py,代碼行數:8,代碼來源:_cufft.py


注:本文中的cuda4py._py.CU類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。