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

Function PowerSetOfIota

tensorflow/compiler/xla/tests/collective_ops_test.cc:138–149  ·  view source on GitHub ↗

Returns the non-empty subsets of {0, 1, ..., n}. For example, PowerSetOfIota(3) = {{0}, {1}, {2}, {0,1}, {0,2}, {1,2}, {0,1,2}}.

Source from the content-addressed store, hash-verified

136// Returns the non-empty subsets of {0, 1, ..., n}. For example,
137// PowerSetOfIota(3) = {{0}, {1}, {2}, {0,1}, {0,2}, {1,2}, {0,1,2}}.
138std::vector<std::vector<int64>> PowerSetOfIota(int64 n) {
139 std::vector<std::vector<int64>> power_set;
140 for (int64 i = 1; i < (1 << n); ++i) {
141 power_set.emplace_back();
142 for (int64 j = 0; j < n; ++j) {
143 if (i & (1 << j)) {
144 power_set.back().push_back(j);
145 }
146 }
147 }
148 return power_set;
149}
150
151// Makes a DeviceAssignment assigning replica-id i to devices[i].
152DeviceAssignment MakeDeviceAssn(std::vector<int64> devices) {

Callers 1

XLA_TEST_FFunction · 0.85

Calls 3

emplace_backMethod · 0.45
push_backMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected