MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Send

Method Send

tensorflow/core/framework/rendezvous.cc:194–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192 explicit LocalRendezvousImpl() {}
193
194 Status Send(const ParsedKey& key, const Args& send_args, const Tensor& val,
195 const bool is_dead) override {
196 uint64 key_hash = KeyHash(key.FullKey());
197 VLOG(2) << "Send " << this << " " << key_hash << " " << key.FullKey();
198
199 mu_.lock();
200 if (!status_.ok()) {
201 // Rendezvous has been aborted.
202 Status s = status_;
203 mu_.unlock();
204 return s;
205 }
206
207 ItemQueue* queue = &table_[key_hash];
208 if (queue->empty() || queue->front()->IsSendValue()) {
209 // There is no waiter for this message. Append the message
210 // into the queue. The waiter will pick it up when arrives.
211 // Only send-related fields need to be filled.
212 VLOG(2) << "Enqueue Send Item (key:" << key.FullKey() << "). ";
213 Item* item = new Item;
214 item->value = val;
215 item->is_dead = is_dead;
216 item->send_args = send_args;
217 if (item->send_args.device_context) {
218 item->send_args.device_context->Ref();
219 }
220 queue->push_back(item);
221 mu_.unlock();
222 return Status::OK();
223 }
224
225 VLOG(2) << "Consume Recv Item (key:" << key.FullKey() << "). ";
226 // There is an earliest waiter to consume this message.
227 Item* item = queue->front();
228
229 // Delete the queue when the last element has been consumed.
230 if (queue->size() == 1) {
231 VLOG(2) << "Clean up Send/Recv queue (key:" << key.FullKey() << "). ";
232 table_.erase(key_hash);
233 } else {
234 queue->pop_front();
235 }
236 mu_.unlock();
237
238 // Notify the waiter by invoking its done closure, outside the
239 // lock.
240 DCHECK(!item->IsSendValue());
241 item->waiter(Status::OK(), send_args, item->recv_args, val, is_dead);
242 delete item;
243 return Status::OK();
244 }
245
246 // support send ref tensor to local rendezvous
247 Status Send(const ParsedKey& key, const Args& send_args,

Callers

nothing calls this directly

Calls 13

KeyHashClass · 0.85
FullKeyMethod · 0.80
lockMethod · 0.45
okMethod · 0.45
unlockMethod · 0.45
emptyMethod · 0.45
IsSendValueMethod · 0.45
frontMethod · 0.45
RefMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected