提交 f9ea6e0c authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Consider numpy.memmap a valid type for TensorType

上级 6e9e6d6b
...@@ -611,6 +611,13 @@ class TensorType(Type): ...@@ -611,6 +611,13 @@ class TensorType(Type):
if data.dtype.num != self.numpy_dtype.num: if data.dtype.num != self.numpy_dtype.num:
data = theano._asarray(data, dtype=self.dtype) data = theano._asarray(data, dtype=self.dtype)
# -- now fall through to ndim check # -- now fall through to ndim check
elif((type(data) is numpy.memmap)
and (data.dtype == self.numpy_dtype)):
# numpy.memmap is a "safe" subclass of ndarray,
# so we can use it whereever we expect a base ndarray.
# however, casting it would defeat the purpose of not
# loading the whole data into memory
pass
elif strict: elif strict:
# If any of the two conditions above was not met, # If any of the two conditions above was not met,
# we raise a meaningful TypeError. # we raise a meaningful TypeError.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论