File: export_data.h

package info (click to toggle)
pytorch 1.13.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 139,252 kB
  • sloc: cpp: 1,100,274; python: 706,454; ansic: 83,052; asm: 7,618; java: 3,273; sh: 2,841; javascript: 612; makefile: 323; xml: 269; ruby: 185; yacc: 144; objc: 68; lex: 44
file content (53 lines) | stat: -rw-r--r-- 1,619 bytes parent folder | download
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
#pragma once

#include <torch/csrc/jit/mobile/module.h>

namespace torch {
namespace 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<std::string, at::Tensor>& 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<std::string, at::Tensor>& 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<std::string, at::Tensor>& dict);

c10::Dict<std::string, at::Tensor> tensor_map_to_dict(
    const std::map<std::string, at::Tensor>& map);

} // namespace mobile

extern void (*_save_mobile_module_to)(
    const mobile::Module& module,
    const std::function<size_t(const void*, size_t)>& writer_func);

} // namespace jit
} // namespace torch