pytorch  1.8.2
About: PyTorch provides Tensor computation (like NumPy) with strong GPU acceleration and Deep Neural Networks (in Python) built on a tape-based autograd system. LTS (Long Term Support) release.
  Fossies Dox: pytorch-1.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

communicator_op.cc
Go to the documentation of this file.
3
4namespace caffe2 {
5
6OPERATOR_SCHEMA(CreateCommonWorld)
7 .NumInputs(0, 1)
8 .NumOutputs(1)
9 .SetDoc(R"DOC(
10Creates a common world for communication operators.
11)DOC")
12 .Input(0, "kv_handler", "Key/value handler for rendezvous (optional).")
13 .Output(0, "comm_world", "A common world for collective operations.")
14 .Arg("size", "(int) size of the common world.")
15 .Arg("rank", "(int) rank of this node in the common world.");
16
17OPERATOR_SCHEMA(CloneCommonWorld)
18 .NumInputs(1)
19 .NumOutputs(1)
20 .SetDoc(R"DOC(
21Clones existing common world.
22)DOC")
23 .Input(0, "existing_comm_world", "Existing common world to clone.")
24 .Output(0, "comm_world", "A common world for collective operations.");
25
26OPERATOR_SCHEMA(DestroyCommonWorld)
27 .NumInputs(1)
28 .NumOutputs(1)
29 .EnforceInplace({{0, 0}})
30 .SetDoc("Closes all connections managed by a common world.")
31 .Input(0, "common_world", "The common world to be destroyed.");
32
34 .NumInputsOutputs([](int in, int out) {
35 return in >= 2 && out == (in - 1);
36 })
37 .EnforceInplace([](int in, int out) { return (in - 1) == out; })
39 .IdenticalTypeAndShapeOfInput(0)
40 .SetDoc(R"DOC(
41Does a broadcast operation from the root node to every other node. The tensor
42on each node should have been pre-created with the same shape and data type.
43)DOC")
44 .Input(0, "comm_world", "The common world.")
45 .Input(1, "X", "A tensor to be broadcasted.")
46 .Output(0, "X", "In-place as input 1.")
47 .Arg("root", "(int, default 0) the root to run broadcast from.");
48
50 .NumInputs(2)
51 .NumOutputs(1)
52 .InputsCanCrossDevices()
53 .IdenticalTypeAndShapeOfInput(0)
54 .SetDoc(R"DOC(
55Does a reduce operation from every node to the root node. Currently only
56Sum is supported.
57)DOC")
58 .Input(0, "comm_world", "The common world.")
59 .Input(1, "X", "A tensor to be reduced.")
60 .Output(0, "Y", "The reduced result on root, not set for other nodes.")
61 .Arg("root", "(int, default 0) the root to run reduce into.");
62
64 .NumInputsOutputs([](int in, int out) {
65 return in >= 2 && out == (in - 1);
66 })
67 .EnforceInplace([](int in, int out) { return (in - 1) == out; })
69 .InputsCanCrossDevices()
70 .SetDoc(R"DOC(
71Does an allreduce operation among the nodes. Currently only Sum is supported.
72)DOC")
73 .Input(0, "comm_world", "The common world.")
74 .Input(1, "X", "A tensor to be allreduced.")
75 .Output(0, "Y", "The allreduced tensor, same on all nodes.");
76
77OPERATOR_SCHEMA(ReduceScatter)
78 .NumInputsOutputs([](int in, int out) {
79 return in >= 2 && out == (in - 1);
80 })
81 .EnforceInplace([](int in, int out) { return (in - 1) == out; })
83 .InputsCanCrossDevices()
84 .SetDoc(R"DOC(
85Does reduce-scatter operation among the nodes. Currently only Sum is supported.
86)DOC")
87 .Input(0, "comm_world", "The common world.")
88 .Input(1, "X", "A tensor to be reduce-scattered.")
89 .Output(0, "Y", "The reduced tensor, scattered on all nodes.");
90
91OPERATOR_SCHEMA(Allgather)
92 .NumInputs(2, INT_MAX)
93 .NumOutputs(1)
94 .InputsCanCrossDevices()
95 .SetDoc(R"DOC(
96Does an allgather operation among the nodes.
97)DOC")
98 .Input(0, "comm_world", "The common world.")
99 .Input(1, "X", "A tensor to be allgathered.")
100 .Output(0, "Y", "The allgathered tensor, same on all nodes.");
101
102OPERATOR_SCHEMA(Barrier)
103 .NumInputs(1)
104 .SetDoc(R"DOC(
105Does a barrier operation among the nodes.
106)DOC")
107 .Input(0, "comm_world", "The common world.");
108
109OPERATOR_SCHEMA(SendTensor)
110 .NumInputs({2, 4})
111 .NumOutputs(0)
112 .SetDoc(R"DOC(
113Sends the tensor to another node.
114)DOC")
115 .Input(0, "comm_world", "The common world.")
116 .Input(1, "X", "A tensor to be allgathered.")
117 .Input(
118 2,
119 "dst",
120 "An int CPUtensor of size 1 specifying the rank. If "
121 "given, this overrides the 'to' argument of the op.")
122 .Input(
123 3,
124 "tag",
125 "An int CPUtensor of size 1 specifying the tag to "
126 "send the tensor with. This overrides the 'tag' "
127 "argument of the op.")
128 .Arg("dst", "The rank to send the tensor to.")
129 .Arg("tag", "(int) a tag to send the tensor with.")
130 .Arg(
131 "raw_buffer",
132 "(bool) if set, only send the content and assume that the receiver "
133 "has already known the tensor's shape and information.");
134
135OPERATOR_SCHEMA(ReceiveTensor)
136 .NumInputs({2, 4})
137 .NumOutputs(3)
138 .EnforceInplace({{1, 0}})
139 .AllowInplace({{2, 1}, {3, 2}})
140 .SetDoc(R"DOC(
141Receives the tensor from another node.
142)DOC")
143 .Input(0, "comm_world", "The common world.")
144 .Input(
145 1,
146 "Y",
147 "In-place output. If raw_buffer is specified, "
148 "Y should have pre-allocated data and type..")
149 .Input(
150 2,
151 "src",
152 "An int CPUtensor of size 1 specifying the rank. If "
153 "given, this overrides the 'from' argument of the op.")
154 .Input(
155 3,
156 "tag",
157 "An int CPUtensor of size 1 specifying the tag to "
158 "send the tensor with. This overrides the 'tag' "
159 "argument of the op.")
160 .Output(0, "Y", "The received tensor.")
161 .Output(
162 1,
163 "src",
164 "The sender that sent the message as a CPUTensor "
165 "of size 1 and of type int.")
166 .Output(
167 2,
168 "tag",
169 "The tag that the message is sent with as a CPUTensor "
170 "of size 1 and of type int.")
171 .Arg("src", "(int) he rank to receive the tensor from.")
172 .Arg("tag", "(int) a tag to receive the tensor with.")
173 .Arg(
174 "raw_buffer",
175 "(bool) if set, only send the content and assume that the receiver "
176 "has already known the tensor's shape and information.");
177
178SHOULD_NOT_DO_GRADIENT(CreateCommonWorld);
179SHOULD_NOT_DO_GRADIENT(CloneCommonWorld);
180SHOULD_NOT_DO_GRADIENT(DestroyCommonWorld);
189
190// Communication operators do not have default engines.
202
203} // namespace caffe2
A helper class to denote that an op does not have a default engine.
TORCH_API void Broadcast(const int X_ndim, const int *X_dims, const int Y_ndim, const int *Y_dims, const T alpha, const T *X, T *Y, Context *context)
def Allreduce(net, blobs, reduced_affix="_reduced", gpu_indices=None)
Definition: muji.py:39
Copyright (c) 2016-present, Facebook, Inc.
Definition: blob.h:13
REGISTER_CPU_OPERATOR(ATen, ATenOp< CPUContext >)
OPERATOR_SCHEMA(ATen)
EnforceInplace({{1, 1}})
InputsCanCrossDevices() .IdenticalTypeAndShapeOfInput(0) .SetDoc(R"DOC( Does a broadcast operation from the root node to every other node. The tensor on each node should have been pre-created with the same shape and data type. )DOC") .Input(0
const vector< TensorShape > & in
AllowInplace({{0, 0}})
INT_MAX NumOutputs(1, INT_MAX)
SHOULD_NOT_DO_GRADIENT(ScriptModule)
SparseLengths8BitsRowwiseOp< CPUContext, 0, 1 >::LENGTHS SetDoc(R"DOC( Variation of SparseLengthsMean operator, where DATA is stored using 8bits. DATA was quantized with 8Bit row-wise quantization (see doc to FloatToRowwiseQuantized8Bits operator). To restore DATA from 8Bit, we use additional input that stores scales and biases. )DOC") .Input(0
IdenticalTypeAndShapeOfInput(0)
Tensor * Reduce(const std::string &name, const std::vector< DimArg > &dim_args, const Reducer &reducer, const Placeholder &buffer, const std::vector< DimArg > &reduce_args)
Definition: tensor.cpp:138