|
|
|
@ -18,6 +18,7 @@ import paddle.fluid as fluid
|
|
|
|
|
import paddle.fluid.core as core
|
|
|
|
|
import unittest
|
|
|
|
|
import numpy
|
|
|
|
|
import numbers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestTensor(unittest.TestCase):
|
|
|
|
@ -171,7 +172,6 @@ class TestTensor(unittest.TestCase):
|
|
|
|
|
var = scope.var("test_tensor")
|
|
|
|
|
|
|
|
|
|
tensor = var.get_tensor()
|
|
|
|
|
|
|
|
|
|
tensor._set_dims([0, 1])
|
|
|
|
|
tensor._alloc_float(place)
|
|
|
|
|
|
|
|
|
@ -256,6 +256,26 @@ class TestTensor(unittest.TestCase):
|
|
|
|
|
print(tensor)
|
|
|
|
|
self.assertTrue(isinstance(str(tensor), str))
|
|
|
|
|
|
|
|
|
|
def test_tensor_poiter(self):
|
|
|
|
|
place = core.CPUPlace()
|
|
|
|
|
scope = core.Scope()
|
|
|
|
|
var = scope.var("test_tensor")
|
|
|
|
|
place = core.CPUPlace()
|
|
|
|
|
tensor = var.get_tensor()
|
|
|
|
|
dtype = core.VarDesc.VarType.FP32
|
|
|
|
|
self.assertTrue(
|
|
|
|
|
isinstance(tensor._mutable_data(place, dtype), numbers.Integral))
|
|
|
|
|
|
|
|
|
|
if core.is_compiled_with_cuda():
|
|
|
|
|
place = core.CUDAPlace(0)
|
|
|
|
|
self.assertTrue(
|
|
|
|
|
isinstance(
|
|
|
|
|
tensor._mutable_data(place, dtype), numbers.Integral))
|
|
|
|
|
place = core.CUDAPinnedPlace()
|
|
|
|
|
self.assertTrue(
|
|
|
|
|
isinstance(
|
|
|
|
|
tensor._mutable_data(place, dtype), numbers.Integral))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
unittest.main()
|
|
|
|
|