2020"""Registry for dataset classes."""
2121
2222
23- def is_ram_cache_supported () -> bool :
24- """Check if RAM cache is supported on the current platform.
25-
26- Returns:
27- bool: True if RAM cache is supported (Linux only), False otherwise.
28- """
29- return platform .system () == "Linux"
30-
31-
3223def validate_ram_cache_config (use_ram_cache : bool , verbose : bool = True ) -> bool :
3324 """Validate RAM cache configuration for current platform.
3425
@@ -39,7 +30,7 @@ def validate_ram_cache_config(use_ram_cache: bool, verbose: bool = True) -> bool
3930 Returns:
4031 bool: True if RAM cache can be used, False otherwise.
4132 """
42- if use_ram_cache and not is_ram_cache_supported () :
33+ if use_ram_cache and platform . system () != "Linux" :
4334 if verbose :
4435 logger .warning (
4536 f"RAM cache is only supported on Linux. Current OS: { platform .system ()} . "
@@ -161,7 +152,7 @@ def build_sampler(
161152 return sampler , batch_sampler
162153
163154
164- def collate (batch : list [DatasetOutput ]) -> dict [ str , torch . Tensor ] :
155+ def collate (batch : list [DatasetOutput ]) -> DatasetOutput :
165156 """Collate function for combining dataset outputs into batches.
166157
167158 Automatically handles stacking of tensors and conversion of numeric
@@ -183,4 +174,4 @@ def collate(batch: list[DatasetOutput]) -> dict[str, torch.Tensor]:
183174 output [k ] = torch .stack (output [k ], dim = 0 )
184175 elif isinstance (output [k ][0 ], (int , float )):
185176 output [k ] = torch .tensor (output [k ])
186- return output
177+ return DatasetOutput ( ** output )
0 commit comments