Caffe2 - C++ API
A deep learning, cross platform ML framework
rebatching_queue_ops.cc
1 
17 #include "rebatching_queue_ops.h"
18 
19 namespace caffe2 {
20 
21 CAFFE_KNOWN_TYPE(RebatchingQueuePtr);
22 
23 namespace {
24 
25 REGISTER_CPU_OPERATOR(CreateRebatchingQueue, CreateRebatchingQueueOp);
26 REGISTER_CPU_OPERATOR(EnqueueRebatchingQueue, EnqueueRebatchingQueueOp);
27 REGISTER_CPU_OPERATOR(DequeueRebatchingQueue, DequeueRebatchingQueueOp);
28 REGISTER_CPU_OPERATOR(CloseRebatchingQueue, CloseRebatchingQueueOp);
29 
30 NO_GRADIENT(CreateRebatchingQueue);
31 NO_GRADIENT(EnqueueRebatchingQueue);
32 NO_GRADIENT(DequeueRebatchingQueue);
33 NO_GRADIENT(CloseRebatchingQueue);
34 
35 OPERATOR_SCHEMA(CreateRebatchingQueue)
36  .NumInputs(0)
37  .NumOutputs(1)
38  .SetDoc(R"DOC(
39 Creates the Queue.
40 )DOC")
41  .Output(0, "queue", "object representing the queue")
42  .Arg("num_blobs", "Number of input tensors the queue will support")
43  .Arg(
44  "capacity",
45  "Maximal number of elements the queue can hold at any given point");
46 
47 OPERATOR_SCHEMA(CloseRebatchingQueue)
48  .NumInputs(1)
49  .NumOutputs(0)
50  .SetDoc(R"DOC(
51 Closes the Queue.
52 )DOC")
53  .Input(0, "queue", "object representing the queue");
54 
55 OPERATOR_SCHEMA(EnqueueRebatchingQueue)
56  .NumInputs(2, INT_MAX)
57  .NumOutputs(0)
58  .SetDoc(R"DOC(
59 Enqueues Tensors into the queue.
60 Number of input tensors should be equal to the number of components passed
61 during creation of the queue.
62 If the Queue is closed this operation will fail.
63 If enqueue_batch argument is set. We will split the input tensors by the
64 first dimension to produce single queue elements.
65 )DOC")
66  .Input(0, "queue", "object representing the queue")
67  .Input(1, "tensor", "First tensor to enque. ")
68  .Arg(
69  "enqueue_batch",
70  "Are we enqueuing a batch or just a single element. \
71  By default we enqueue single element.");
72 
73 OPERATOR_SCHEMA(DequeueRebatchingQueue)
74  .NumInputs(1)
75  .NumOutputs(1, INT_MAX)
76  .SetDoc(R"DOC(
77 Dequeue Tensors from the Queue.
78 If the Queue is closed this might return less elements than asked.
79 If num_elements > 1 the returned elements will be concatenated into one
80 tensor per component.
81 )DOC")
82  .Input(0, "rebatching_queue", "object representing the queue")
83  .Input(1, "tensor", "First tensor to enqueue")
84  .Arg(
85  "num_elements",
86  "Number of elements to dequeue. By default we dequeue one element.");
87 }
88 }
Copyright (c) 2016-present, Facebook, Inc.