예제 #1
0
 def test_tensor_list(self):
     with tempfile.NamedTemporaryFile() as bf:
         with h5py.File(bf.name,
                        "w") as hf, FileEdgeAppender(hf) as buffered_hf:
             buffered_hf.append_tensor_list(
                 "foo",
                 TensorList(
                     torch.tensor([0, 3, 5], dtype=torch.long),
                     torch.tensor([1, 2, 3, 4, 5], dtype=torch.long),
                 ),
             )
             buffered_hf.append_tensor_list(
                 "bar",
                 TensorList(
                     torch.tensor([0, 1_000_000], dtype=torch.long),
                     torch.arange(1_000_000, dtype=torch.long),
                 ),
             )
             buffered_hf.append_tensor_list(
                 "foo",
                 TensorList(
                     torch.tensor([0, 1, 1, 3], dtype=torch.long),
                     torch.tensor([6, 7, 8], dtype=torch.long),
                 ),
             )
예제 #2
0
 def test_tensors(self):
     with tempfile.NamedTemporaryFile() as bf:
         with h5py.File(bf.name,
                        "w") as hf, FileEdgeAppender(hf) as buffered_hf:
             buffered_hf.append_tensor(
                 "foo",
                 torch.tensor([1, 2, 3], dtype=torch.long),
             )
             buffered_hf.append_tensor(
                 "bar",
                 torch.tensor([10, 11], dtype=torch.long),
             )
             buffered_hf.append_tensor(
                 "foo",
                 torch.tensor([4], dtype=torch.long),
             )
             buffered_hf.append_tensor(
                 "foo",
                 torch.tensor([], dtype=torch.long),
             )
             buffered_hf.append_tensor(
                 "bar",
                 torch.arange(12, 1_000_000, dtype=torch.long),
             )
             buffered_hf.append_tensor(
                 "foo",
                 torch.tensor([5, 6], dtype=torch.long),
             )