TrtTable.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # automatically generated by the FlatBuffers compiler, do not modify
  2. # namespace: CalTableFlatBuffers
  3. import flatbuffers
  4. from flatbuffers.compat import import_numpy
  5. np = import_numpy()
  6. class TrtTable:
  7. __slots__ = ["_tab"]
  8. @classmethod
  9. def GetRootAs(cls, buf, offset=0): # noqa: N802
  10. n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
  11. x = TrtTable()
  12. x.Init(buf, n + offset)
  13. return x
  14. @classmethod
  15. def GetRootAsTrtTable(cls, buf, offset=0): # noqa: N802
  16. """This method is deprecated. Please switch to GetRootAs."""
  17. return cls.GetRootAs(buf, offset)
  18. # TrtTable
  19. def Init(self, buf, pos): # noqa: N802
  20. self._tab = flatbuffers.table.Table(buf, pos)
  21. # TrtTable
  22. def Dict(self, j): # noqa: N802
  23. o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
  24. if o != 0:
  25. x = self._tab.Vector(o)
  26. x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
  27. x = self._tab.Indirect(x)
  28. from onnxruntime.quantization.CalTableFlatBuffers.KeyValue import KeyValue # noqa: PLC0415
  29. obj = KeyValue()
  30. obj.Init(self._tab.Bytes, x)
  31. return obj
  32. return None
  33. # TrtTable
  34. def DictLength(self): # noqa: N802
  35. o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
  36. if o != 0:
  37. return self._tab.VectorLen(o)
  38. return 0
  39. # TrtTable
  40. def DictIsNone(self): # noqa: N802
  41. o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
  42. return o == 0
  43. def Start(builder): # noqa: N802
  44. builder.StartObject(1)
  45. def TrtTableStart(builder): # noqa: N802
  46. """This method is deprecated. Please switch to Start."""
  47. return Start(builder)
  48. def AddDict(builder, dict): # noqa: N802
  49. builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(dict), 0)
  50. def TrtTableAddDict(builder, dict): # noqa: N802
  51. """This method is deprecated. Please switch to AddDict."""
  52. return AddDict(builder, dict)
  53. def StartDictVector(builder, numElems): # noqa: N802
  54. return builder.StartVector(4, numElems, 4)
  55. def TrtTableStartDictVector(builder, numElems): # noqa: N802
  56. """This method is deprecated. Please switch to Start."""
  57. return StartDictVector(builder, numElems)
  58. def End(builder): # noqa: N802
  59. return builder.EndObject()
  60. def TrtTableEnd(builder): # noqa: N802
  61. """This method is deprecated. Please switch to End."""
  62. return End(builder)