提交 b1fd4b7e authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #1619 from nouiz/memmap

Make tensor.{constant,as_tensor_variable} work with memmap.
......@@ -370,7 +370,7 @@ def constant_or_value(x, rtype, name=None, ndim=None, dtype=None):
# it will work if the long fits in int64 or uint64.
x_ = numpy.asarray(x)
assert type(x_) == numpy.ndarray
assert type(x_) in [numpy.ndarray, numpy.memmap]
bcastable = [d == 1 for d in x_.shape]
if ndim is not None:
......
......@@ -5929,6 +5929,14 @@ class T_as_tensor_variable(unittest.TestCase):
ten = as_tensor_variable(numpy.array([True, False, False, True, True]))
assert ten.type.dtype == 'uint8'
def test_memmap(self):
inp = numpy.random.rand(4, 3)
f, fname = mkstemp()
new_inp = numpy.memmap(fname, dtype=inp.dtype,
mode='w+', shape=inp.shape)
new_inp[...] = inp
x = as_tensor_variable(new_inp)
class test_complex_mod(unittest.TestCase):
"""Make sure % fails on complex numbers."""
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论