mirror of
https://github.com/pytorch/pytorch.git
synced 2026-11-20 09:04:25 +08:00
Remove OptionsGuard from ATen (#13738)
Summary: Deletes the `OptionsGuard` from ATen. This works towards the goal of reworking `DefaultTensorOptions`. `OptionsGuard` is troublesome because it relies on mutating thread local state. This PR fixes those code locations and then deletes the `OptionsGuard`. ezyang gchanan Pull Request resolved: https://github.com/pytorch/pytorch/pull/13738 Differential Revision: D13000962 Pulled By: goldsborough fbshipit-source-id: c8143ee75070c2280f5fd1d9af86f8ce14279b72
This commit is contained in:
committed by
Facebook Github Bot
parent
8f4dc192b6
commit
37cb357d8d
@@ -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::dtype(torch::kInt32));
|
||||
return torch::ones(5, torch::kInt32);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -176,12 +176,9 @@ 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});
|
||||
@@ -202,9 +199,6 @@ 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);
|
||||
@@ -215,7 +209,7 @@ TEST_F(ParallelTest, DataParallelUsesAllAvailableCUDADevices_CUDA) {
|
||||
struct M : torch::nn::Cloneable<M> {
|
||||
void reset() override {}
|
||||
torch::Tensor forward(torch::Tensor input) {
|
||||
return torch::tensor(torch::getDefaultTensorOptions().device().index());
|
||||
return torch::tensor(input.device().index());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user