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

Method Run

tensorflow/core/nccl/nccl_rewrite.cc:246–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244class NcclReplacePass : public GraphOptimizationPass {
245 public:
246 Status Run(const GraphOptimizationPassOptions& options) override {
247 if (options.graph == nullptr) {
248 return Status::OK();
249 }
250 Graph* graph = options.graph->get();
251 if (graph == nullptr) {
252 return errors::Internal(
253 "NCCL replacement should happen before partitioning and a "
254 "graph should be available.");
255 }
256 // Find reduction and broadcast ops and replace them with Send/Recv ops.
257 for (Node* node : graph->op_nodes()) {
258 StringPiece type = node->type_string();
259 if (!absl::StartsWith(type, "Nccl")) {
260 continue;
261 }
262 if (type == "NcclReduce") {
263 TF_RETURN_IF_ERROR(ReplaceReduce(graph, node));
264 }
265 if (type == "NcclBroadcast") {
266 TF_RETURN_IF_ERROR(ReplaceBroadcast(graph, node));
267 }
268 }
269 return Status::OK();
270 }
271};
272REGISTER_OPTIMIZATION(OptimizationPassRegistry::POST_PLACEMENT, 0,
273 NcclReplacePass);

Callers

nothing calls this directly

Calls 6

InternalFunction · 0.85
StartsWithFunction · 0.85
ReplaceReduceFunction · 0.85
ReplaceBroadcastFunction · 0.85
op_nodesMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected