Try optimized parser forward loop

This commit is contained in:
Matthew Honnibal 2017-10-18 21:48:00 +02:00
parent 79fcf8576a
commit f018f2030c
3 changed files with 4 additions and 5 deletions

View File

@ -16,7 +16,7 @@ cdef class Parser:
cdef public object _multitasks cdef public object _multitasks
cdef void _parse_step(self, StateC* state, cdef void _parse_step(self, StateC* state,
const float* feat_weights, const float* feat_weights, const float* hW, const float* hb,
int nr_class, int nr_feat, int nr_piece) nogil int nr_class, int nr_hidden, int nr_feat, int nr_piece) nogil
#cdef int parseC(self, TokenC* tokens, int length, int nr_feat) nogil #cdef int parseC(self, TokenC* tokens, int length, int nr_feat) nogil

View File

@ -289,8 +289,6 @@ cdef class Parser:
zero_init(Affine(nr_class, hidden_width, drop_factor=0.0)) zero_init(Affine(nr_class, hidden_width, drop_factor=0.0))
) )
upper.is_noop = False upper.is_noop = False
print(upper._layers)
print(upper._layers[0]._layers)
# TODO: This is an unfortunate hack atm! # TODO: This is an unfortunate hack atm!
# Used to set input dimensions in network. # Used to set input dimensions in network.

View File

@ -148,7 +148,8 @@ cdef class TransitionSystem:
def add_action(self, int action, label_name): def add_action(self, int action, label_name):
cdef attr_t label_id cdef attr_t label_id
if not isinstance(label_name, (int, long)): if not isinstance(label_name, int) and \
not isinstance(label_name, long):
label_id = self.strings.add(label_name) label_id = self.strings.add(label_name)
else: else:
label_id = label_name label_id = label_name