MCPcopy Create free account
hub / github.com/ml-explore/mlx / all_sum

Function all_sum

mlx/distributed/ops.cpp:25–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23} // namespace
24
25array all_sum(
26 const array& x,
27 std::optional<Group> group_ /* = std::nullopt */,
28 StreamOrDevice s /* = {} */) {
29 auto group = to_group(group_);
30
31 if (group.size() == 1) {
32 return x;
33 }
34 auto stream = detail::communication_stream(group, s);
35
36 return array(
37 x.shape(),
38 x.dtype(),
39 std::make_shared<AllReduce>(stream, group, AllReduce::Sum),
40 {x});
41}
42
43array all_max(
44 const array& x,

Callers 5

vmapMethod · 0.70
jvpMethod · 0.70
init_distributedFunction · 0.50
eval_cpuMethod · 0.50
mainFunction · 0.50

Calls 4

to_groupFunction · 0.85
communication_streamFunction · 0.85
arrayClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected