110a17a4d96d21cecf449073c9b66e1c888d2573,test/test_foreach.py,TestForeach,test_bool_scalarlist,#TestForeach#Any#Any#,668
Before Change
return
if foreach_bin_op == torch._foreach_sub:
if self.device_type == "cpu":
// see TODO[Fix scalar list]
res = foreach_bin_op(tensors, scalars)
if dtype in torch.testing.integral_types():
self.assertEqual(res, [r.to(torch.float32) for r in [torch_bin_op(t, 1) for t in tensors]])
with self.assertRaisesRegex(RuntimeError, "result type Float can"t be cast to the "):
foreach_bin_op_(tensors, scalars)
else:
self.assertEqual(res, [torch_bin_op(t, 1) for t in tensors])
foreach_bin_op_(tensors, scalars)
self.assertEqual(res, tensors)
else:
// see TODO[Fix scalar list]
res = foreach_bin_op(tensors, scalars)
if dtype in torch.testing.integral_types():
self.assertEqual(res, [r.to(dtype) for r in [torch_bin_op(t, 1) for t in tensors]])
else:
self.assertEqual(res, [torch_bin_op(t, 1) for t in tensors])
foreach_bin_op_(tensors, scalars)
self.assertEqual(res, tensors)
else:
if self.device_type == "cpu":
expected = [torch_bin_op(t, s) for t, s in zip(tensors, scalars)]
res = foreach_bin_op(tensors, scalars)
After Change
foreach_bin_op_(tensors, scalars)
return
else:
if foreach_bin_op == torch._foreach_sub:
with self.assertRaisesRegex(RuntimeError, "Subtraction, the `-` operator, with two bool tensors"):
foreach_bin_op_(tensors, scalars)
with self.assertRaisesRegex(RuntimeError, "Subtraction, the `-` operator, with two bool tensors"):
foreach_bin_op(tensors, scalars)
else:
expected = [torch_bin_op(t, s) for t, s in zip(tensors, scalars)]
res = foreach_bin_op(tensors, scalars)
self.assertEqual(res, expected)
if foreach_bin_op_ == torch._foreach_div_:
with self.assertRaisesRegex(RuntimeError, "result type Float can"t be cast to the desired"):
foreach_bin_op_(tensors, scalars)
else:
foreach_bin_op_(tensors, scalars)
self.assertEqual(res, tensors)
else:
// we dont support complex types on CUDA for now
if (dtype in torch.testing.get_all_complex_dtypes()) and self.device_type == "cuda":
with self.assertRaisesRegex(RuntimeError, "not implemented for"):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 8
Instances
Project Name: pytorch/pytorch
Commit Name: 110a17a4d96d21cecf449073c9b66e1c888d2573
Time: 2021-03-04
Author: iuriiz@fb.com
File Name: test/test_foreach.py
Class Name: TestForeach
Method Name: test_bool_scalarlist
Project Name: jsalt18-sentence-repl/jiant
Commit Name: 05a5e9c7c71571a1396adacd305bb0415e9c4170
Time: 2018-07-04
Author: wang.alex.c@gmail.com
File Name: src/evaluate.py
Class Name:
Method Name: write_preds
Project Name: pytorch/pytorch
Commit Name: cce84b5ca5fb02bda814138bd361eea6cafc16d5
Time: 2021-02-02
Author: iuriiz@devfair004.maas
File Name: test/test_foreach.py
Class Name: TestForeach
Method Name: test_bool_scalarlist