MCPcopy Create free account
hub / github.com/THUDM/GLM / build_data_loader

Function build_data_loader

tasks/data_utils.py:362–384  ·  view source on GitHub ↗

Data loader. Note that batch-size is the local (per GPU) batch-size.

(dataset, batch_size, num_workers, drop_last, shuffle=True, only_rank0=False)

Source from the content-addressed store, hash-verified

360
361
362def build_data_loader(dataset, batch_size, num_workers, drop_last, shuffle=True, only_rank0=False):
363 """Data loader. Note that batch-size is the local (per GPU) batch-size."""
364
365 # Sampler.
366 if only_rank0:
367 rank, world_size = 0, 1
368 else:
369 world_size = mpu.get_data_parallel_world_size()
370 rank = mpu.get_data_parallel_rank()
371 sampler = torch.utils.data.distributed.DistributedSampler(
372 dataset, num_replicas=world_size, rank=rank, shuffle=shuffle)
373
374 # Data loader. Note that batch size is the per GPU batch size.
375 data_loader = torch.utils.data.DataLoader(dataset,
376 batch_size=batch_size,
377 sampler=sampler,
378 shuffle=False,
379 num_workers=num_workers,
380 drop_last=drop_last,
381 pin_memory=True,
382 collate_fn=my_collate)
383
384 return data_loader

Callers 3

accuracy_func_providerFunction · 0.90
metrics_func_providerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected