#pragma once #include namespace torch::jit { /** * Serializes the provided tensor map to the provided stream. * * @param[in] map The tensors to serialize. * @param[in] out The stream to write the serialized data to. * @param[in] use_flatbuffer If true, use Flatbuffers to serialize the data. * If false, use Pickle. */ TORCH_API void _save_parameters( const std::map& map, std::ostream& out, bool use_flatbuffer = false); /** * Serializes the provided tensor map to a file. * * @param[in] map The tensors to serialize. * @param[in] filename The stem of the file name to write to. If * @p use_flatbuffer is false, the extension ".pkl" will be appended. If * @p use_flatbuffer is true, the extension ".ff" will be appended. * @param[in] use_flatbuffer If true, use Flatbuffers to serialize the data. * If false, use Pickle. */ TORCH_API void _save_parameters( const std::map& map, const std::string& filename, bool use_flatbuffer = false); namespace mobile { // NOTE: Please prefer using _save_parameters directly over using the 2 // functions below. TORCH_API mobile::Module tensor_dict_to_mobile( const c10::Dict& dict); c10::Dict tensor_map_to_dict( const std::map& map); } // namespace mobile extern void (*_save_mobile_module_to)( const mobile::Module& module, const std::function& writer_func); } // namespace torch::jit