Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
onnx.hxx
Go to the documentation of this file.
1// TMVA SOFIE — minimal, dependency-free ONNX protobuf reader.
2//
3// Drop-in replacement for the protoc-generated onnx_proto3.pb.h. Provides the
4// subset of the onnx:: message API that the SOFIE ONNX parser actually uses,
5// backed by a hand-written protobuf wire-format decoder. No libprotobuf, no
6// protoc, no codegen.
7//
8// Only the read-side accessors used by RModelParser_ONNX and the Parse*.cxx
9// operator parsers are implemented.
10
11#ifndef TMVA_SOFIE_ONNX_LITE
12#define TMVA_SOFIE_ONNX_LITE
13
14#include <cstdint>
15#include <cstring>
16#include <istream>
17#include <memory>
18#include <utility>
19#include <sstream>
20#include <string>
21#include <vector>
22
23namespace onnx {
24
25// ---------------------------------------------------------------------------
26// Protobuf wire-format reader (proto3 subset: varint, 64-bit, len, 32-bit)
27// ---------------------------------------------------------------------------
28namespace detail {
29
32 WT_I64 = 1,
33 WT_LEN = 2,
34 WT_I32 = 5
35};
36
38 const uint8_t *fP;
39 const uint8_t *fEnd;
40 bool fOk = true;
41
42public:
43 WireReader(const char *data, std::size_t n) : fP(reinterpret_cast<const uint8_t *>(data)), fEnd(fP + n) {}
44
45 bool ok() const { return fOk; }
46 bool eof() const { return fP >= fEnd; }
47
48 uint64_t ReadVarint()
49 {
50 uint64_t result = 0;
51 int shift = 0;
52 while (fP < fEnd && shift < 64) {
53 uint8_t b = *fP++;
54 result |= uint64_t(b & 0x7F) << shift;
55 if (!(b & 0x80))
56 return result;
57 shift += 7;
58 }
59 fOk = false;
60 return result;
61 }
62
63 // Fixed-width fields are little-endian on the wire. Assemble them byte-wise
64 // so the result is a correct host-order value on both little- and big-endian
65 // machines (ROOT CI covers big-endian s390x). Varints need no such handling.
66 uint32_t ReadFixed32()
67 {
68 if (fP + 4 > fEnd) {
69 fOk = false;
70 return 0;
71 }
72 uint32_t v = uint32_t(fP[0]) | (uint32_t(fP[1]) << 8) | (uint32_t(fP[2]) << 16) | (uint32_t(fP[3]) << 24);
73 fP += 4;
74 return v;
75 }
76
77 uint64_t ReadFixed64()
78 {
79 if (fP + 8 > fEnd) {
80 fOk = false;
81 return 0;
82 }
83 uint64_t v = 0;
84 for (int k = 0; k < 8; ++k)
85 v |= uint64_t(fP[k]) << (8 * k);
86 fP += 8;
87 return v;
88 }
89
90 // Length-delimited payload returned as a (ptr,len) view into the buffer.
91 std::pair<const char *, std::size_t> ReadLen()
92 {
93 uint64_t n = ReadVarint();
94 if (fP + n > fEnd) {
95 fOk = false;
96 return {nullptr, 0};
97 }
98 auto ptr = reinterpret_cast<const char *>(fP);
99 fP += n;
100 return {ptr, std::size_t(n)};
101 }
102
103 bool ReadTag(uint32_t &field, uint32_t &wire)
104 {
105 if (eof())
106 return false;
107 uint64_t tag = ReadVarint();
108 if (!fOk)
109 return false;
110 field = uint32_t(tag >> 3);
111 wire = uint32_t(tag & 7);
112 return true;
113 }
114
115 void SkipField(uint32_t wire)
116 {
117 switch (wire) {
118 case WT_VARINT: ReadVarint(); break;
119 case WT_I64: ReadFixed64(); break;
120 case WT_LEN: ReadLen(); break;
121 case WT_I32: ReadFixed32(); break;
122 default: fOk = false; break; // groups (3,4) unsupported / not used by ONNX
123 }
124 }
125};
126
127// Read a repeated numeric field that may be packed (single WT_LEN block) or
128// written as individual entries.
129inline void ReadPackedVarint(WireReader &r, uint32_t wire, std::vector<int64_t> &out)
130{
131 if (wire == WT_LEN) {
132 auto s = r.ReadLen();
133 WireReader rr(s.first, s.second);
134 while (!rr.eof())
135 out.push_back(int64_t(rr.ReadVarint()));
136 } else {
137 out.push_back(int64_t(r.ReadVarint()));
138 }
139}
140inline void ReadPackedI32(WireReader &r, uint32_t wire, std::vector<int32_t> &out)
141{
142 if (wire == WT_LEN) {
143 auto s = r.ReadLen();
144 WireReader rr(s.first, s.second);
145 while (!rr.eof())
146 out.push_back(int32_t(rr.ReadVarint()));
147 } else {
148 out.push_back(int32_t(r.ReadVarint()));
149 }
150}
151inline void ReadPackedFloat(WireReader &r, uint32_t wire, std::vector<float> &out)
152{
153 auto one = [](uint32_t bits) {
154 float f;
155 std::memcpy(&f, &bits, 4);
156 return f;
157 };
158 if (wire == WT_LEN) {
159 auto s = r.ReadLen();
160 WireReader rr(s.first, s.second);
161 while (!rr.eof())
162 out.push_back(one(rr.ReadFixed32()));
163 } else {
164 out.push_back(one(r.ReadFixed32()));
165 }
166}
167inline void ReadPackedDouble(WireReader &r, uint32_t wire, std::vector<double> &out)
168{
169 auto one = [](uint64_t bits) {
170 double d;
171 std::memcpy(&d, &bits, 8);
172 return d;
173 };
174 if (wire == WT_LEN) {
175 auto s = r.ReadLen();
176 WireReader rr(s.first, s.second);
177 while (!rr.eof())
178 out.push_back(one(rr.ReadFixed64()));
179 } else {
180 out.push_back(one(r.ReadFixed64()));
181 }
182}
183
184inline std::string Str(std::pair<const char *, std::size_t> v)
185{
186 return std::string(v.first, v.second);
187}
188
189} // namespace detail
190
191// ---------------------------------------------------------------------------
192// Message types (subset). Each exposes the generated-protobuf-style accessors.
193// ---------------------------------------------------------------------------
194
195class GraphProto; // fwd
196class TensorProto; // fwd
197
198// --- TensorShapeProto::Dimension (flattened name: TensorShapeProto_Dimension)
200public:
201 enum class ValueCase {
202 VALUE_NOT_SET = 0,
203 kDimValue = 1,
204 kDimParam = 2
205 };
206
207 ValueCase value_case() const { return fCase; }
208 int64_t dim_value() const { return fDimValue; }
209 const std::string &dim_param() const { return fDimParam; }
210
212 {
213 uint32_t f, wt;
214 while (r.ReadTag(f, wt)) {
215 switch (f) {
216 case 1:
217 fDimValue = int64_t(r.ReadVarint());
219 break;
220 case 2:
221 fDimParam = detail::Str(r.ReadLen());
223 break;
224 default: r.SkipField(wt); break;
225 }
226 }
227 }
228
229private:
231 int64_t fDimValue = 0;
232 std::string fDimParam;
233};
234
236public:
237 int dim_size() const { return int(fDim.size()); }
238 const TensorShapeProto_Dimension &dim(int i) const { return fDim[i]; }
239
241 {
242 uint32_t f, wt;
243 while (r.ReadTag(f, wt)) {
244 if (f == 1 && wt == detail::WT_LEN) {
245 auto s = r.ReadLen();
246 fDim.emplace_back();
247 fDim.back().ParseFrom(detail::WireReader(s.first, s.second));
248 } else {
249 r.SkipField(wt);
250 }
251 }
252 }
253
254private:
255 std::vector<TensorShapeProto_Dimension> fDim;
256};
257
258// TypeProto::Tensor
260public:
261 int elem_type() const { return fElemType; }
262 bool has_shape() const { return fHasShape; }
263 const TensorShapeProto &shape() const { return fShape; }
264
266 {
267 uint32_t f, wt;
268 while (r.ReadTag(f, wt)) {
269 switch (f) {
270 case 1: fElemType = int(r.ReadVarint()); break;
271 case 2: {
272 auto s = r.ReadLen();
273 fShape.ParseFrom(detail::WireReader(s.first, s.second));
274 fHasShape = true;
275 break;
276 }
277 default: r.SkipField(wt); break;
278 }
279 }
280 }
281
282private:
283 int fElemType = 0;
284 bool fHasShape = false;
286};
287
289public:
290 const TypeProto_Tensor &tensor_type() const { return fTensorType; }
291
293 {
294 uint32_t f, wt;
295 while (r.ReadTag(f, wt)) {
296 if (f == 1 && wt == detail::WT_LEN) { // tensor_type
297 auto s = r.ReadLen();
298 fTensorType.ParseFrom(detail::WireReader(s.first, s.second));
299 } else {
300 r.SkipField(wt);
301 }
302 }
303 }
304
305private:
307};
308
310public:
311 const std::string &name() const { return fName; }
312 const TypeProto &type() const { return fType; }
313
315 {
316 uint32_t f, wt;
317 while (r.ReadTag(f, wt)) {
318 switch (f) {
319 case 1: fName = detail::Str(r.ReadLen()); break;
320 case 2: {
321 auto s = r.ReadLen();
322 fType.ParseFrom(detail::WireReader(s.first, s.second));
323 break;
324 }
325 default: r.SkipField(wt); break;
326 }
327 }
328 }
329
330private:
331 std::string fName;
333};
334
336public:
337 const std::string &key() const { return fKey; }
338 const std::string &value() const { return fValue; }
339
341 {
342 uint32_t f, wt;
343 while (r.ReadTag(f, wt)) {
344 switch (f) {
345 case 1: fKey = detail::Str(r.ReadLen()); break;
346 case 2: fValue = detail::Str(r.ReadLen()); break;
347 default: r.SkipField(wt); break;
348 }
349 }
350 }
351
352private:
353 std::string fKey, fValue;
354};
355
357public:
358 enum DataType {
360 FLOAT = 1,
361 UINT8 = 2,
362 INT8 = 3,
364 INT16 = 5,
365 INT32 = 6,
366 INT64 = 7,
368 BOOL = 9,
370 DOUBLE = 11,
371 UINT32 = 12,
372 UINT64 = 13,
375 BFLOAT16 = 16
376 };
379 EXTERNAL = 1
380 };
381
382 const std::string &name() const { return fName; }
383 int data_type() const { return fDataType; }
384 int dims_size() const { return int(fDims.size()); }
385 int64_t dims(int i) const { return fDims[i]; }
386 const std::string &raw_data() const { return fRawData; }
388 const std::vector<StringStringEntryProto> &external_data() const { return fExternalData; }
389
390 int float_data_size() const { return int(fFloatData.size()); }
391 int double_data_size() const { return int(fDoubleData.size()); }
392 int int32_data_size() const { return int(fInt32Data.size()); }
393 int int64_data_size() const { return int(fInt64Data.size()); }
394 const std::vector<float> &float_data() const { return fFloatData; }
395 const std::vector<double> &double_data() const { return fDoubleData; }
396 const std::vector<int32_t> &int32_data() const { return fInt32Data; }
397 const std::vector<int64_t> &int64_data() const { return fInt64Data; }
398 // Indexed element accessors (the generated protobuf API exposes both forms).
399 float float_data(int i) const { return fFloatData[i]; }
400 double double_data(int i) const { return fDoubleData[i]; }
401 int32_t int32_data(int i) const { return fInt32Data[i]; }
402 int64_t int64_data(int i) const { return fInt64Data[i]; }
403
405 {
406 uint32_t f, wt;
407 while (r.ReadTag(f, wt)) {
408 switch (f) {
409 case 1: detail::ReadPackedVarint(r, wt, fDims); break;
410 case 2: fDataType = int(r.ReadVarint()); break;
411 case 4: detail::ReadPackedFloat(r, wt, fFloatData); break;
412 case 5: detail::ReadPackedI32(r, wt, fInt32Data); break;
413 case 7: detail::ReadPackedVarint(r, wt, fInt64Data); break;
414 case 8: fName = detail::Str(r.ReadLen()); break;
415 case 9: fRawData = detail::Str(r.ReadLen()); break;
416 case 10: detail::ReadPackedDouble(r, wt, fDoubleData); break;
417 case 13: {
418 auto s = r.ReadLen();
419 fExternalData.emplace_back();
420 fExternalData.back().ParseFrom(detail::WireReader(s.first, s.second));
421 break;
422 }
423 case 14: fDataLocation = DataLocation(r.ReadVarint()); break;
424 default: r.SkipField(wt); break;
425 }
426 }
427 }
428
429private:
430 std::string fName;
431 int fDataType = 0;
432 std::vector<int64_t> fDims;
433 std::string fRawData;
435 std::vector<StringStringEntryProto> fExternalData;
436 std::vector<float> fFloatData;
437 std::vector<double> fDoubleData;
438 std::vector<int32_t> fInt32Data;
439 std::vector<int64_t> fInt64Data;
440};
441
443public:
459
460 const std::string &name() const { return fName; }
461 AttributeType type() const { return fType; }
462 float f() const { return fF; }
463 int64_t i() const { return fI; }
464 const std::string &s() const { return fS; }
465 const TensorProto &t() const { return fT; }
466 const GraphProto &g() const; // defined after GraphProto
467 bool has_g() const { return fHasG; }
468 bool has_t() const { return fHasT; }
469
470 const std::vector<float> &floats() const { return fFloats; }
471 const std::vector<int64_t> &ints() const { return fInts; }
472 const std::vector<std::string> &strings() const { return fStrings; }
473
474 void ParseFrom(detail::WireReader r); // defined after GraphProto (needs g())
475
476private:
477 std::string fName;
479 float fF = 0.f;
480 int64_t fI = 0;
481 std::string fS;
482 bool fHasG = false, fHasT = false;
483 std::vector<float> fFloats;
484 std::vector<int64_t> fInts;
485 std::vector<std::string> fStrings;
487 // graph attribute held by shared_ptr to break the cyclic type dependency
488 // (a subgraph contains nodes, whose attributes may again hold subgraphs)
489 std::shared_ptr<GraphProto> fG;
490};
491
493public:
494 const std::string &op_type() const { return fOpType; }
495 const std::string &name() const { return fName; }
496 int input_size() const { return int(fInput.size()); }
497 const std::string &input(int i) const { return fInput[i]; }
498 const std::vector<std::string> &input() const { return fInput; }
499 int output_size() const { return int(fOutput.size()); }
500 const std::string &output(int i) const { return fOutput[i]; }
501 const std::vector<std::string> &output() const { return fOutput; }
502 int attribute_size() const { return int(fAttribute.size()); }
503 const AttributeProto &attribute(int i) const { return fAttribute[i]; }
504
506 {
507 uint32_t f, wt;
508 while (r.ReadTag(f, wt)) {
509 switch (f) {
510 case 1: fInput.push_back(detail::Str(r.ReadLen())); break;
511 case 2: fOutput.push_back(detail::Str(r.ReadLen())); break;
512 case 3: fName = detail::Str(r.ReadLen()); break;
513 case 4: fOpType = detail::Str(r.ReadLen()); break;
514 case 5: {
515 auto s = r.ReadLen();
516 fAttribute.emplace_back();
517 fAttribute.back().ParseFrom(detail::WireReader(s.first, s.second));
518 break;
519 }
520 default: r.SkipField(wt); break;
521 }
522 }
523 }
524
525private:
526 std::vector<std::string> fInput, fOutput;
527 std::string fName, fOpType;
528 std::vector<AttributeProto> fAttribute;
529};
530
532public:
533 const std::string &name() const { return fName; }
534 int node_size() const { return int(fNode.size()); }
535 const NodeProto &node(int i) const { return fNode[i]; }
536 int input_size() const { return int(fInput.size()); }
537 const ValueInfoProto &input(int i) const { return fInput[i]; }
538 int output_size() const { return int(fOutput.size()); }
539 const ValueInfoProto &output(int i) const { return fOutput[i]; }
540 int initializer_size() const { return int(fInitializer.size()); }
541 const TensorProto &initializer(int i) const { return fInitializer[i]; }
542
544 {
545 uint32_t f, wt;
546 while (r.ReadTag(f, wt)) {
547 switch (f) {
548 case 1: {
549 auto s = r.ReadLen();
550 fNode.emplace_back();
551 fNode.back().ParseFrom(detail::WireReader(s.first, s.second));
552 break;
553 }
554 case 2: fName = detail::Str(r.ReadLen()); break;
555 case 5: {
556 auto s = r.ReadLen();
557 fInitializer.emplace_back();
558 fInitializer.back().ParseFrom(detail::WireReader(s.first, s.second));
559 break;
560 }
561 case 11: {
562 auto s = r.ReadLen();
563 fInput.emplace_back();
564 fInput.back().ParseFrom(detail::WireReader(s.first, s.second));
565 break;
566 }
567 case 12: {
568 auto s = r.ReadLen();
569 fOutput.emplace_back();
570 fOutput.back().ParseFrom(detail::WireReader(s.first, s.second));
571 break;
572 }
573 default: r.SkipField(wt); break;
574 }
575 }
576 }
577
578private:
579 std::string fName;
580 std::vector<NodeProto> fNode;
581 std::vector<TensorProto> fInitializer;
582 std::vector<ValueInfoProto> fInput, fOutput;
583};
584
585// --- AttributeProto members that depend on the complete GraphProto type ------
586inline const GraphProto &AttributeProto::g() const
587{
588 return *fG;
589}
590
592{
593 uint32_t f, wt;
594 while (r.ReadTag(f, wt)) {
595 switch (f) {
596 case 1: fName = detail::Str(r.ReadLen()); break;
597 case 2: {
598 uint32_t bits = r.ReadFixed32();
599 std::memcpy(&fF, &bits, 4);
600 break;
601 }
602 case 3: fI = int64_t(r.ReadVarint()); break;
603 case 4: fS = detail::Str(r.ReadLen()); break;
604 case 5: {
605 auto s = r.ReadLen();
606 fT.ParseFrom(detail::WireReader(s.first, s.second));
607 fHasT = true;
608 break;
609 }
610 case 6: {
611 auto s = r.ReadLen();
612 fG = std::make_shared<GraphProto>();
613 fG->ParseFrom(detail::WireReader(s.first, s.second));
614 fHasG = true;
615 break;
616 }
617 case 7: detail::ReadPackedFloat(r, wt, fFloats); break;
618 case 8: detail::ReadPackedVarint(r, wt, fInts); break;
619 case 9: fStrings.push_back(detail::Str(r.ReadLen())); break;
620 case 20: fType = AttributeType(r.ReadVarint()); break;
621 default: r.SkipField(wt); break;
622 }
623 }
624}
625
627public:
628 int64_t ir_version() const { return fIrVersion; }
629 const std::string &producer_name() const { return fProducerName; }
630 const GraphProto &graph() const { return fGraph; }
631
632 bool ParseFromIstream(std::istream *in)
633 {
634 std::ostringstream ss;
635 ss << in->rdbuf();
636 fBuffer = ss.str();
637 detail::WireReader r(fBuffer.data(), fBuffer.size());
638 uint32_t f, wt;
639 while (r.ReadTag(f, wt)) {
640 switch (f) {
641 case 1: fIrVersion = int64_t(r.ReadVarint()); break;
642 case 2: fProducerName = detail::Str(r.ReadLen()); break;
643 case 7: {
644 auto s = r.ReadLen();
645 fGraph.ParseFrom(detail::WireReader(s.first, s.second));
646 break;
647 }
648 default: r.SkipField(wt); break;
649 }
650 }
651 return r.ok();
652 }
653
654private:
655 std::string fBuffer;
656 int64_t fIrVersion = 0;
657 std::string fProducerName;
659};
660
661} // namespace onnx
662
663#endif
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
const std::vector< int64_t > & ints() const
Definition onnx.hxx:471
const TensorProto & t() const
Definition onnx.hxx:465
const std::vector< std::string > & strings() const
Definition onnx.hxx:472
std::string fName
Definition onnx.hxx:477
const std::vector< float > & floats() const
Definition onnx.hxx:470
std::vector< std::string > fStrings
Definition onnx.hxx:485
float f() const
Definition onnx.hxx:462
bool has_g() const
Definition onnx.hxx:467
std::vector< int64_t > fInts
Definition onnx.hxx:484
TensorProto fT
Definition onnx.hxx:486
void ParseFrom(detail::WireReader r)
Definition onnx.hxx:591
const GraphProto & g() const
Definition onnx.hxx:586
const std::string & name() const
Definition onnx.hxx:460
int64_t i() const
Definition onnx.hxx:463
std::shared_ptr< GraphProto > fG
Definition onnx.hxx:489
std::string fS
Definition onnx.hxx:481
std::vector< float > fFloats
Definition onnx.hxx:483
AttributeType fType
Definition onnx.hxx:478
AttributeType type() const
Definition onnx.hxx:461
bool has_t() const
Definition onnx.hxx:468
const std::string & s() const
Definition onnx.hxx:464
std::vector< ValueInfoProto > fInput
Definition onnx.hxx:582
const std::string & name() const
Definition onnx.hxx:533
std::vector< ValueInfoProto > fOutput
Definition onnx.hxx:582
int output_size() const
Definition onnx.hxx:538
const ValueInfoProto & output(int i) const
Definition onnx.hxx:539
void ParseFrom(detail::WireReader r)
Definition onnx.hxx:543
std::string fName
Definition onnx.hxx:579
int input_size() const
Definition onnx.hxx:536
int initializer_size() const
Definition onnx.hxx:540
std::vector< TensorProto > fInitializer
Definition onnx.hxx:581
const ValueInfoProto & input(int i) const
Definition onnx.hxx:537
int node_size() const
Definition onnx.hxx:534
const NodeProto & node(int i) const
Definition onnx.hxx:535
std::vector< NodeProto > fNode
Definition onnx.hxx:580
const TensorProto & initializer(int i) const
Definition onnx.hxx:541
std::string fProducerName
Definition onnx.hxx:657
const std::string & producer_name() const
Definition onnx.hxx:629
const GraphProto & graph() const
Definition onnx.hxx:630
GraphProto fGraph
Definition onnx.hxx:658
int64_t fIrVersion
Definition onnx.hxx:656
std::string fBuffer
Definition onnx.hxx:655
int64_t ir_version() const
Definition onnx.hxx:628
bool ParseFromIstream(std::istream *in)
Definition onnx.hxx:632
const std::string & input(int i) const
Definition onnx.hxx:497
std::vector< std::string > fInput
Definition onnx.hxx:526
std::string fName
Definition onnx.hxx:527
int input_size() const
Definition onnx.hxx:496
std::string fOpType
Definition onnx.hxx:527
int attribute_size() const
Definition onnx.hxx:502
const std::string & name() const
Definition onnx.hxx:495
int output_size() const
Definition onnx.hxx:499
void ParseFrom(detail::WireReader r)
Definition onnx.hxx:505
const std::vector< std::string > & output() const
Definition onnx.hxx:501
std::vector< AttributeProto > fAttribute
Definition onnx.hxx:528
std::vector< std::string > fOutput
Definition onnx.hxx:526
const std::string & output(int i) const
Definition onnx.hxx:500
const AttributeProto & attribute(int i) const
Definition onnx.hxx:503
const std::vector< std::string > & input() const
Definition onnx.hxx:498
const std::string & op_type() const
Definition onnx.hxx:494
const std::string & value() const
Definition onnx.hxx:338
void ParseFrom(detail::WireReader r)
Definition onnx.hxx:340
const std::string & key() const
Definition onnx.hxx:337
int32_t int32_data(int i) const
Definition onnx.hxx:401
std::vector< int32_t > fInt32Data
Definition onnx.hxx:438
int data_type() const
Definition onnx.hxx:383
int64_t int64_data(int i) const
Definition onnx.hxx:402
const std::string & raw_data() const
Definition onnx.hxx:386
std::vector< int64_t > fDims
Definition onnx.hxx:432
int int64_data_size() const
Definition onnx.hxx:393
const std::vector< StringStringEntryProto > & external_data() const
Definition onnx.hxx:388
const std::vector< double > & double_data() const
Definition onnx.hxx:395
std::string fRawData
Definition onnx.hxx:433
int64_t dims(int i) const
Definition onnx.hxx:385
int dims_size() const
Definition onnx.hxx:384
std::vector< double > fDoubleData
Definition onnx.hxx:437
const std::string & name() const
Definition onnx.hxx:382
int float_data_size() const
Definition onnx.hxx:390
DataLocation data_location() const
Definition onnx.hxx:387
int double_data_size() const
Definition onnx.hxx:391
const std::vector< int64_t > & int64_data() const
Definition onnx.hxx:397
std::vector< float > fFloatData
Definition onnx.hxx:436
const std::vector< int32_t > & int32_data() const
Definition onnx.hxx:396
std::string fName
Definition onnx.hxx:430
float float_data(int i) const
Definition onnx.hxx:399
DataLocation fDataLocation
Definition onnx.hxx:434
std::vector< StringStringEntryProto > fExternalData
Definition onnx.hxx:435
double double_data(int i) const
Definition onnx.hxx:400
std::vector< int64_t > fInt64Data
Definition onnx.hxx:439
int int32_data_size() const
Definition onnx.hxx:392
const std::vector< float > & float_data() const
Definition onnx.hxx:394
void ParseFrom(detail::WireReader r)
Definition onnx.hxx:404
ValueCase value_case() const
Definition onnx.hxx:207
const std::string & dim_param() const
Definition onnx.hxx:209
void ParseFrom(detail::WireReader r)
Definition onnx.hxx:211
std::vector< TensorShapeProto_Dimension > fDim
Definition onnx.hxx:255
const TensorShapeProto_Dimension & dim(int i) const
Definition onnx.hxx:238
int dim_size() const
Definition onnx.hxx:237
void ParseFrom(detail::WireReader r)
Definition onnx.hxx:240
TensorShapeProto fShape
Definition onnx.hxx:285
const TensorShapeProto & shape() const
Definition onnx.hxx:263
void ParseFrom(detail::WireReader r)
Definition onnx.hxx:265
int elem_type() const
Definition onnx.hxx:261
bool has_shape() const
Definition onnx.hxx:262
void ParseFrom(detail::WireReader r)
Definition onnx.hxx:292
TypeProto_Tensor fTensorType
Definition onnx.hxx:306
const TypeProto_Tensor & tensor_type() const
Definition onnx.hxx:290
std::string fName
Definition onnx.hxx:331
void ParseFrom(detail::WireReader r)
Definition onnx.hxx:314
TypeProto fType
Definition onnx.hxx:332
const TypeProto & type() const
Definition onnx.hxx:312
const std::string & name() const
Definition onnx.hxx:311
void SkipField(uint32_t wire)
Definition onnx.hxx:115
uint64_t ReadFixed64()
Definition onnx.hxx:77
WireReader(const char *data, std::size_t n)
Definition onnx.hxx:43
uint64_t ReadVarint()
Definition onnx.hxx:48
bool ok() const
Definition onnx.hxx:45
const uint8_t * fP
Definition onnx.hxx:38
std::pair< const char *, std::size_t > ReadLen()
Definition onnx.hxx:91
uint32_t ReadFixed32()
Definition onnx.hxx:66
const uint8_t * fEnd
Definition onnx.hxx:39
bool eof() const
Definition onnx.hxx:46
bool ReadTag(uint32_t &field, uint32_t &wire)
Definition onnx.hxx:103
const Int_t n
Definition legend1.C:16
void ReadPackedI32(WireReader &r, uint32_t wire, std::vector< int32_t > &out)
Definition onnx.hxx:140
void ReadPackedVarint(WireReader &r, uint32_t wire, std::vector< int64_t > &out)
Definition onnx.hxx:129
void ReadPackedDouble(WireReader &r, uint32_t wire, std::vector< double > &out)
Definition onnx.hxx:167
std::string Str(std::pair< const char *, std::size_t > v)
Definition onnx.hxx:184
void ReadPackedFloat(WireReader &r, uint32_t wire, std::vector< float > &out)
Definition onnx.hxx:151