#include <gtest/gtest.h>
-#include <torch/csrc/utils/tempfile.h>
#include <torch/nn/init.h>
#include <torch/nn/modules/linear.h>
#include <torch/types.h>
"has been used in an in-place operation");
ASSERT_EQ(torch::nn::init::ones_(tensor).sum().item<int32_t>(), 12);
}
-
-#if !defined(_WIN32)
-TEST(TempFileTest, MatchesExpectedPattern) {
- torch::utils::TempFile pattern = torch::utils::make_tempfile("test-pattern-");
- ASSERT_NE(pattern.name.find("test-pattern-"), std::string::npos);
-}
-#endif // !defined(_WIN32)
#include <gtest/gtest.h>
+#include <c10/util/tempfile.h>
+
#include <torch/nn/modules/functional.h>
#include <torch/nn/modules/linear.h>
#include <torch/nn/modules/sequential.h>
auto x = torch::randn({5, 5});
- auto tempfile = torch::utils::make_tempfile();
+ auto tempfile = c10::make_tempfile();
torch::save(x, tempfile.name);
torch::Tensor y;
epoch++;
}
- auto tempfile = torch::utils::make_tempfile();
+ auto tempfile = c10::make_tempfile();
torch::save(model, tempfile.name);
torch::load(model2, tempfile.name);
auto model3 = Linear(5, 2);
// Models 1, 2, 3 will have the same parameters.
- auto model_tempfile = torch::utils::make_tempfile();
+ auto model_tempfile = c10::make_tempfile();
torch::save(model1, model_tempfile.name);
torch::load(model2, model_tempfile.name);
torch::load(model3, model_tempfile.name);
// Do 2 steps of model 3 while saving the optimizer
step(optim3, model3);
- auto optim_tempfile = torch::utils::make_tempfile();
+ auto optim_tempfile = c10::make_tempfile();
torch::save(optim3, optim_tempfile.name);
torch::load(optim3_2, optim_tempfile.name);
step(optim3_2, model3);
epoch++;
}
- auto tempfile = torch::utils::make_tempfile();
+ auto tempfile = c10::make_tempfile();
torch::save(model, tempfile.name);
torch::load(model2, tempfile.name);
loss = getLoss(model2, 100, true);
ASSERT_LT(loss.item<float>(), 0.1);
- auto tempfile2 = torch::utils::make_tempfile();
+ auto tempfile2 = c10::make_tempfile();
torch::save(model2, tempfile2.name);
torch::load(model3, tempfile2.name);
#include <memory>
#include <unordered_map>
-#include <torch/csrc/utils/tempfile.h>
-#include <c10/util/Optional.h>
+#include <c10/util/tempfile.h>
#include <libshm/err.h>
#include <libshm/socket.h>
std::unique_ptr<ManagerServerSocket> srv_socket;
const auto tempfile =
- torch::utils::try_make_tempfile(/*name_prefix=*/"torch-shm-file-");
+ c10::try_make_tempfile(/*name_prefix=*/"torch-shm-file-");
try {
if (!tempfile.has_value()) {
throw std::runtime_error(