Revert "Remove OptionsGuard from ATen (#13738)" (#14082)

Summary:
This reverts commit 37cb357d8d.

Try to see if it unbreaks master
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14082

Differential Revision: D13095888

Pulled By: bddppq

fbshipit-source-id: c728f80f233b4d9daaf65f43202d8104651029a9
This commit is contained in:
Your Name
2018-11-15 23:45:31 -08:00
committed by Facebook Github Bot
parent 45fd77d3b7
commit 2fe4711eb4
13 changed files with 212 additions and 16 deletions
+8 -2
View File
@@ -134,7 +134,7 @@ TEST_F(ParallelTest, ParallelApply_MultiCUDA) {
TEST_F(ParallelTest, ParallelApplyWithDifferentOutputDevice_MultiCUDA) {
struct M : torch::nn::Module {
torch::Tensor forward(torch::Tensor input) {
return torch::ones(5, torch::kInt32);
return torch::ones({5}, torch::dtype(torch::kInt32));
}
};
@@ -176,9 +176,12 @@ TEST_F(
struct M : torch::nn::Cloneable<M> {
void reset() override {}
torch::Tensor forward(torch::Tensor input) {
// Intermediate tensors should be on the replica's current device.
intermediate_tensor = torch::rand(5);
// The returned tensor should be on the output device.
return torch::ones(3);
}
torch::Tensor intermediate_tensor;
};
auto m = std::make_shared<M>();
auto input = torch::ones({10, 3});
@@ -199,6 +202,9 @@ TEST_F(
input,
/*devices=*/std::vector<torch::Device>{torch::Device(torch::kCUDA, 0)},
/*output_device=*/torch::Device(torch::kCUDA, 1));
ASSERT_TRUE(m->intermediate_tensor.defined());
ASSERT_TRUE(m->intermediate_tensor.device().is_cuda());
ASSERT_EQ(m->intermediate_tensor.device().index(), 0);
ASSERT_TRUE(output.defined());
ASSERT_TRUE(output.device().is_cuda());
ASSERT_EQ(output.device().index(), 1);
@@ -209,7 +215,7 @@ TEST_F(ParallelTest, DataParallelUsesAllAvailableCUDADevices_CUDA) {
struct M : torch::nn::Cloneable<M> {
void reset() override {}
torch::Tensor forward(torch::Tensor input) {
return torch::tensor(input.device().index());
return torch::tensor(torch::getDefaultTensorOptions().device().index());
}
};