1 #include <torch/optim/serialize.h> 3 #include <torch/serialize/archive.h> 4 #include <torch/types.h> 15 serialize::OutputArchive& archive,
16 const std::string& key,
17 const std::vector<int64_t>& steps) {
18 std::vector<torch::Tensor> tensors;
19 tensors.reserve(steps.size());
20 for (
const auto& step : steps) {
21 tensors.push_back(torch::tensor(static_cast<int64_t>(step)));
23 serialize(archive, key, tensors);
27 serialize::InputArchive& archive,
28 const std::string& key,
29 std::vector<int64_t>& steps) {
31 std::vector<torch::Tensor> tensors;
32 serialize(archive, key, tensors);
33 for (
const auto& step : tensors) {
34 steps.push_back(step.item<int64_t>());