|
|
@@ -35,7 +35,7 @@ class TestJittor: |
|
|
|
:return: |
|
|
|
""" |
|
|
|
dataset = MyDataset() |
|
|
|
jtl = JittorDataLoader(dataset, keep_numpy_array=True, batch_size=4) |
|
|
|
jtl = JittorDataLoader(dataset, keep_numpy_array=False, batch_size=4) |
|
|
|
for batch in jtl: |
|
|
|
assert batch.size() == [4, 3, 4] |
|
|
|
jtl1 = JittorDataLoader(dataset, keep_numpy_array=False, batch_size=4, num_workers=2) |
|
|
@@ -49,11 +49,11 @@ class TestJittor: |
|
|
|
:return: |
|
|
|
""" |
|
|
|
dataset = Fdataset({'x': [[1, 2], [0], [2, 3, 4, 5]] * 100, 'y': [0, 1, 2] * 100}) |
|
|
|
jtl = JittorDataLoader(dataset, batch_size=16, drop_last=True) |
|
|
|
jtl.set_pad("x", -1) |
|
|
|
jtl.set_ignore("y") |
|
|
|
for batch in jtl: |
|
|
|
assert batch['x'].size() == (16, 4) |
|
|
|
# jtl = JittorDataLoader(dataset, batch_size=16, drop_last=True) |
|
|
|
# jtl.set_pad("x", -1) |
|
|
|
# jtl.set_ignore("y") |
|
|
|
# for batch in jtl: |
|
|
|
# assert batch['x'].size() == (16, 4) |
|
|
|
jtl1 = JittorDataLoader(dataset, batch_size=16, drop_last=True, num_workers=2) |
|
|
|
for batch in jtl1: |
|
|
|
print(batch) |
|
|
@@ -61,7 +61,7 @@ class TestJittor: |
|
|
|
|
|
|
|
def test_huggingface_datasets(self): |
|
|
|
dataset = HfDataset.from_dict({'x': [[1, 2], [0], [2, 3, 4, 5]] * 100, 'y': [0, 1, 2] * 100}) |
|
|
|
jtl = JittorDataLoader(dataset, batch_size=4, drop_last=True) |
|
|
|
jtl = JittorDataLoader(dataset, batch_size=4, drop_last=True, shuffle=False) |
|
|
|
for batch in jtl: |
|
|
|
assert batch['x'].size() == [4, 4] |
|
|
|
assert len(batch['y']) == 4 |
|
|
|