Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]
requires = [
"setuptools",
"cython>=0.25,<3.0",
"cython>=3.1.0,<3.2.0",
"murmurhash>=1.0.2,<1.1.0",
"cymem>=2.0.2,<2.1.0",
"preshed>=3.0.2,<3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pydantic>=1.7.4,!=1.8,!=1.8.1,<3.0.0
numpy>=2.0.0,<3.0.0
packaging>=20.0
# Development dependencies
cython>=0.25.0,<3.0
cython>=3.1.0,<3.2.0
hypothesis>=3.27.0,<6.72.2
pytest>=8.2.0
pytest-cov>=2.7.0,<5.0.0
Expand Down
26 changes: 13 additions & 13 deletions thinc/backends/_accelerate.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@ cdef extern from "Accelerate/Accelerate.h":

# BLAS level 1 routines

void cblas_sswap(int M, float *x, int incX, float *y, int incY) nogil
void cblas_sscal(int N, float alpha, float *x, int incX) nogil
void cblas_scopy(int N, float *x, int incX, float *y, int incY) nogil
void cblas_saxpy(int N, float alpha, float *x, int incX, float *y, int incY ) nogil
float cblas_sdot(int N, float *x, int incX, float *y, int incY ) nogil
float cblas_snrm2(int N, float *x, int incX) nogil
float cblas_sasum(int N, float *x, int incX) nogil
int cblas_isamax(int N, float *x, int incX) nogil
void cblas_sswap(int M, float *x, int incX, float *y, int incY) noexcept nogil
void cblas_sscal(int N, float alpha, float *x, int incX) noexcept nogil
void cblas_scopy(int N, float *x, int incX, float *y, int incY) noexcept nogil
void cblas_saxpy(int N, float alpha, float *x, int incX, float *y, int incY ) noexcept nogil
float cblas_sdot(int N, float *x, int incX, float *y, int incY ) noexcept nogil
float cblas_snrm2(int N, float *x, int incX) noexcept nogil
float cblas_sasum(int N, float *x, int incX) noexcept nogil
int cblas_isamax(int N, float *x, int incX) noexcept nogil

# BLAS level 2 routines
void cblas_sgemv(CBLAS_ORDER Order, CBLAS_TRANSPOSE TransA, int M, int N,
float alpha, float *A, int lda, float *x, int incX,
float beta, float *y, int incY) nogil
float beta, float *y, int incY) noexcept nogil

void cblas_sger(CBLAS_ORDER Order, int M, int N, float alpha, float *x,
int incX, float *y, int incY, float *A, int lda) nogil
int incX, float *y, int incY, float *A, int lda) noexcept nogil

# BLAS level 3 routines
void cblas_sgemm(CBLAS_ORDER Order, CBLAS_TRANSPOSE TransA,
CBLAS_TRANSPOSE TransB, int M, int N, int K,
float alpha, float *A, int lda, float *B, int ldb,
float beta, float *C, int ldc) nogil
float beta, float *C, int ldc) noexcept nogil


cdef void sgemm(bint TransA, bint TransB, int M, int N, int K,
float alpha, const float* A, int lda, const float *B,
int ldb, float beta, float* C, int ldc) nogil
int ldb, float beta, float* C, int ldc) noexcept nogil


cdef void saxpy(int N, float alpha, const float* X, int incX,
float *Y, int incY) nogil
float *Y, int incY) noexcept nogil
6 changes: 3 additions & 3 deletions thinc/backends/_accelerate.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import numpy

cpdef np.ndarray gemm(float[:, ::1] A, float[:, ::1] B,
bint trans1=False, bint trans2=False,
np.ndarray out=None):
np.ndarray out=None) noexcept:
cdef int nM = A.shape[0] if not trans1 else A.shape[1]
cdef int nK = A.shape[1] if not trans1 else A.shape[0]
cdef int nK_b = B.shape[0] if not trans2 else B.shape[1]
Expand Down Expand Up @@ -51,7 +51,7 @@ cpdef np.ndarray gemm(float[:, ::1] A, float[:, ::1] B,

cdef void sgemm(bint TransA, bint TransB, int M, int N, int K,
float alpha, const float* A, int lda, const float *B,
int ldb, float beta, float* C, int ldc) nogil:
int ldb, float beta, float* C, int ldc) noexcept nogil:
cblas_sgemm(
CblasRowMajor,
CblasTrans if TransA else CblasNoTrans,
Expand All @@ -71,5 +71,5 @@ cdef void sgemm(bint TransA, bint TransB, int M, int N, int K,


cdef void saxpy(int N, float alpha, const float* X, int incX,
float *Y, int incY) nogil:
float *Y, int incY) noexcept nogil:
cblas_saxpy(N, alpha, X, incX, Y, incY)
36 changes: 18 additions & 18 deletions thinc/backends/cblas.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ from libcpp.memory cimport shared_ptr

ctypedef void (*sgemm_ptr)(bint transA, bint transB, int M, int N, int K,
float alpha, const float* A, int lda, const float* B,
int ldb, float beta, float* C, int ldc) nogil
int ldb, float beta, float* C, int ldc) noexcept nogil
ctypedef void (*dgemm_ptr)(bint transA, bint transB, int M, int N, int K,
double alpha, const double* A, int lda, const double* B,
int ldb, double beta, double* C, int ldc) nogil
int ldb, double beta, double* C, int ldc) noexcept nogil


ctypedef void (*saxpy_ptr)(int N, float alpha, const float* X, int incX,
float *Y, int incY) nogil
float *Y, int incY) noexcept nogil


ctypedef void (*daxpy_ptr)(int N, double alpha, const double* X, int incX,
double *Y, int incY) nogil
double *Y, int incY) noexcept nogil

ctypedef void (*sscal_ptr)(int N, float alpha, float* X, int incX) nogil
ctypedef void (*dscal_ptr)(int N, double alpha, double* X, int incX) nogil
ctypedef void (*sscal_ptr)(int N, float alpha, float* X, int incX) noexcept nogil
ctypedef void (*dscal_ptr)(int N, double alpha, double* X, int incX) noexcept nogil

# Forward-declaration of the BlasFuncs struct. This struct must be opaque, so
# that consumers of the CBlas class cannot become dependent on its size or
Expand All @@ -34,15 +34,15 @@ cdef class CBlas:
#
# See https://github.com/explosion/thinc/pull/700 for more information.

cdef daxpy_ptr daxpy(CBlas cblas) nogil
cdef saxpy_ptr saxpy(CBlas cblas) nogil
cdef sgemm_ptr sgemm(CBlas cblas) nogil
cdef dgemm_ptr dgemm(CBlas cblas) nogil
cdef sscal_ptr sscal(CBlas cblas) nogil
cdef dscal_ptr dscal(CBlas cblas) nogil
cdef void set_daxpy(CBlas cblas, daxpy_ptr daxpy) nogil
cdef void set_saxpy(CBlas cblas, saxpy_ptr saxpy) nogil
cdef void set_sgemm(CBlas cblas, sgemm_ptr sgemm) nogil
cdef void set_dgemm(CBlas cblas, dgemm_ptr dgemm) nogil
cdef void set_sscal(CBlas cblas, sscal_ptr sscal) nogil
cdef void set_dscal(CBlas cblas, dscal_ptr dscal) nogil
cdef daxpy_ptr daxpy(CBlas cblas) noexcept nogil
cdef saxpy_ptr saxpy(CBlas cblas) noexcept nogil
cdef sgemm_ptr sgemm(CBlas cblas) noexcept nogil
cdef dgemm_ptr dgemm(CBlas cblas) noexcept nogil
cdef sscal_ptr sscal(CBlas cblas) noexcept nogil
cdef dscal_ptr dscal(CBlas cblas) noexcept nogil
cdef void set_daxpy(CBlas cblas, daxpy_ptr daxpy) noexcept nogil
cdef void set_saxpy(CBlas cblas, saxpy_ptr saxpy) noexcept nogil
cdef void set_sgemm(CBlas cblas, sgemm_ptr sgemm) noexcept nogil
cdef void set_dgemm(CBlas cblas, dgemm_ptr dgemm) noexcept nogil
cdef void set_sscal(CBlas cblas, sscal_ptr sscal) noexcept nogil
cdef void set_dscal(CBlas cblas, dscal_ptr dscal) noexcept nogil
28 changes: 14 additions & 14 deletions thinc/backends/cblas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ from libcpp.memory cimport make_shared


# Single- and double-precision wrappers for `blis.cy.scalv`
cdef void blis_sscal(int N, float alpha, float* X, int incX) nogil:
cdef void blis_sscal(int N, float alpha, float* X, int incX) noexcept nogil:
blis.cy.scalv(blis.cy.NO_CONJUGATE, N, alpha, X, incX)

cdef void blis_dscal(int N, double alpha, double* X, int incX) nogil:
cdef void blis_dscal(int N, double alpha, double* X, int incX) noexcept nogil:
blis.cy.scalv(blis.cy.NO_CONJUGATE, N, alpha, X, incX)


Expand Down Expand Up @@ -36,38 +36,38 @@ cdef class CBlas:
funcs.dscal = blis_dscal
self.ptr = make_shared[BlasFuncs](funcs)

cdef daxpy_ptr daxpy(CBlas cblas) nogil:
cdef daxpy_ptr daxpy(CBlas cblas) noexcept nogil:
return deref(cblas.ptr).daxpy

cdef saxpy_ptr saxpy(CBlas cblas) nogil:
cdef saxpy_ptr saxpy(CBlas cblas) noexcept nogil:
return deref(cblas.ptr).saxpy

cdef sgemm_ptr sgemm(CBlas cblas) nogil:
cdef sgemm_ptr sgemm(CBlas cblas) noexcept nogil:
return deref(cblas.ptr).sgemm

cdef dgemm_ptr dgemm(CBlas cblas) nogil:
cdef dgemm_ptr dgemm(CBlas cblas) noexcept nogil:
return deref(cblas.ptr).dgemm

cdef sscal_ptr sscal(CBlas cblas) nogil:
cdef sscal_ptr sscal(CBlas cblas) noexcept nogil:
return deref(cblas.ptr).sscal

cdef dscal_ptr dscal(CBlas cblas) nogil:
cdef dscal_ptr dscal(CBlas cblas) noexcept nogil:
return deref(cblas.ptr).dscal

cdef void set_daxpy(CBlas cblas, daxpy_ptr daxpy) nogil:
cdef void set_daxpy(CBlas cblas, daxpy_ptr daxpy) noexcept nogil:
deref(cblas.ptr).daxpy = daxpy

cdef void set_saxpy(CBlas cblas, saxpy_ptr saxpy) nogil:
cdef void set_saxpy(CBlas cblas, saxpy_ptr saxpy) noexcept nogil:
deref(cblas.ptr).saxpy = saxpy

cdef void set_sgemm(CBlas cblas, sgemm_ptr sgemm) nogil:
cdef void set_sgemm(CBlas cblas, sgemm_ptr sgemm) noexcept nogil:
deref(cblas.ptr).sgemm = sgemm

cdef void set_dgemm(CBlas cblas, dgemm_ptr dgemm) nogil:
cdef void set_dgemm(CBlas cblas, dgemm_ptr dgemm) noexcept nogil:
deref(cblas.ptr).dgemm = dgemm

cdef void set_sscal(CBlas cblas, sscal_ptr sscal) nogil:
cdef void set_sscal(CBlas cblas, sscal_ptr sscal) noexcept nogil:
deref(cblas.ptr).sscal = sscal

cdef void set_dscal(CBlas cblas, dscal_ptr dscal) nogil:
cdef void set_dscal(CBlas cblas, dscal_ptr dscal) noexcept nogil:
deref(cblas.ptr).dscal = dscal