(self)
| 414 | self.assertIs(weak_xat1(), None) |
| 415 | |
| 416 | def testWeakKeyDictionaryTensor(self): |
| 417 | weak_key_dict = weakref.WeakKeyDictionary() |
| 418 | |
| 419 | strong_x = constant_op.constant([[1.]]) |
| 420 | strong_y = constant_op.constant([[2.]]) |
| 421 | strong_x_ref = strong_x.experimental_ref() |
| 422 | strong_y_ref = strong_y.experimental_ref() |
| 423 | weak_key_dict[strong_x_ref] = constant_op.constant([[3.]]) |
| 424 | weak_key_dict[strong_y_ref] = constant_op.constant([[4.]]) |
| 425 | strong_y.a = constant_op.constant([[5.]]) |
| 426 | weak_x_ref = weakref.ref(strong_x) |
| 427 | |
| 428 | del strong_x, strong_x_ref |
| 429 | self.assertIs(weak_x_ref(), None) |
| 430 | self.assertEqual([strong_y_ref], list(weak_key_dict)) |
| 431 | self.assertEqual(1, len(list(weak_key_dict))) |
| 432 | self.assertEqual(1, len(weak_key_dict)) |
| 433 | |
| 434 | del strong_y, strong_y_ref |
| 435 | self.assertEqual([], list(weak_key_dict)) |
| 436 | |
| 437 | def testEagerTensorsCanBeGarbageCollected(self): |
| 438 | x = constant_op.constant([[1.]]) |
nothing calls this directly
no test coverage detected