参考 Tensorflow Cross Device Communication
In TensorFlow, cross-device communication is achieved using the Rendezvous
interface, which has multiple different implementations, depending on the deployment. The comment on that interface describes the general idea:
在 TensorFlow 中,跨设备通信使用Rendezvous
接口实现,该接口具有多个不同的实现,具体取决于不同的部署。 该接口的注释描述了大概的思路:
rendezvous.h
// A Rendezvous is an abstraction for passing a Tensor
// from a producer to a consumer, where the consumer may safely
// request the Tensor before or after it has been produced. A
// producer never blocks when using a Rendezvous. A consumer has the
// choice of making a blocking call or providing a callback: in either
// case, the consumer receives the Tensor as soon as it is available.