Exemplo n.º 1
0
    def test_dump_load(self):
        if not cuda_ndarray.cuda_enabled:
            raise SkipTest('Optional package cuda disabled')

        x = CudaNdarraySharedVariable('x', CudaNdarrayType((1, 1), name='x'),
                                      [[1]], False)

        with open('test', 'wb') as f:
            dump(x, f)

        with open('test', 'rb') as f:
            x = load(f)

        assert x.name == 'x'
        assert_allclose(x.get_value(), [[1]])
Exemplo n.º 2
0
    def test_dump_load(self):
        if not cuda_ndarray.cuda_enabled:
            raise SkipTest('Optional package cuda disabled')

        x = CudaNdarraySharedVariable('x', CudaNdarrayType((1, 1), name='x'),
                                      [[1]], False)

        with open('test', 'wb') as f:
            dump(x, f)

        with open('test', 'rb') as f:
            x = load(f)

        assert x.name == 'x'
        assert_allclose(x.get_value(), [[1]])
Exemplo n.º 3
0
 def test_cudandarrayvariable(self):
     # Get counter value
     autoname_id = next(Variable.__count__)
     Variable.__count__ = count(autoname_id)
     mytype = tensor.TensorType(dtype='int32', broadcastable=())
     r1 = CudaNdarrayVariable(type='int32')
     r2 = CudaNdarrayVariable(type='int32')
     r3 = CudaNdarrayConstant(type=mytype,
                              data=1)
     r4 = CudaNdarraySharedVariable(name='x', type=mytype,
                                    value=1, strict=False)
     assert r1.auto_name == "auto_" + str(autoname_id)
     assert r2.auto_name == "auto_" + str(autoname_id + 1)
     assert r3.auto_name == "auto_" + str(autoname_id + 2)
     assert r4.auto_name == "auto_" + str(autoname_id + 3)
Exemplo n.º 4
0
 def test_cudandarrayvariable(self):
     ## Re-init counter
     Variable.__count__ = count(0)
     mytype = tensor.TensorType(dtype='int32', broadcastable=())
     r1 = CudaNdarrayVariable(type='int32')
     r2 = CudaNdarrayVariable(type='int32')
     r3 = CudaNdarrayConstant(type=mytype, data=1)
     r4 = CudaNdarraySharedVariable(name='x',
                                    type=mytype,
                                    value=1,
                                    strict=False)
     assert r1.auto_name == "auto_0"
     assert r2.auto_name == "auto_1"
     assert r3.auto_name == "auto_2"
     assert r4.auto_name == "auto_3"