From 25280b7013a041a003f7eefe9c51a3f216d7c33d Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 27 Mar 2018 10:08:38 +0000 Subject: [PATCH] Try to make sum_state_features faster --- spacy/syntax/nn_parser.pyx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spacy/syntax/nn_parser.pyx b/spacy/syntax/nn_parser.pyx index d772be40b..8fd870939 100644 --- a/spacy/syntax/nn_parser.pyx +++ b/spacy/syntax/nn_parser.pyx @@ -165,16 +165,17 @@ cdef void sum_state_features(float* output, cdef const float* feature padding = cached cached += F * O + cdef int id_stride = F*O + cdef float one = 1. for b in range(B): for f in range(F): if token_ids[f] < 0: feature = &padding[f*O] else: - idx = token_ids[f] * F * O + f*O + idx = token_ids[f] * id_stride + f*O feature = &cached[idx] - VecVec.add_i(output, - feature, 1., O) - output += O + openblas.simple_axpy(&output[b*O], O, + feature, one) token_ids += F