1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#pragma once
#include <caffe2/serialize/inline_container.h>
#include <torch/csrc/jit/api/module.h>
#include <torch/csrc/jit/ir/ir.h>
#include <torch/csrc/jit/serialization/unpickler.h>
#include <istream>
namespace caffe2 {
namespace serialize {
class ReadAdapterInterface;
} // namespace serialize
} // namespace caffe2
namespace torch {
namespace jit {
static ExtraFilesMap default_extra_files;
TORCH_API Module import_ir_module(
std::shared_ptr<CompilationUnit> cu,
const std::string& filename,
c10::optional<c10::Device> device = c10::nullopt,
ExtraFilesMap& extra_files = default_extra_files);
TORCH_API Module import_ir_module(
std::shared_ptr<CompilationUnit> cu,
std::istream& in,
c10::optional<c10::Device> device = c10::nullopt,
ExtraFilesMap& extra_files = default_extra_files);
TORCH_API Module import_ir_module(
std::shared_ptr<CompilationUnit> cu,
std::unique_ptr<caffe2::serialize::ReadAdapterInterface> rai,
c10::optional<c10::Device> device = c10::nullopt,
ExtraFilesMap& extra_files = default_extra_files);
/// Loads a serialized `Module` from the given `istream`.
///
/// The istream must contain a serialized `Module`, exported via
/// `torch::jit::ExportModule` in C++.
TORCH_API Module load(
std::istream& in,
c10::optional<c10::Device> device = c10::nullopt,
ExtraFilesMap& extra_files = default_extra_files);
/// Loads a serialized `Module` from the given `filename`.
///
/// The file stored at the location given in `filename` must contain a
/// serialized `Module`, exported either via `ScriptModule.save()` in
/// Python or `torch::jit::ExportModule` in C++.
TORCH_API Module load(
const std::string& filename,
c10::optional<c10::Device> device = c10::nullopt,
ExtraFilesMap& extra_files = default_extra_files);
/// Loads a serialized `Module` from the given `rai`.
///
/// The reader adapter, which is for customized input stream, must contain a
/// serialized `Module`, exported either via `ScriptModule.save()` in
/// Python or `torch::jit::ExportModule` in C++.
TORCH_API Module load(
std::unique_ptr<caffe2::serialize::ReadAdapterInterface> rai,
c10::optional<c10::Device> device = c10::nullopt,
ExtraFilesMap& extra_files = default_extra_files);
TORCH_API IValue readArchiveAndTensors(
const std::string& archive_name,
c10::optional<TypeResolver> type_resolver,
c10::optional<ObjLoader> obj_loader,
c10::optional<at::Device> device,
caffe2::serialize::PyTorchStreamReader& stream_reader);
} // namespace jit
} // namespace torch
|