neural_compressor.data.dataloaders.base_dataloader

BaseDataloder of all dataloaders.

Module Contents

Classes

BaseDataLoader

Base class for all DataLoaders.

class neural_compressor.data.dataloaders.base_dataloader.BaseDataLoader(dataset, batch_size=1, last_batch='rollover', collate_fn=None, sampler=None, batch_sampler=None, num_workers=0, pin_memory=False, shuffle=False, distributed=False)

Base class for all DataLoaders.

_generate_dataloader is needed to create a dataloader object from the general params like batch_size and sampler. The dynamic batching is just to generate a new dataloader by setting batch_size and last_batch.

property batch_size

Get dataloader’s batch_size.

Returns:

batch_size

Return type:

int

batch(batch_size, last_batch=None)

Set batch size for dataloader.

Parameters:
  • batch_size (int) – number of samples per batch.

  • last_batch (str, optional) – whether to drop the last batch if it is incomplete. Support [‘rollover’, ‘discard’], rollover means False, discard means True. Defaults to None.