mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-15 14:17:58 +03:00
85dd2b6c04
* Parser: use C saxpy/sgemm provided by the Ops implementation This is a backport of https://github.com/explosion/spaCy/pull/10747 from the parser refactor branch. It eliminates the explicit calls to BLIS, instead using the saxpy/sgemm provided by the Ops implementation. This allows us to use Accelerate in the parser on M1 Macs (with an updated thinc-apple-ops). Performance of the de_core_news_lg pipe: BLIS 0.7.0, no thinc-apple-ops: 6385 WPS BLIS 0.7.0, thinc-apple-ops: 36455 WPS BLIS 0.9.0, no thinc-apple-ops: 19188 WPS BLIS 0.9.0, thinc-apple-ops: 36682 WPS This PR, thinc-apple-ops: 38726 WPS Performance of the de_core_news_lg pipe (only tok2vec -> parser): BLIS 0.7.0, no thinc-apple-ops: 13907 WPS BLIS 0.7.0, thinc-apple-ops: 73172 WPS BLIS 0.9.0, no thinc-apple-ops: 41576 WPS BLIS 0.9.0, thinc-apple-ops: 72569 WPS This PR, thinc-apple-ops: 87061 WPS * Require thinc >=8.1.0,<8.2.0 * Lower thinc lowerbound to 8.1.0.dev0 * Use best CPU ops for CBLAS when the parser model is on the GPU * Fix another unguarded cblas() call * Fix: use ops as a shorthand for self.model.ops Co-authored-by: Madeesh Kannan <shadeMe@users.noreply.github.com> Co-authored-by: Madeesh Kannan <shadeMe@users.noreply.github.com>
21 lines
715 B
Cython
21 lines
715 B
Cython
from cymem.cymem cimport Pool
|
|
from thinc.backends.cblas cimport CBlas
|
|
|
|
from ..vocab cimport Vocab
|
|
from .trainable_pipe cimport TrainablePipe
|
|
from ._parser_internals.transition_system cimport Transition, TransitionSystem
|
|
from ._parser_internals._state cimport StateC
|
|
from ..ml.parser_model cimport WeightsC, ActivationsC, SizesC
|
|
|
|
|
|
cdef class Parser(TrainablePipe):
|
|
cdef public object _rehearsal_model
|
|
cdef readonly TransitionSystem moves
|
|
cdef public object _multitasks
|
|
|
|
cdef void _parseC(self, CBlas cblas, StateC** states,
|
|
WeightsC weights, SizesC sizes) nogil
|
|
|
|
cdef void c_transition_batch(self, StateC** states, const float* scores,
|
|
int nr_class, int batch_size) nogil
|