pytorch-proto.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976
  1. export const torch = {};
  2. export const caffe2 = {};
  3. torch.RecordRef = class RecordRef {
  4. static decodeJson(obj) {
  5. const message = new torch.RecordRef();
  6. if ('key' in obj) {
  7. message.key = obj.key;
  8. }
  9. return message;
  10. }
  11. };
  12. torch.RecordRef.prototype.key = "";
  13. torch.TensorDef = class TensorDef {
  14. constructor() {
  15. this.dims = [];
  16. this.strides = [];
  17. }
  18. static decodeJson(obj) {
  19. const message = new torch.TensorDef();
  20. if ('dims' in obj) {
  21. message.dims = obj.dims.map((obj) => BigInt(obj));
  22. }
  23. if ('offset' in obj) {
  24. message.offset = BigInt(obj.offset);
  25. }
  26. if ('strides' in obj) {
  27. message.strides = obj.strides.map((obj) => BigInt(obj));
  28. }
  29. if ('requiresGrad' in obj) {
  30. message.requires_grad = obj.requiresGrad;
  31. }
  32. if ('dataType' in obj) {
  33. message.data_type = typeof obj.dataType === 'string' ? caffe2.TensorProto.DataType[obj.dataType] : obj.dataType;
  34. }
  35. if ('data' in obj) {
  36. message.data = torch.RecordRef.decodeJson(obj.data);
  37. }
  38. if ('device' in obj) {
  39. message.device = obj.device;
  40. }
  41. if ('isQuantized' in obj) {
  42. message.is_quantized = obj.isQuantized;
  43. }
  44. if ('scale' in obj) {
  45. message.scale = Number(obj.scale);
  46. }
  47. if ('zeroPoint' in obj) {
  48. message.zero_point = BigInt(obj.zeroPoint);
  49. }
  50. return message;
  51. }
  52. };
  53. torch.TensorDef.prototype.offset = 0n;
  54. torch.TensorDef.prototype.requires_grad = false;
  55. torch.TensorDef.prototype.data_type = 0;
  56. torch.TensorDef.prototype.data = null;
  57. torch.TensorDef.prototype.device = "";
  58. torch.TensorDef.prototype.is_quantized = false;
  59. torch.TensorDef.prototype.scale = 0;
  60. torch.TensorDef.prototype.zero_point = 0n;
  61. torch.AttributeDef = class AttributeDef {
  62. static decodeJson(obj) {
  63. const message = new torch.AttributeDef();
  64. message.type = obj.type;
  65. message.name = obj.name;
  66. message.id = BigInt(obj.id);
  67. return message;
  68. }
  69. };
  70. torch.AttributeDef.prototype.type = "";
  71. torch.AttributeDef.prototype.name = "";
  72. torch.AttributeDef.prototype.id = 0n;
  73. torch.ParameterDef = class ParameterDef {
  74. static decodeJson(obj) {
  75. const message = new torch.ParameterDef();
  76. if ('isBuffer' in obj) {
  77. message.is_buffer = obj.isBuffer;
  78. }
  79. if ('tensorId' in obj) {
  80. message.tensor_id = BigInt(obj.tensorId);
  81. }
  82. if ('name' in obj) {
  83. message.name = obj.name;
  84. }
  85. return message;
  86. }
  87. };
  88. torch.ParameterDef.prototype.is_buffer = false;
  89. torch.ParameterDef.prototype.tensor_id = 0n;
  90. torch.ParameterDef.prototype.name = "";
  91. torch.ModuleDef = class ModuleDef {
  92. constructor() {
  93. this.submodules = [];
  94. this.caffe2_nets = [];
  95. this.parameters = [];
  96. this.attributes = [];
  97. }
  98. static decodeJson(obj) {
  99. const message = new torch.ModuleDef();
  100. if ('submodules' in obj) {
  101. message.submodules = obj.submodules.map((obj) => torch.ModuleDef.decodeJson(obj));
  102. }
  103. if ('torchscriptArena' in obj) {
  104. message.torchscript_arena = torch.RecordRef.decodeJson(obj.torchscriptArena);
  105. }
  106. if ('caffe2Nets' in obj) {
  107. message.caffe2_nets = obj.caffe2Nets.map((obj) => caffe2.NetDef.decodeJson(obj));
  108. }
  109. if ('pickleArena' in obj) {
  110. message.pickle_arena = torch.RecordRef.decodeJson(obj.pickleArena);
  111. }
  112. if ('cppArena' in obj) {
  113. message.cpp_arena = torch.RecordRef.decodeJson(obj.cppArena);
  114. }
  115. if ('parameters' in obj) {
  116. message.parameters = obj.parameters.map((obj) => torch.ParameterDef.decodeJson(obj));
  117. }
  118. if ('name' in obj) {
  119. message.name = obj.name;
  120. }
  121. if ('optimize' in obj) {
  122. message.optimize = obj.optimize;
  123. }
  124. if ('attributes' in obj) {
  125. message.attributes = obj.attributes.map((obj) => torch.AttributeDef.decodeJson(obj));
  126. }
  127. if ('getStateAttributeId' in obj) {
  128. message.get_state_attribute_id = BigInt(obj.getStateAttributeId);
  129. }
  130. if ('torchscriptDebugArena' in obj) {
  131. message.torchscript_debug_arena = torch.RecordRef.decodeJson(obj.torchscriptDebugArena);
  132. }
  133. return message;
  134. }
  135. };
  136. torch.ModuleDef.prototype.torchscript_arena = null;
  137. torch.ModuleDef.prototype.pickle_arena = null;
  138. torch.ModuleDef.prototype.cpp_arena = null;
  139. torch.ModuleDef.prototype.name = "";
  140. torch.ModuleDef.prototype.optimize = false;
  141. torch.ModuleDef.prototype.get_state_attribute_id = 0n;
  142. torch.ModuleDef.prototype.torchscript_debug_arena = null;
  143. torch.LibDef = class LibDef {
  144. static decodeJson(obj) {
  145. const message = new torch.LibDef();
  146. if ('torchscriptArena' in obj) {
  147. message.torchscript_arena = torch.RecordRef.decodeJson(obj.torchscriptArena);
  148. }
  149. return message;
  150. }
  151. };
  152. torch.LibDef.prototype.torchscript_arena = null;
  153. torch.ProtoVersion = {
  154. "PROTO_VERSION_NEWEST": 6
  155. };
  156. torch.ModelDef = class ModelDef {
  157. constructor() {
  158. this.tensors = [];
  159. }
  160. static decodeJson(obj) {
  161. const message = new torch.ModelDef();
  162. if ('protoVersion' in obj) {
  163. message.proto_version = BigInt(obj.protoVersion);
  164. }
  165. if ('mainModule' in obj) {
  166. message.main_module = torch.ModuleDef.decodeJson(obj.mainModule);
  167. }
  168. if ('producerName' in obj) {
  169. message.producer_name = obj.producerName;
  170. }
  171. if ('producerVersion' in obj) {
  172. message.producer_version = obj.producerVersion;
  173. }
  174. if ('tensors' in obj) {
  175. message.tensors = obj.tensors.map((obj) => torch.TensorDef.decodeJson(obj));
  176. }
  177. return message;
  178. }
  179. };
  180. torch.ModelDef.prototype.proto_version = 0n;
  181. torch.ModelDef.prototype.main_module = null;
  182. torch.ModelDef.prototype.producer_name = "";
  183. torch.ModelDef.prototype.producer_version = "";
  184. caffe2.TensorProto = class TensorProto {
  185. constructor() {
  186. this.dims = [];
  187. this.float_data = [];
  188. this.int32_data = [];
  189. this.string_data = [];
  190. this.double_data = [];
  191. this.int64_data = [];
  192. }
  193. static decodeJson(obj) {
  194. const message = new caffe2.TensorProto();
  195. if ('dims' in obj) {
  196. message.dims = obj.dims.map((obj) => BigInt(obj));
  197. }
  198. if ('dataType' in obj) {
  199. message.data_type = typeof obj.dataType === 'string' ? caffe2.TensorProto.DataType[obj.dataType] : obj.dataType;
  200. }
  201. if ('dataFormat' in obj) {
  202. message.data_format = Number(obj.dataFormat);
  203. }
  204. if ('floatData' in obj) {
  205. message.float_data = obj.floatData.map((obj) => Number(obj));
  206. }
  207. if ('int32Data' in obj) {
  208. message.int32_data = obj.int32Data.map((obj) => Number(obj));
  209. }
  210. if ('byteData' in obj) {
  211. message.byte_data = typeof obj.byteData === 'string' ? Uint8Array.from(atob(obj.byteData), (c) => c.charCodeAt(0)) : Uint8Array.from(obj.byteData);
  212. }
  213. if ('stringData' in obj) {
  214. message.string_data = obj.stringData.map((obj) => typeof obj === 'string' ? Uint8Array.from(atob(obj), (c) => c.charCodeAt(0)) : Uint8Array.from(obj));
  215. }
  216. if ('doubleData' in obj) {
  217. message.double_data = obj.doubleData.map((obj) => Number(obj));
  218. }
  219. if ('int64Data' in obj) {
  220. message.int64_data = obj.int64Data.map((obj) => BigInt(obj));
  221. }
  222. if ('rawData' in obj) {
  223. message.raw_data = typeof obj.rawData === 'string' ? Uint8Array.from(atob(obj.rawData), (c) => c.charCodeAt(0)) : Uint8Array.from(obj.rawData);
  224. }
  225. if ('name' in obj) {
  226. message.name = obj.name;
  227. }
  228. if ('deviceDetail' in obj) {
  229. message.device_detail = caffe2.DeviceOption.decodeJson(obj.deviceDetail);
  230. }
  231. if ('segment' in obj) {
  232. message.segment = caffe2.TensorProto.Segment.decodeJson(obj.segment);
  233. }
  234. return message;
  235. }
  236. };
  237. caffe2.TensorProto.prototype.data_type = 1;
  238. caffe2.TensorProto.prototype.data_format = 0;
  239. caffe2.TensorProto.prototype.byte_data = new Uint8Array([]);
  240. caffe2.TensorProto.prototype.raw_data = new Uint8Array([]);
  241. caffe2.TensorProto.prototype.name = "";
  242. caffe2.TensorProto.prototype.device_detail = null;
  243. caffe2.TensorProto.prototype.segment = null;
  244. caffe2.TensorProto.DataType = {
  245. "UNDEFINED": 0,
  246. "FLOAT": 1,
  247. "INT32": 2,
  248. "BYTE": 3,
  249. "STRING": 4,
  250. "BOOL": 5,
  251. "UINT8": 6,
  252. "INT8": 7,
  253. "UINT16": 8,
  254. "INT16": 9,
  255. "INT64": 10,
  256. "FLOAT16": 12,
  257. "DOUBLE": 13,
  258. "ZERO_COLLISION_HASH": 14,
  259. "REBATCHING_BUFFER": 15
  260. };
  261. caffe2.TensorProto.SerializationFormat = {
  262. "FMT_PROTOBUF": 0,
  263. "FMT_BFLOAT16": 1
  264. };
  265. caffe2.TensorProto.Segment = class Segment {
  266. static decodeJson(obj) {
  267. const message = new caffe2.TensorProto.Segment();
  268. message.begin = BigInt(obj.begin);
  269. message.end = BigInt(obj.end);
  270. return message;
  271. }
  272. };
  273. caffe2.TensorProto.Segment.prototype.begin = 0n;
  274. caffe2.TensorProto.Segment.prototype.end = 0n;
  275. caffe2.QTensorProto = class QTensorProto {
  276. constructor() {
  277. this.dims = [];
  278. this.data = [];
  279. this.scales = [];
  280. this.biases = [];
  281. }
  282. static decodeJson(obj) {
  283. const message = new caffe2.QTensorProto();
  284. if ('dims' in obj) {
  285. message.dims = obj.dims.map((obj) => BigInt(obj));
  286. }
  287. message.precision = Number(obj.precision);
  288. message.scale = Number(obj.scale);
  289. message.bias = Number(obj.bias);
  290. message.is_signed = obj.isSigned;
  291. if ('data' in obj) {
  292. message.data = obj.data.map((obj) => Number(obj));
  293. }
  294. if ('name' in obj) {
  295. message.name = obj.name;
  296. }
  297. if ('dataType' in obj) {
  298. message.data_type = typeof obj.dataType === 'string' ? caffe2.TensorProto.DataType[obj.dataType] : obj.dataType;
  299. }
  300. if ('scales' in obj) {
  301. message.scales = obj.scales.map((obj) => Number(obj));
  302. }
  303. if ('biases' in obj) {
  304. message.biases = obj.biases.map((obj) => Number(obj));
  305. }
  306. if ('axis' in obj) {
  307. message.axis = Number(obj.axis);
  308. }
  309. if ('isMultiparam' in obj) {
  310. message.is_multiparam = obj.isMultiparam;
  311. }
  312. return message;
  313. }
  314. };
  315. caffe2.QTensorProto.prototype.precision = 0;
  316. caffe2.QTensorProto.prototype.scale = 0;
  317. caffe2.QTensorProto.prototype.bias = 0;
  318. caffe2.QTensorProto.prototype.is_signed = false;
  319. caffe2.QTensorProto.prototype.name = "";
  320. caffe2.QTensorProto.prototype.data_type = 2;
  321. caffe2.QTensorProto.prototype.axis = 0;
  322. caffe2.QTensorProto.prototype.is_multiparam = false;
  323. caffe2.TensorProtos = class TensorProtos {
  324. constructor() {
  325. this.protos = [];
  326. }
  327. static decodeJson(obj) {
  328. const message = new caffe2.TensorProtos();
  329. if ('protos' in obj) {
  330. message.protos = obj.protos.map((obj) => caffe2.TensorProto.decodeJson(obj));
  331. }
  332. return message;
  333. }
  334. };
  335. caffe2.TensorShape = class TensorShape {
  336. constructor() {
  337. this.dims = [];
  338. this.unknown_dims = [];
  339. }
  340. static decodeJson(obj) {
  341. const message = new caffe2.TensorShape();
  342. if ('dims' in obj) {
  343. message.dims = obj.dims.map((obj) => BigInt(obj));
  344. }
  345. if ('dataType' in obj) {
  346. message.data_type = typeof obj.dataType === 'string' ? caffe2.TensorProto.DataType[obj.dataType] : obj.dataType;
  347. }
  348. if ('unknownDims' in obj) {
  349. message.unknown_dims = obj.unknownDims.map((obj) => Number(obj));
  350. }
  351. if ('unknownShape' in obj) {
  352. message.unknown_shape = obj.unknownShape;
  353. }
  354. if ('name' in obj) {
  355. message.name = obj.name;
  356. }
  357. return message;
  358. }
  359. };
  360. caffe2.TensorShape.prototype.data_type = 1;
  361. caffe2.TensorShape.prototype.unknown_shape = false;
  362. caffe2.TensorShape.prototype.name = "";
  363. caffe2.TensorShapes = class TensorShapes {
  364. constructor() {
  365. this.shapes = [];
  366. }
  367. static decodeJson(obj) {
  368. const message = new caffe2.TensorShapes();
  369. if ('shapes' in obj) {
  370. message.shapes = obj.shapes.map((obj) => caffe2.TensorShape.decodeJson(obj));
  371. }
  372. return message;
  373. }
  374. };
  375. caffe2.TensorBoundShape = class TensorBoundShape {
  376. constructor() {
  377. this.dim_type = [];
  378. }
  379. static decodeJson(obj) {
  380. const message = new caffe2.TensorBoundShape();
  381. if ('shape' in obj) {
  382. message.shape = caffe2.TensorShape.decodeJson(obj.shape);
  383. }
  384. if ('dimType' in obj) {
  385. message.dim_type = obj.dimType.map((key) => typeof key === 'string' ? caffe2.TensorBoundShape.DimType[key] : key);
  386. }
  387. if ('name' in obj) {
  388. message.name = obj.name;
  389. }
  390. if ('shapeIsFinal' in obj) {
  391. message.shape_is_final = obj.shapeIsFinal;
  392. }
  393. return message;
  394. }
  395. };
  396. caffe2.TensorBoundShape.prototype.shape = null;
  397. caffe2.TensorBoundShape.prototype.name = "";
  398. caffe2.TensorBoundShape.prototype.shape_is_final = false;
  399. caffe2.TensorBoundShape.DimType = {
  400. "UNKNOWN": 0,
  401. "CONSTANT": 1,
  402. "BATCH": 2,
  403. "BATCH_OF_FEATURE_MAX": 3,
  404. "BATCH_OF_FEATURE_MAX_DEFAULT": 4,
  405. "FEATURE_MAX": 5,
  406. "FEATURE_MAX_DEFAULT": 6
  407. };
  408. caffe2.TensorBoundShapes = class TensorBoundShapes {
  409. constructor() {
  410. this.shapes = [];
  411. }
  412. static decodeJson(obj) {
  413. const message = new caffe2.TensorBoundShapes();
  414. if ('shapes' in obj) {
  415. message.shapes = obj.shapes.map((obj) => caffe2.TensorBoundShape.decodeJson(obj));
  416. }
  417. if ('maxBatchSize' in obj) {
  418. message.max_batch_size = BigInt(obj.maxBatchSize);
  419. }
  420. if ('maxFeatureLen' in obj) {
  421. message.max_feature_len = BigInt(obj.maxFeatureLen);
  422. }
  423. return message;
  424. }
  425. };
  426. caffe2.TensorBoundShapes.prototype.max_batch_size = 0n;
  427. caffe2.TensorBoundShapes.prototype.max_feature_len = 0n;
  428. caffe2.AOTConfig = class AOTConfig {
  429. static decodeJson(obj) {
  430. const message = new caffe2.AOTConfig();
  431. message.max_batch_size = BigInt(obj.maxBatchSize);
  432. message.max_seq_size = BigInt(obj.maxSeqSize);
  433. message.in_batch_broadcast = obj.inBatchBroadcast;
  434. if ('onnxifiBlacklistOps' in obj) {
  435. message.onnxifi_blacklist_ops = obj.onnxifiBlacklistOps;
  436. }
  437. if ('onnxifiMinOps' in obj) {
  438. message.onnxifi_min_ops = Number(obj.onnxifiMinOps);
  439. }
  440. return message;
  441. }
  442. };
  443. caffe2.AOTConfig.prototype.max_batch_size = 0n;
  444. caffe2.AOTConfig.prototype.max_seq_size = 0n;
  445. caffe2.AOTConfig.prototype.in_batch_broadcast = false;
  446. caffe2.AOTConfig.prototype.onnxifi_blacklist_ops = "";
  447. caffe2.AOTConfig.prototype.onnxifi_min_ops = 0;
  448. caffe2.Argument = class Argument {
  449. constructor() {
  450. this.floats = [];
  451. this.ints = [];
  452. this.strings = [];
  453. this.tensors = [];
  454. this.nets = [];
  455. this.qtensors = [];
  456. }
  457. static decodeJson(obj) {
  458. const message = new caffe2.Argument();
  459. if ('name' in obj) {
  460. message.name = obj.name;
  461. }
  462. if ('f' in obj) {
  463. message.f = Number(obj.f);
  464. }
  465. if ('i' in obj) {
  466. message.i = BigInt(obj.i);
  467. }
  468. if ('s' in obj) {
  469. message.s = typeof obj.s === 'string' ? Uint8Array.from(atob(obj.s), (c) => c.charCodeAt(0)) : Uint8Array.from(obj.s);
  470. }
  471. if ('t' in obj) {
  472. message.t = caffe2.TensorProto.decodeJson(obj.t);
  473. }
  474. if ('n' in obj) {
  475. message.n = caffe2.NetDef.decodeJson(obj.n);
  476. }
  477. if ('floats' in obj) {
  478. message.floats = obj.floats.map((obj) => Number(obj));
  479. }
  480. if ('ints' in obj) {
  481. message.ints = obj.ints.map((obj) => BigInt(obj));
  482. }
  483. if ('strings' in obj) {
  484. message.strings = obj.strings.map((obj) => typeof obj === 'string' ? Uint8Array.from(atob(obj), (c) => c.charCodeAt(0)) : Uint8Array.from(obj));
  485. }
  486. if ('tensors' in obj) {
  487. message.tensors = obj.tensors.map((obj) => caffe2.TensorProto.decodeJson(obj));
  488. }
  489. if ('nets' in obj) {
  490. message.nets = obj.nets.map((obj) => caffe2.NetDef.decodeJson(obj));
  491. }
  492. if ('qtensors' in obj) {
  493. message.qtensors = obj.qtensors.map((obj) => caffe2.QTensorProto.decodeJson(obj));
  494. }
  495. return message;
  496. }
  497. };
  498. caffe2.Argument.prototype.name = "";
  499. caffe2.Argument.prototype.f = 0;
  500. caffe2.Argument.prototype.i = 0n;
  501. caffe2.Argument.prototype.s = new Uint8Array([]);
  502. caffe2.Argument.prototype.t = null;
  503. caffe2.Argument.prototype.n = null;
  504. caffe2.DeviceTypeProto = {
  505. "PROTO_CPU": 0,
  506. "PROTO_CUDA": 1,
  507. "PROTO_MKLDNN": 2,
  508. "PROTO_OPENGL": 3,
  509. "PROTO_OPENCL": 4,
  510. "PROTO_IDEEP": 5,
  511. "PROTO_HIP": 6,
  512. "PROTO_FPGA": 7,
  513. "PROTO_MAIA": 8,
  514. "PROTO_XLA": 9,
  515. "PROTO_MPS": 10,
  516. "PROTO_COMPILE_TIME_MAX_DEVICE_TYPES": 11
  517. };
  518. caffe2.DeviceOption = class DeviceOption {
  519. constructor() {
  520. this.extra_info = [];
  521. }
  522. static decodeJson(obj) {
  523. const message = new caffe2.DeviceOption();
  524. if ('deviceType' in obj) {
  525. message.device_type = Number(obj.deviceType);
  526. }
  527. if ('deviceId' in obj) {
  528. message.device_id = Number(obj.deviceId);
  529. }
  530. if ('randomSeed' in obj) {
  531. message.random_seed = Number(obj.randomSeed);
  532. }
  533. if ('nodeName' in obj) {
  534. message.node_name = obj.nodeName;
  535. }
  536. if ('numaNodeId' in obj) {
  537. message.numa_node_id = Number(obj.numaNodeId);
  538. }
  539. if ('extraInfo' in obj) {
  540. message.extra_info = obj.extraInfo;
  541. }
  542. return message;
  543. }
  544. };
  545. caffe2.DeviceOption.prototype.device_type = 0;
  546. caffe2.DeviceOption.prototype.device_id = 0;
  547. caffe2.DeviceOption.prototype.random_seed = 0;
  548. caffe2.DeviceOption.prototype.node_name = "";
  549. caffe2.DeviceOption.prototype.numa_node_id = 0;
  550. caffe2.OperatorDef = class OperatorDef {
  551. constructor() {
  552. this.input = [];
  553. this.output = [];
  554. this.arg = [];
  555. this.control_input = [];
  556. }
  557. static decodeJson(obj) {
  558. const message = new caffe2.OperatorDef();
  559. if ('input' in obj) {
  560. message.input = obj.input;
  561. }
  562. if ('output' in obj) {
  563. message.output = obj.output;
  564. }
  565. if ('name' in obj) {
  566. message.name = obj.name;
  567. }
  568. if ('type' in obj) {
  569. message.type = obj.type;
  570. }
  571. if ('arg' in obj) {
  572. message.arg = obj.arg.map((obj) => caffe2.Argument.decodeJson(obj));
  573. }
  574. if ('deviceOption' in obj) {
  575. message.device_option = caffe2.DeviceOption.decodeJson(obj.deviceOption);
  576. }
  577. if ('engine' in obj) {
  578. message.engine = obj.engine;
  579. }
  580. if ('controlInput' in obj) {
  581. message.control_input = obj.controlInput;
  582. }
  583. if ('isGradientOp' in obj) {
  584. message.is_gradient_op = obj.isGradientOp;
  585. }
  586. if ('debugInfo' in obj) {
  587. message.debug_info = obj.debugInfo;
  588. }
  589. if ('domain' in obj) {
  590. message.domain = obj.domain;
  591. }
  592. if ('opVersion' in obj) {
  593. message.op_version = BigInt(obj.opVersion);
  594. }
  595. return message;
  596. }
  597. };
  598. caffe2.OperatorDef.prototype.name = "";
  599. caffe2.OperatorDef.prototype.type = "";
  600. caffe2.OperatorDef.prototype.device_option = null;
  601. caffe2.OperatorDef.prototype.engine = "";
  602. caffe2.OperatorDef.prototype.is_gradient_op = false;
  603. caffe2.OperatorDef.prototype.debug_info = "";
  604. caffe2.OperatorDef.prototype.domain = "";
  605. caffe2.OperatorDef.prototype.op_version = 0n;
  606. caffe2.MapFieldEntry = class MapFieldEntry {
  607. static decodeJson(obj) {
  608. const message = new caffe2.MapFieldEntry();
  609. message.key = obj.key;
  610. message.val = obj.val;
  611. return message;
  612. }
  613. };
  614. caffe2.MapFieldEntry.prototype.key = "";
  615. caffe2.MapFieldEntry.prototype.val = "";
  616. caffe2.BackendOptions = class BackendOptions {
  617. constructor() {
  618. this.option = [];
  619. }
  620. static decodeJson(obj) {
  621. const message = new caffe2.BackendOptions();
  622. message.backend_name = obj.backendName;
  623. if ('option' in obj) {
  624. message.option = obj.option.map((obj) => caffe2.MapFieldEntry.decodeJson(obj));
  625. }
  626. return message;
  627. }
  628. };
  629. caffe2.BackendOptions.prototype.backend_name = "";
  630. caffe2.PartitionInfo = class PartitionInfo {
  631. constructor() {
  632. this.device_id = [];
  633. this.backend_options = [];
  634. }
  635. static decodeJson(obj) {
  636. const message = new caffe2.PartitionInfo();
  637. message.name = obj.name;
  638. if ('deviceId' in obj) {
  639. message.device_id = obj.deviceId.map((obj) => Number(obj));
  640. }
  641. if ('extraInfo' in obj) {
  642. message.extra_info = obj.extraInfo;
  643. }
  644. if ('backendOptions' in obj) {
  645. message.backend_options = obj.backendOptions.map((obj) => caffe2.BackendOptions.decodeJson(obj));
  646. }
  647. return message;
  648. }
  649. };
  650. caffe2.PartitionInfo.prototype.name = "";
  651. caffe2.PartitionInfo.prototype.extra_info = "";
  652. caffe2.NetDef = class NetDef {
  653. constructor() {
  654. this.op = [];
  655. this.arg = [];
  656. this.external_input = [];
  657. this.external_output = [];
  658. this.partition_info = [];
  659. }
  660. static decodeJson(obj) {
  661. const message = new caffe2.NetDef();
  662. if ('name' in obj) {
  663. message.name = obj.name;
  664. }
  665. if ('op' in obj) {
  666. message.op = obj.op.map((obj) => caffe2.OperatorDef.decodeJson(obj));
  667. }
  668. if ('type' in obj) {
  669. message.type = obj.type;
  670. }
  671. if ('numWorkers' in obj) {
  672. message.num_workers = Number(obj.numWorkers);
  673. }
  674. if ('deviceOption' in obj) {
  675. message.device_option = caffe2.DeviceOption.decodeJson(obj.deviceOption);
  676. }
  677. if ('arg' in obj) {
  678. message.arg = obj.arg.map((obj) => caffe2.Argument.decodeJson(obj));
  679. }
  680. if ('externalInput' in obj) {
  681. message.external_input = obj.externalInput;
  682. }
  683. if ('externalOutput' in obj) {
  684. message.external_output = obj.externalOutput;
  685. }
  686. if ('partitionInfo' in obj) {
  687. message.partition_info = obj.partitionInfo.map((obj) => caffe2.PartitionInfo.decodeJson(obj));
  688. }
  689. return message;
  690. }
  691. };
  692. caffe2.NetDef.prototype.name = "";
  693. caffe2.NetDef.prototype.type = "";
  694. caffe2.NetDef.prototype.num_workers = 0;
  695. caffe2.NetDef.prototype.device_option = null;
  696. caffe2.ExecutionStep = class ExecutionStep {
  697. constructor() {
  698. this.substep = [];
  699. this.network = [];
  700. }
  701. static decodeJson(obj) {
  702. const message = new caffe2.ExecutionStep();
  703. if ('name' in obj) {
  704. message.name = obj.name;
  705. }
  706. if ('substep' in obj) {
  707. message.substep = obj.substep.map((obj) => caffe2.ExecutionStep.decodeJson(obj));
  708. }
  709. if ('network' in obj) {
  710. message.network = obj.network;
  711. }
  712. if ('numIter' in obj) {
  713. message.num_iter = BigInt(obj.numIter);
  714. }
  715. if ('criteriaNetwork' in obj) {
  716. message.criteria_network = obj.criteriaNetwork;
  717. }
  718. if ('reportNet' in obj) {
  719. message.report_net = obj.reportNet;
  720. }
  721. if ('reportInterval' in obj) {
  722. message.report_interval = Number(obj.reportInterval);
  723. }
  724. if ('runEveryMs' in obj) {
  725. message.run_every_ms = BigInt(obj.runEveryMs);
  726. }
  727. if ('concurrentSubsteps' in obj) {
  728. message.concurrent_substeps = obj.concurrentSubsteps;
  729. }
  730. if ('shouldStopBlob' in obj) {
  731. message.should_stop_blob = obj.shouldStopBlob;
  732. }
  733. if ('onlyOnce' in obj) {
  734. message.only_once = obj.onlyOnce;
  735. }
  736. if ('createWorkspace' in obj) {
  737. message.create_workspace = obj.createWorkspace;
  738. }
  739. if ('numConcurrentInstances' in obj) {
  740. message.num_concurrent_instances = Number(obj.numConcurrentInstances);
  741. }
  742. return message;
  743. }
  744. };
  745. caffe2.ExecutionStep.prototype.name = "";
  746. caffe2.ExecutionStep.prototype.num_iter = 0n;
  747. caffe2.ExecutionStep.prototype.criteria_network = "";
  748. caffe2.ExecutionStep.prototype.report_net = "";
  749. caffe2.ExecutionStep.prototype.report_interval = 0;
  750. caffe2.ExecutionStep.prototype.run_every_ms = 0n;
  751. caffe2.ExecutionStep.prototype.concurrent_substeps = false;
  752. caffe2.ExecutionStep.prototype.should_stop_blob = "";
  753. caffe2.ExecutionStep.prototype.only_once = false;
  754. caffe2.ExecutionStep.prototype.create_workspace = false;
  755. caffe2.ExecutionStep.prototype.num_concurrent_instances = 0;
  756. caffe2.PlanDef = class PlanDef {
  757. constructor() {
  758. this.network = [];
  759. this.execution_step = [];
  760. }
  761. static decodeJson(obj) {
  762. const message = new caffe2.PlanDef();
  763. if ('name' in obj) {
  764. message.name = obj.name;
  765. }
  766. if ('network' in obj) {
  767. message.network = obj.network.map((obj) => caffe2.NetDef.decodeJson(obj));
  768. }
  769. if ('executionStep' in obj) {
  770. message.execution_step = obj.executionStep.map((obj) => caffe2.ExecutionStep.decodeJson(obj));
  771. }
  772. return message;
  773. }
  774. };
  775. caffe2.PlanDef.prototype.name = "";
  776. caffe2.BlobProto = class BlobProto {
  777. static decodeJson(obj) {
  778. const message = new caffe2.BlobProto();
  779. if ('name' in obj) {
  780. message.name = obj.name;
  781. }
  782. if ('type' in obj) {
  783. message.type = obj.type;
  784. }
  785. if ('tensor' in obj) {
  786. message.tensor = caffe2.TensorProto.decodeJson(obj.tensor);
  787. }
  788. if ('content' in obj) {
  789. message.content = typeof obj.content === 'string' ? Uint8Array.from(atob(obj.content), (c) => c.charCodeAt(0)) : Uint8Array.from(obj.content);
  790. }
  791. if ('qtensor' in obj) {
  792. message.qtensor = caffe2.QTensorProto.decodeJson(obj.qtensor);
  793. }
  794. if ('contentNumChunks' in obj) {
  795. message.content_num_chunks = Number(obj.contentNumChunks);
  796. }
  797. if ('contentChunkId' in obj) {
  798. message.content_chunk_id = Number(obj.contentChunkId);
  799. }
  800. return message;
  801. }
  802. };
  803. caffe2.BlobProto.prototype.name = "";
  804. caffe2.BlobProto.prototype.type = "";
  805. caffe2.BlobProto.prototype.tensor = null;
  806. caffe2.BlobProto.prototype.content = new Uint8Array([]);
  807. caffe2.BlobProto.prototype.qtensor = null;
  808. caffe2.BlobProto.prototype.content_num_chunks = 0;
  809. caffe2.BlobProto.prototype.content_chunk_id = 0;
  810. caffe2.DBReaderProto = class DBReaderProto {
  811. static decodeJson(obj) {
  812. const message = new caffe2.DBReaderProto();
  813. if ('name' in obj) {
  814. message.name = obj.name;
  815. }
  816. if ('source' in obj) {
  817. message.source = obj.source;
  818. }
  819. if ('dbType' in obj) {
  820. message.db_type = obj.dbType;
  821. }
  822. if ('key' in obj) {
  823. message.key = obj.key;
  824. }
  825. return message;
  826. }
  827. };
  828. caffe2.DBReaderProto.prototype.name = "";
  829. caffe2.DBReaderProto.prototype.source = "";
  830. caffe2.DBReaderProto.prototype.db_type = "";
  831. caffe2.DBReaderProto.prototype.key = "";
  832. caffe2.BlobSerializationOptions = class BlobSerializationOptions {
  833. static decodeJson(obj) {
  834. const message = new caffe2.BlobSerializationOptions();
  835. if ('blobNameRegex' in obj) {
  836. message.blob_name_regex = obj.blobNameRegex;
  837. }
  838. if ('chunkSize' in obj) {
  839. message.chunk_size = BigInt(obj.chunkSize);
  840. }
  841. if ('floatFormat' in obj) {
  842. message.float_format = typeof obj.floatFormat === 'string' ? caffe2.BlobSerializationOptions.FloatFormat[obj.floatFormat] : obj.floatFormat;
  843. }
  844. return message;
  845. }
  846. };
  847. caffe2.BlobSerializationOptions.prototype.blob_name_regex = "";
  848. caffe2.BlobSerializationOptions.prototype.chunk_size = 0n;
  849. caffe2.BlobSerializationOptions.prototype.float_format = 0;
  850. caffe2.BlobSerializationOptions.FloatFormat = {
  851. "FLOAT_DEFAULT": 0,
  852. "FLOAT_PROTOBUF": 1,
  853. "FLOAT_BFLOAT16": 2
  854. };
  855. caffe2.SerializationOptions = class SerializationOptions {
  856. constructor() {
  857. this.options = [];
  858. }
  859. static decodeJson(obj) {
  860. const message = new caffe2.SerializationOptions();
  861. if ('options' in obj) {
  862. message.options = obj.options.map((obj) => caffe2.BlobSerializationOptions.decodeJson(obj));
  863. }
  864. return message;
  865. }
  866. };