| 95 | : NcclReduceOpBase(c) {} |
| 96 | |
| 97 | void ComputeAsync(OpKernelContext* c, DoneCallback done) override { |
| 98 | const Tensor* input = &c->input(0); |
| 99 | Tensor* output; |
| 100 | OP_REQUIRES_OK_ASYNC( |
| 101 | c, c->forward_input_or_allocate_output({0}, 0, input->shape(), &output), |
| 102 | done); |
| 103 | auto actual_done = [c, done](Status s) { |
| 104 | OP_REQUIRES_OK_ASYNC(c, s, done); |
| 105 | done(); |
| 106 | }; |
| 107 | |
| 108 | auto* compute_stream = c->op_device_context()->stream(); |
| 109 | auto* gpu_info = c->device()->tensorflow_gpu_device_info(); |
| 110 | auto participant = absl::make_unique<NcclManager::Participant>( |
| 111 | compute_stream->parent(), compute_stream, gpu_info, |
| 112 | input, output, /*global_rank=*/-1, |
| 113 | std::move(actual_done)); |
| 114 | NcclManager::instance()->AddToAllReduce( |
| 115 | std::move(participant), |
| 116 | {GetCollectiveKey(c), |
| 117 | /*num_local_devices=*/num_devices(), |
| 118 | /*num_global_devices=*/num_devices(), |
| 119 | /*communicator_key=*/"", /*source_rank=*/-1}, |
| 120 | reduction_op()); |
| 121 | } |
| 122 | }; |
| 123 | REGISTER_KERNEL_BUILDER(Name("NcclAllReduce").Device(DEVICE_GPU), |
| 124 | NcclAllReduceOpKernel); |
nothing calls this directly
no test coverage detected