提交 4a99c441 编写于 作者: Y Yu Yang 提交者: GitHub

Merge pull request #1765 from reyoung/feature/speed_up_int_converter

Speed up int scanner of data converter.
...@@ -160,10 +160,19 @@ class SparseFloatScanner(SparseBinaryScanner): ...@@ -160,10 +160,19 @@ class SparseFloatScanner(SparseBinaryScanner):
class IndexScanner(IScanner): class IndexScanner(IScanner):
def __init__(self, input_type, pos): def __init__(self, input_type, pos):
IScanner.__init__(self, input_type, pos) IScanner.__init__(self, input_type, pos)
self.__ids__ = [] self.__ids__ = None
self.__idx__ = 0
def pre_scan(self, dat):
self.__idx__ += 1
def finish_pre_scan(self, argument):
self.__ids__ = [0] * self.__idx__
self.__idx__ = 0
def scan(self, dat): def scan(self, dat):
self.__ids__.append(dat) self.__ids__[self.__idx__] = dat
self.__idx__ += 1
def finish_scan(self, argument): def finish_scan(self, argument):
ids = swig_paddle.IVector.create(self.__ids__, self.data_in_gpu) ids = swig_paddle.IVector.create(self.__ids__, self.data_in_gpu)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册