Skip to content

Commit

Permalink
adding BAND/BOR/BXOR reduce ops to unsupported list for complex numbe…
Browse files Browse the repository at this point in the history
…rs. added tests (#46270)

Summary: Pull Request resolved: #46270

Test Plan: Imported from OSS

Reviewed By: mrshenli

Differential Revision: D24284702

Pulled By: bdhirsh

fbshipit-source-id: 7e6c3fce83a4367808a638f0400999399b2c35b0
  • Loading branch information
bdhirsh authored and facebook-github-bot committed Oct 14, 2020
1 parent 8a074af commit 1f791c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion torch/distributed/distributed_c10d.py
Expand Up @@ -52,7 +52,8 @@
# We'd like calls to unsupported ops to error out accordingly,
# rather than returning garbage values.
def supports_complex(reduceOp: ReduceOp) -> bool:
denyList = [ReduceOp.MAX, ReduceOp.MIN, ReduceOp.PRODUCT]
denyList = [ReduceOp.MAX, ReduceOp.MIN, ReduceOp.PRODUCT,
ReduceOp.BAND, ReduceOp.BOR, ReduceOp.BXOR]
return reduceOp not in denyList


Expand Down
9 changes: 6 additions & 3 deletions torch/testing/_internal/distributed/distributed_test.py
Expand Up @@ -1303,10 +1303,13 @@ def test_all_reduce_sum_complex(self):
)

@unittest.skipIf(BACKEND == "nccl", "Nccl does not support CPU tensors")
def test_all_reduce_max_complex_unsupported(self):
def test_all_reduce_complex_unsupported_ops(self):
unsupported_ops = [dist.ReduceOp.MAX, dist.ReduceOp.MIN, dist.ReduceOp.PRODUCT,
dist.ReduceOp.BAND, dist.ReduceOp.BOR, dist.ReduceOp.BXOR]
group, group_id, rank = self._init_global_test()
with self.assertRaisesRegex(RuntimeError, "all_reduce does not support"):
dist.all_reduce(_build_tensor(1, dtype=torch.cfloat), dist.ReduceOp.MAX, group_id)
for unsupported_op in unsupported_ops:
with self.assertRaisesRegex(RuntimeError, "all_reduce does not support"):
dist.all_reduce(_build_tensor(1, dtype=torch.cfloat), unsupported_op, group_id)

@unittest.skipIf(
BACKEND != "gloo",
Expand Down

0 comments on commit 1f791c0

Please sign in to comment.