File: torch.proto

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 (114 lines) | stat: -rw-r--r-- 3,188 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
syntax = "proto2";

import "caffe2/proto/caffe2.proto";

package torch;

message RecordRef {
  optional string key = 1;
}

message TensorDef {
  repeated int64 dims = 1;
  optional int64 offset = 2;
  repeated int64 strides = 3;
  // whether we compute the gradient for the parameter
  optional bool requires_grad = 4;
  optional caffe2.TensorProto.DataType data_type = 5;

  optional RecordRef data = 6;

  // device field stores the canonical device string, and it follows the
  // format below: `(cpu|cuda)[:<device-index>]`, e.g., 'cuda:0'
  optional string device = 7;

  optional bool is_quantized = 8;
  optional double scale = 9;
  optional int64 zero_point = 10;
}

message AttributeDef {
  // The mypy type of this attribute
  required string type = 1;
  required string name = 2;

  // Offset into attribute table
  required int64 id = 3;
}

message ParameterDef {
  // whether this parameter is registered as buffer or not
  optional bool is_buffer = 1;

  // the offset into the tensor table where this parameter is stored
  optional int64 tensor_id = 2;

  optional string name = 3;
}

message ModuleDef {
  repeated ModuleDef submodules = 1;

  optional RecordRef torchscript_arena = 2;

  repeated caffe2.NetDef caffe2_nets = 3;

  // because the old pickle modules may not be supported by torch_script,
  // have to stored as pickle_arena at this moment.
  optional RecordRef pickle_arena = 4;
  // should be exposed by the Class Archive, so user can save
  // module specific data which cannot be store in the graph or torch_script
  optional RecordRef cpp_arena = 5;

  // the parameters of this module
  repeated ParameterDef parameters = 6;

  // the names of inputs and outputs of the module are inferred
  // from the main method.

  optional string name = 7;

  // whether apply the optimizations to this module, only applicable to
  // script modules
  optional bool optimize = 8;

  repeated AttributeDef attributes = 9;

  // Used for retrieving module state from the pickled IValues table
  optional int64 get_state_attribute_id = 10;

  optional RecordRef torchscript_debug_arena = 11;
}

// Represents all non-module code that the model depends on.
// Right now it's just a straight list of classes, defined in dependency order
// (i.e. dependencies appear before their dependers)
message LibDef {
  optional RecordRef torchscript_arena = 1;
}

enum ProtoVersion { PROTO_VERSION_NEWEST = 0x0000000000000006; }

message ModelDef {
  // numbers of fields that have been removed. Do not reuse them!
  reserved 9;
  reserved "libs";
  // for the proto version, to keep both backward and forward
  // compatibility, please bump the proto_version when we add any
  // change in the proto. runtime decides whether accept the
  // model based on the ir_version.
  optional int64 proto_version = 1;

  // main module of the model
  optional ModuleDef main_module = 2;

  // to distinguish whether exported from c2 or torch
  optional string producer_name = 3;

  // put build version here
  optional string producer_version = 4;

  // the table contains all the tensor information
  // the tensor id is defined as TensorProto.name
  repeated TensorDef tensors = 5;
}