#pragma once #include #include #include #include #include namespace caffe2::serialize { class ReadAdapterInterface; } // namespace caffe2::serialize namespace torch::jit { class DeserializationStorageContext; TORCH_API Module import_ir_module( std::shared_ptr cu, const std::string& filename, std::optional device = std::nullopt, bool load_debug_files = true); TORCH_API Module import_ir_module( std::shared_ptr cu, std::istream& in, std::optional device = std::nullopt, bool load_debug_files = true); TORCH_API Module import_ir_module( std::shared_ptr cu, std::unique_ptr rai, std::optional device = std::nullopt, bool load_debug_files = true); TORCH_API Module import_ir_module( std::shared_ptr cu, const std::string& filename, std::optional device, ExtraFilesMap& extra_files, bool load_debug_files = true, bool restore_shapes = false); // For reading unified serialization format from torch.Package TORCH_API Module import_ir_module( std::shared_ptr cu, std::shared_ptr reader, std::shared_ptr storage_context, std::optional device, const std::string& ts_id /* torchscript identifier inside package */); TORCH_API Module import_ir_module( std::shared_ptr cu, std::istream& in, std::optional device, ExtraFilesMap& extra_files, bool load_debug_files = true, bool restore_shapes = false); TORCH_API Module import_ir_module( std::shared_ptr cu, std::unique_ptr rai, std::optional device, ExtraFilesMap& extra_files, bool load_debug_files = true); TORCH_API Module import_ir_module( std::shared_ptr cu, std::shared_ptr rai, std::optional device, ExtraFilesMap& extra_files, bool load_debug_files = true); /// 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, std::optional device = std::nullopt, bool load_debug_files = true); TORCH_API Module load( std::istream& in, std::optional device, ExtraFilesMap& extra_files, bool load_debug_files = true); /// 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, std::optional device = std::nullopt, bool load_debug_files = true); TORCH_API Module load( const std::string& filename, std::optional device, ExtraFilesMap& extra_files, bool load_debug_files = true); /// Loads a serialized `Module` from the given shared_ptr `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::shared_ptr rai, std::optional device = std::nullopt, bool load_debug_files = true); TORCH_API Module load( std::shared_ptr rai, std::optional device, ExtraFilesMap& extra_files, bool load_debug_files = true); TORCH_API Module jitModuleFromSourceAndConstants( const IValue& ivalue, const ExtraFilesMap& source, const std::vector& constants, int32_t version); TORCH_API Module parse_and_initialize_jit_module( const std::shared_ptr& data, size_t size, ExtraFilesMap& extra_files, std::optional device = std::nullopt); TORCH_API Module load_jit_module_from_file( const std::string& filename, ExtraFilesMap& extra_files, std::optional device = std::nullopt); TORCH_API Module load_jit_module_from_stream( std::istream& in, ExtraFilesMap& extra_files, std::optional device = std::nullopt); TORCH_API Module parse_and_initialize_jit_module( const std::shared_ptr& data, size_t size, ExtraFilesMap& extra_files, std::optional device); TORCH_API c10::intrusive_ptr ObjLoaderFunc( const at::StrongTypePtr& type, IValue input); } // namespace torch::jit