forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcpp_c10d_extension.cpp
122 lines (98 loc) · 3.84 KB
/
cpp_c10d_extension.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "cpp_c10d_extension.hpp"
#include <map>
namespace c10d {
ProcessGroupTest::WorkTest::~WorkTest() {}
bool ProcessGroupTest::WorkTest::isCompleted() {
return true;
}
bool ProcessGroupTest::WorkTest::isSuccess() const {
return true;
}
bool ProcessGroupTest::WorkTest::wait(std::chrono::milliseconds /* unused */) {
return true;
}
ProcessGroupTest::ProcessGroupTest(int rank, int size)
: ProcessGroup(rank, size) {}
ProcessGroupTest::~ProcessGroupTest() {}
c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupTest::broadcast(
std::vector<at::Tensor>& tensors,
const BroadcastOptions& opts) {
return c10::make_intrusive<ProcessGroupTest::WorkTest>();
}
c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupTest::allreduce(
std::vector<at::Tensor>& tensors,
const AllreduceOptions& opts) {
return c10::make_intrusive<ProcessGroupTest::WorkTest>();
}
c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupTest::allreduce_coalesced(
std::vector<at::Tensor>& tensors,
const AllreduceCoalescedOptions& opts) {
throw std::runtime_error("ProcessGroupTest does not support allreduce_coalesced");
}
c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupTest::reduce(
std::vector<at::Tensor>& tensors,
const ReduceOptions& opts) {
throw std::runtime_error("ProcessGroupTest does not support reduce");
}
c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupTest::allgather(
std::vector<std::vector<at::Tensor>>& outputTensors,
std::vector<at::Tensor>& inputTensors,
const AllgatherOptions& opts) {
throw std::runtime_error("ProcessGroupTest does not support allgather");
}
c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupTest::_allgather_base(
at::Tensor& outputBuffer,
at::Tensor& inputBuffer,
const AllgatherOptions& opts) {
throw std::runtime_error("ProcessGroupTest does not support _allgather_base");
}
c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupTest::barrier(
const BarrierOptions& opts) {
return c10::make_intrusive<ProcessGroupTest::WorkTest>();
}
c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupTest::gather(
std::vector<std::vector<at::Tensor>>& outputTensors,
std::vector<at::Tensor>& inputTensors,
const GatherOptions& opts) {
throw std::runtime_error("ProcessGroupTest does not support gather");
}
c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupTest::scatter(
std::vector<at::Tensor>& outputTensors,
std::vector<std::vector<at::Tensor>>& inputTensors,
const ScatterOptions& opts) {
throw std::runtime_error("ProcessGroupTest does not support scatter");
}
c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupTest::reduce_scatter(
std::vector<at::Tensor>& outputTensors,
std::vector<std::vector<at::Tensor>>& inputTensors,
const ReduceScatterOptions& opts) {
throw std::runtime_error("ProcessGroupTest does not support reduce_scatter");
}
c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupTest::send(
std::vector<at::Tensor>& tensors,
int dstRank,
int tag) {
throw std::runtime_error("ProcessGroupTest does not support send");
}
c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupTest::recv(
std::vector<at::Tensor>& tensors,
int srcRank,
int tag) {
throw std::runtime_error("ProcessGroupTest does not support recv");
}
c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupTest::recvAnysource(
std::vector<at::Tensor>& tensor,
int tag) {
throw std::runtime_error("ProcessGroupTest does not support recvAnysource");
}
c10::intrusive_ptr<ProcessGroup> ProcessGroupTest::createProcessGroupTest(
const c10::intrusive_ptr<::c10d::Store>& store,
int rank,
int size,
const std::chrono::duration<float>& timeout) {
return c10::make_intrusive<ProcessGroupTest>(rank, size);
}
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("createProcessGroupTest", &ProcessGroupTest::createProcessGroupTest);
}
} // namespace c10d