This repository has been archived by the owner on Mar 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove unecessary deep copy * Add lru_cache on get_word_info * Add lru_cache to get_word_info This seems to be a small speedup. * Basic Cythonization Unlike the other branch the tests pass on this one. Benchmark time went down by a third compared to the previous commit. I'm not sure the _c functions are necessary here - I think that's what cpdef functions are for, but I had difficulty getting them working. Will need to give that another look. * Use cpdef functions Didn't have any issues this time, and it's cleaner with no clear performance difference. * Move build_lattice to Cython, intern some slow parts This should cut execution time by roughly 25% compared to the last commit. * Don't use deepcopy This is not an appropriate use of deepcopy and it's slow. * Add cython to setup_requires * Fix setup.py * Make INHIBITED_CONNECTION literal Minor speed boost. * Bring the matrix into the lattice building This provides a notable speedup. * Various cythonizations Improvements are relatively minor compared to previous commit, but there is a few seconds of speedup. * Inline function for small speed boost * Change import order, make lru cache size explicit Maybe this will make Travis happy? * Add a build command * Use INT_MAX * Remove comment Missed this before, this is fine.
- Loading branch information
Showing
14 changed files
with
148 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from .latticenode cimport LatticeNode | ||
|
||
cdef extern from "limits.h": | ||
cdef int INT_MAX | ||
|
||
cdef class Lattice: | ||
|
||
cdef int size | ||
cdef int capacity | ||
cdef LatticeNode eos_node | ||
|
||
cdef list end_lists | ||
cdef object grammar | ||
cdef object eos_params | ||
cdef const short[:,:] connect_costs | ||
|
||
cpdef void resize(self, int size) | ||
cpdef void insert(self, int begin, int end, LatticeNode node) | ||
cdef void connect_node(self, LatticeNode r_node) | ||
cdef void connect_eos_node(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cdef class LatticeNode: | ||
|
||
cdef int begin | ||
cdef int end | ||
cdef int total_cost | ||
cdef int word_id | ||
cdef bint _is_oov | ||
cdef LatticeNode best_previous_node | ||
cdef bint is_connected_to_bos | ||
cdef object extra_word_info | ||
cdef object undefined_word_info | ||
cdef bint is_defined | ||
cdef object lexicon | ||
cdef int left_id | ||
cdef int right_id | ||
cdef int cost | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.