@@ -368,8 +368,6 @@ cdef class DenseDenseMiddleTermComputer{{name_suffix}}(MiddleTermComputer{{name_
368
368
ITYPE_t thread_num,
369
369
) nogil:
370
370
cdef:
371
- const {{INPUT_DTYPE_t}}[:, ::1] X_c = self.X[X_start:X_end, :]
372
- const {{INPUT_DTYPE_t}}[:, ::1] Y_c = self.Y[Y_start:Y_end, :]
373
371
DTYPE_t *dist_middle_terms = self.dist_middle_terms_chunks[thread_num].data()
374
372
375
373
# Careful: LDA, LDB and LDC are given for F-ordered arrays
@@ -380,9 +378,9 @@ cdef class DenseDenseMiddleTermComputer{{name_suffix}}(MiddleTermComputer{{name_
380
378
BLAS_Order order = RowMajor
381
379
BLAS_Trans ta = NoTrans
382
380
BLAS_Trans tb = Trans
383
- ITYPE_t m = X_c.shape[0]
384
- ITYPE_t n = Y_c.shape[0]
385
- ITYPE_t K = X_c.shape[1]
381
+ ITYPE_t m = X_end - X_start
382
+ ITYPE_t n = Y_end - Y_start
383
+ ITYPE_t K = self.n_features
386
384
DTYPE_t alpha = - 2.
387
385
{{if upcast_to_float64}}
388
386
DTYPE_t * A = self.X_c_upcast[thread_num].data()
@@ -391,15 +389,15 @@ cdef class DenseDenseMiddleTermComputer{{name_suffix}}(MiddleTermComputer{{name_
391
389
# Casting for A and B to remove the const is needed because APIs exposed via
392
390
# scipy.linalg.cython_blas aren't reflecting the arguments' const qualifier.
393
391
# See: https://github.com/scipy/scipy/issues/14262
394
- DTYPE_t * A = <DTYPE_t *> &X_c[0 , 0]
395
- DTYPE_t * B = <DTYPE_t *> &Y_c[0 , 0]
392
+ DTYPE_t * A = <DTYPE_t *> &self.X[X_start , 0]
393
+ DTYPE_t * B = <DTYPE_t *> &self.Y[Y_start , 0]
396
394
{{endif}}
397
- ITYPE_t lda = X_c.shape[1]
398
- ITYPE_t ldb = X_c.shape[1]
395
+ ITYPE_t lda = self.n_features
396
+ ITYPE_t ldb = self.n_features
399
397
DTYPE_t beta = 0.
400
- ITYPE_t ldc = Y_c.shape[0]
398
+ ITYPE_t ldc = Y_end - Y_start
401
399
402
- # dist_middle_terms = `-2 * X_c @ Y_c .T`
400
+ # dist_middle_terms = `-2 * X[X_start:X_end] @ Y[Y_start:Y_end] .T`
403
401
_gemm(order, ta, tb, m, n, K, alpha, A, lda, B, ldb, beta, dist_middle_terms, ldc)
404
402
405
403
return dist_middle_terms
0 commit comments