MCPcopy Index your code
hub / github.com/pytorch/pytorch / pipe

Function pipe

caffe2/python/pipeline.py:99–149  ·  view source on GitHub ↗

Given a Reader, Queue or DataStream in `input`, and optionally, a Writer, Queue or DataStream in `output`, creates a Task that, when run, will pipe the input into the output, using multiple parallel threads. Additionally, if a processor is given, it will be called between reading

(
        input, output=None, num_threads=1, processor=None, name=None,
        capacity=None, group=None, num_runtime_threads=1)

Source from the content-addressed store, hash-verified

97
98
99def pipe(
100 input, output=None, num_threads=1, processor=None, name=None,
101 capacity=None, group=None, num_runtime_threads=1):
102 """
103 Given a Reader, Queue or DataStream in `input`, and optionally, a Writer,
104 Queue or DataStream in `output`, creates a Task that, when run, will
105 pipe the input into the output, using multiple parallel threads.
106 Additionally, if a processor is given, it will be called between reading
107 and writing steps, allowing it to transform the record.
108
109 Args:
110 input: either a Reader, Queue or DataStream that will be read
111 until a stop is signaled either by the reader or the
112 writer.
113 output: either a Writer, a Queue or a DataStream that will be
114 written to as long as neither reader nor writer signal
115 a stop condition. If output is not provided or is None,
116 a Queue is created with given `capacity` and written to.
117 num_threads: number of concurrent threads used for processing and
118 piping. If set to 0, no Task is created, and a
119 reader is returned instead -- the reader returned will
120 read from the reader passed in and process it.
121 ** DEPRECATED **. Use `num_runtime_threads` instead.
122 This option will be removed once all readers/processors
123 support `num_runtime_threads`.
124 processor: (optional) function that takes an input record and
125 optionally returns a record; this will be called
126 between read and write steps. If the processor does
127 not return a record, a writer will not be instantiated.
128 Processor can also be a core.Net with input and output
129 records properly set. In that case, a NetProcessor is
130 instantiated, cloning the net for each of the threads.
131 name: (optional) name of the task to be created.
132 capacity: when output is not passed, a queue of given `capacity`
133 is created and written to.
134 group: (optional) explicitly add the created Task to this
135 TaskGroup, instead of using the currently active one.
136 num_runtime_threads: Similar to `num_threads`, but instead of expanding
137 the tasks with a `for` loop in python, does that at
138 runtime. This is preferable to `num_threads`, but some
139 processors/readers still require to be called multiple
140 times in python.
141
142 Returns:
143 Output Queue, DataStream, Reader, or None, depending on the parameters
144 passed.
145 """
146 result, _ = _pipe_step(
147 input, output, num_threads, processor, name, capacity, group,
148 num_runtime_threads)
149 return result
150
151
152def pipe_and_output(

Callers 12

build_pipelineFunction · 0.90
test_dequeue_manyMethod · 0.90
build_cache_stepMethod · 0.90
test_local_sessionMethod · 0.90
test_composite_readerMethod · 0.90
test_runtime_threadsMethod · 0.90
_read_all_dataMethod · 0.90
test_deferred_batch_normFunction · 0.85

Calls 1

_pipe_stepFunction · 0.85

Tested by 11

build_pipelineFunction · 0.72
test_dequeue_manyMethod · 0.72
test_local_sessionMethod · 0.72
test_composite_readerMethod · 0.72
test_runtime_threadsMethod · 0.72
_read_all_dataMethod · 0.72
test_deferred_batch_normFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…