File: export_data.h

package info (click to toggle)
pytorch-cuda 2.6.0%2Bdfsg-7
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid, trixie
  • size: 161,620 kB
  • sloc: python: 1,278,832; cpp: 900,322; ansic: 82,710; asm: 7,754; java: 3,363; sh: 2,811; javascript: 2,443; makefile: 597; ruby: 195; xml: 84; objc: 68
file content (51 lines) | stat: -rw-r--r-- 1,594 bytes parent folder | download | duplicates (3)
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
#pragma once

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

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<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 torch::jit