Add c10::optional to type syntax (#12582)

Summary:
This PR adds optional type to ATen native, autograd, JIT schema and Python Arg parser, closes #9513. It allows us to use optional default values (including None) for function signature and implementations like clamp, etc., and also let us remove the python_default_init hack.

Follow up:

remove python_default_init completely.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/12582

Differential Revision: D10417423

Pulled By: wanchaol

fbshipit-source-id: 1c80f0727bb528188b47c595629e2996be269b89
This commit is contained in:
Wanchao Liang
2018-10-25 16:06:00 -07:00
committed by Facebook Github Bot
parent 569a29b81a
commit 4e1c64caee
41 changed files with 352 additions and 224 deletions
+2 -2
View File
@@ -44,8 +44,8 @@ TEST_F(ParallelTest, DifferentiableScatter_MultiCUDA) {
TEST_F(ParallelTest, DifferentiableGather_MultiCUDA) {
Gather gather(torch::Device(torch::kCUDA, 1));
auto a = torch::ones(5, torch::requires_grad(true).device({torch::kCUDA, 0}));
auto b = torch::ones(5, torch::requires_grad(true).device({torch::kCUDA, 1}));
auto a = torch::ones(5, torch::requires_grad(true).device(torch::kCUDA, 0));
auto b = torch::ones(5, torch::requires_grad(true).device(torch::kCUDA, 1));
auto outputs = gather.apply({a, b});
ASSERT_EQ(outputs.size(), 1);