Uni-Core / unicore /data /from_numpy_dataset.py
Irwiny123's picture
提交Uni-Core初始代码
eb6d243
Raw
History Blame Contribute Delete
461 Bytes
# Copyright (c) DP Technology.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from functools import lru_cache
from . import BaseWrapperDataset
class FromNumpyDataset(BaseWrapperDataset):
def __init__(self, dataset):
super().__init__(dataset)
@lru_cache(maxsize=16)
def __getitem__(self, idx):
return torch.from_numpy(self.dataset[idx])