pytorch_pfn_extras.training.extensions.snapshot_writers.ThreadQueueWriter#

class pytorch_pfn_extras.training.extensions.snapshot_writers.ThreadQueueWriter(savefun=<function save>, fs=None, out_dir='', task=None)#

Bases: QueueWriter[Thread]

Snapshot writer that uses a thread queue.

This class creates a thread and a queue by threading and queue modules respectively. The thread will be a consumer of the queue, and the main thread will be a producer of the queue.

Methods

__init__([savefun, fs, out_dir, task])

consume(q)

create_consumer(q)

create_queue()

create_task(savefun)

finalize()

Finalizes the writer.

initialize(out_dir)

save(filename, out_dir, target, savefun, ...)

Parameters:
  • savefun (Callable[[...], None]) –

  • fs (Any) –

  • out_dir (str) –

  • task (Optional[Callable[[...], None]]) –

__init__(savefun=<function save>, fs=None, out_dir='', task=None)#
Parameters:
  • savefun (Callable[[...], None]) –

  • fs (Any) –

  • out_dir (str) –

  • task (Optional[Callable[[...], None]]) –

Return type:

None

create_consumer(q)#
Parameters:

q (Queue[Optional[Tuple[Callable[[...], None], str, str, Union[Sequence[Any], Mapping[str, Any]], Optional[Callable[[...], None]], bool]]]) –

Return type:

Thread

create_queue()#
Return type:

Queue[Optional[Tuple[Callable[[…], None], str, str, Union[Sequence[Any], Mapping[str, Any]], Optional[Callable[[…], None]], bool]]]