mirror of
https://github.com/wassname/ray.git
synced 2026-08-11 11:24:51 +08:00
Lint Cython files (#4097)
This commit is contained in:
committed by
Robert Nishihara
parent
acf4d53b55
commit
bcd5af78c7
@@ -20,6 +20,7 @@
|
||||
|
||||
cimport scipy.linalg.cython_blas as blas
|
||||
|
||||
|
||||
def compute_self_corr_for_voxel_sel(py_trans_a, py_trans_b, py_m, py_n, py_k,
|
||||
py_alpha, py_a, py_lda, int py_start_voxel,
|
||||
py_b, py_ldb, py_beta, py_c, py_ldc,
|
||||
@@ -116,7 +117,9 @@ def compute_self_corr_for_voxel_sel(py_trans_a, py_trans_b, py_m, py_n, py_k,
|
||||
cdef float[:, :, ::1] C
|
||||
C = py_c
|
||||
blas.sgemm(trans_a, trans_b, &M, &N, &K, &alpha, &A[0, 0], &lda,
|
||||
&B[0, py_start_voxel], &ldb, &beta, &C[0, py_start_epoch, 0], &ldc)
|
||||
&B[0, py_start_voxel], &ldb, &beta,
|
||||
&C[0, py_start_epoch, 0], &ldc)
|
||||
|
||||
|
||||
def compute_kernel_matrix(py_uplo, py_trans, py_n, py_k, py_alpha, py_a,
|
||||
int py_start_voxel, py_lda,
|
||||
@@ -209,6 +212,7 @@ def compute_kernel_matrix(py_uplo, py_trans, py_n, py_k, py_alpha, py_a,
|
||||
for k in range(j):
|
||||
py_c[k, j] = py_c[j, k]
|
||||
|
||||
|
||||
def compute_single_self_corr_syrk(py_uplo, py_trans, py_n, py_k,
|
||||
py_alpha, py_a, py_lda,
|
||||
py_beta, py_c, py_ldc,
|
||||
@@ -298,6 +302,7 @@ def compute_single_self_corr_syrk(py_uplo, py_trans, py_n, py_k,
|
||||
for k in range(j):
|
||||
py_c[py_start_sample, k, j] = py_c[py_start_sample, j, k]
|
||||
|
||||
|
||||
def compute_single_self_corr_gemm(py_trans_a, py_trans_b, py_m, py_n,
|
||||
py_k, py_alpha, py_a, py_lda,
|
||||
py_ldb, py_beta, py_c, py_ldc,
|
||||
@@ -388,6 +393,7 @@ def compute_single_self_corr_gemm(py_trans_a, py_trans_b, py_m, py_n,
|
||||
blas.sgemm(trans_a, trans_b, &M, &N, &K, &alpha, &A[0, 0], &lda,
|
||||
&A[0, 0], &ldb, &beta, &C[py_start_sample, 0, 0], &ldc)
|
||||
|
||||
|
||||
def compute_corr_vectors(py_trans_a, py_trans_b, py_m, py_n,
|
||||
py_k, py_alpha, py_a, py_lda,
|
||||
py_b, py_ldb, py_beta, py_c, py_ldc,
|
||||
@@ -478,7 +484,9 @@ def compute_corr_vectors(py_trans_a, py_trans_b, py_m, py_n,
|
||||
cdef float[:, :, ::1] C
|
||||
C = py_c
|
||||
blas.sgemm(trans_a, trans_b, &M, &N, &K, &alpha, &A[0, 0], &lda,
|
||||
&B[0, py_start_voxel], &ldb, &beta, &C[py_start_sample, 0, 0], &ldc)
|
||||
&B[0, py_start_voxel], &ldb, &beta,
|
||||
&C[py_start_sample, 0, 0], &ldc)
|
||||
|
||||
|
||||
def compute_single_matrix_multiplication(py_trans_a, py_trans_b, py_m, py_n,
|
||||
py_k, py_alpha, py_a, py_lda,
|
||||
|
||||
@@ -1,36 +1,43 @@
|
||||
#!python
|
||||
# cython: embedsignature=True, binding=True
|
||||
|
||||
|
||||
def simple_func(x, y, z):
|
||||
return x + y + z
|
||||
|
||||
|
||||
# Cython code directly callable from Python
|
||||
def fib(n):
|
||||
if n < 2:
|
||||
return n
|
||||
return fib(n-2) + fib(n-1)
|
||||
|
||||
|
||||
# Typed Cython code
|
||||
def fib_int(int n):
|
||||
if n < 2:
|
||||
return n
|
||||
return fib_int(n-2) + fib_int(n-1)
|
||||
|
||||
|
||||
# Cython-Python code
|
||||
cpdef fib_cpdef(int n):
|
||||
if n < 2:
|
||||
return n
|
||||
return fib_cpdef(n-2) + fib_cpdef(n-1)
|
||||
|
||||
|
||||
# C code
|
||||
def fib_cdef(int n):
|
||||
return fib_in_c(n)
|
||||
|
||||
|
||||
cdef int fib_in_c(int n):
|
||||
if n < 2:
|
||||
return n
|
||||
return fib_in_c(n-2) + fib_in_c(n-1)
|
||||
|
||||
|
||||
# Simple class
|
||||
class simple_class(object):
|
||||
def __init__(self):
|
||||
@@ -39,5 +46,3 @@ class simple_class(object):
|
||||
def increment(self):
|
||||
self.value += 1
|
||||
return self.value
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user