def test_merge_form(self): w1, w2 = dragon.Workspace(), dragon.Workspace() with w1.as_default(): x = dragon.Tensor((), name='test_merge_from/x').set_value(0) w2.merge_from(w1) with w2.as_default(): self.assertEqual(int(x), 0)
def test_merge_form(self): w1, w2 = dragon.Workspace(), dragon.Workspace() with w1.as_default(): x = dragon.constant(0) w2.merge_from(w1) with w2.as_default(): self.assertEqual(int(x), 0)
def test_reset_tensor(self): w = dragon.Workspace() with w.as_default(): x = dragon.EagerTensor(1) self.assertEqual(x.size, 1) w.reset_tensor(x) self.assertEqual(x.size, 0)
def test_clear(self): w = dragon.Workspace() with w.as_default(): x = dragon.EagerTensor(1) self.assertEqual(x.size, 1) w.clear() self.assertEqual(x.size, 0)
def test_register_alias(self): w = dragon.Workspace() with w.as_default(): x = dragon.constant(1) w.set_alias(x.id, 'test_register_alias/y') alias_impl = w.get_tensor('test_register_alias/y') self.assertEqual(int(alias_impl.ToNumpy()), 1)
def test_reset_workspace(self): w = dragon.Workspace() with w.as_default(): try: dragon.reset_workspace() except AssertionError: pass dragon.reset_workspace()
def test_feed_tensor(self): w = dragon.Workspace() with w.as_default(): v1, v2 = dragon.EagerTensor(1), np.array(2) x = dragon.Tensor((), name='test_feed_tensor/x') w.feed_tensor(x, v1) self.assertEqual(int(x), 1) w.feed_tensor(x, v2) self.assertEqual(int(x), 2)
def test_memory_allocated(self): w = dragon.Workspace() with w.as_default(): _ = w.memory_allocated() _ = dragon.cuda.memory_allocated()
def test_register_alias(self): w = dragon.Workspace() with w.as_default(): x = dragon.EagerTensor(1) w.register_alias(x.id, 'test_register_alias/y') self.assertEqual(int(w.fetch_tensor('test_register_alias/y')), 1)