mediapipe-nightly 0.10.10.post20240225__cp38-cp38-macosx_11_0_universal2.whl → 0.10.11.post20240302__cp38-cp38-macosx_11_0_universal2.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. mediapipe/__init__.py +1 -1
  2. mediapipe/python/__init__.py +1 -0
  3. mediapipe/python/_framework_bindings.cpython-38-darwin.so +0 -0
  4. mediapipe/tasks/cc/genai/inference/calculators/__init__.py +0 -0
  5. mediapipe/tasks/cc/genai/inference/calculators/detokenizer_calculator_pb2.py +27 -0
  6. mediapipe/tasks/cc/genai/inference/calculators/llm_gpu_calculator_pb2.py +31 -0
  7. mediapipe/tasks/cc/genai/inference/calculators/tokenizer_calculator_pb2.py +29 -0
  8. mediapipe/tasks/cc/genai/inference/proto/llm_file_metadata_pb2.py +32 -0
  9. mediapipe/tasks/cc/genai/inference/proto/llm_params_pb2.py +6 -6
  10. mediapipe/tasks/cc/genai/inference/proto/transformer_params_pb2.py +18 -18
  11. mediapipe/tasks/cc/metadata/python/_pywrap_metadata_version.cpython-38-darwin.so +0 -0
  12. mediapipe/tasks/metadata/schema_py_generated.py +4019 -119
  13. mediapipe/tasks/python/genai/converter/converter_base.py +4 -1
  14. mediapipe/tasks/python/genai/converter/llm_converter.py +16 -13
  15. mediapipe/tasks/python/genai/converter/pytorch_converter.py +7 -4
  16. mediapipe/tasks/python/genai/converter/pytorch_converter_test.py +1 -1
  17. mediapipe/tasks/python/genai/converter/safetensors_converter.py +5 -4
  18. mediapipe/tasks/python/genai/converter/safetensors_converter_test.py +1 -1
  19. mediapipe/tasks/python/metadata/flatbuffers_lib/_pywrap_flatbuffers.cpython-38-darwin.so +0 -0
  20. mediapipe/tasks/python/vision/__init__.py +5 -0
  21. mediapipe/version.txt +1 -1
  22. {mediapipe_nightly-0.10.10.post20240225.dist-info → mediapipe_nightly-0.10.11.post20240302.dist-info}/METADATA +3 -1
  23. {mediapipe_nightly-0.10.10.post20240225.dist-info → mediapipe_nightly-0.10.11.post20240302.dist-info}/RECORD +25 -20
  24. {mediapipe_nightly-0.10.10.post20240225.dist-info → mediapipe_nightly-0.10.11.post20240302.dist-info}/LICENSE +0 -0
  25. {mediapipe_nightly-0.10.10.post20240225.dist-info → mediapipe_nightly-0.10.11.post20240302.dist-info}/WHEEL +0 -0
  26. {mediapipe_nightly-0.10.10.post20240225.dist-info → mediapipe_nightly-0.10.11.post20240302.dist-info}/top_level.txt +0 -0
@@ -228,6 +228,50 @@ class BuiltinOperator(object):
228
228
  BITCAST = 159
229
229
  BITWISE_XOR = 160
230
230
  RIGHT_SHIFT = 161
231
+ STABLEHLO_LOGISTIC = 162
232
+ STABLEHLO_ADD = 163
233
+ STABLEHLO_DIVIDE = 164
234
+ STABLEHLO_MULTIPLY = 165
235
+ STABLEHLO_MAXIMUM = 166
236
+ STABLEHLO_RESHAPE = 167
237
+ STABLEHLO_CLAMP = 168
238
+ STABLEHLO_CONCATENATE = 169
239
+ STABLEHLO_BROADCAST_IN_DIM = 170
240
+ STABLEHLO_CONVOLUTION = 171
241
+ STABLEHLO_SLICE = 172
242
+ STABLEHLO_CUSTOM_CALL = 173
243
+ STABLEHLO_REDUCE = 174
244
+ STABLEHLO_ABS = 175
245
+ STABLEHLO_AND = 176
246
+ STABLEHLO_COSINE = 177
247
+ STABLEHLO_EXPONENTIAL = 178
248
+ STABLEHLO_FLOOR = 179
249
+ STABLEHLO_LOG = 180
250
+ STABLEHLO_MINIMUM = 181
251
+ STABLEHLO_NEGATE = 182
252
+ STABLEHLO_OR = 183
253
+ STABLEHLO_POWER = 184
254
+ STABLEHLO_REMAINDER = 185
255
+ STABLEHLO_RSQRT = 186
256
+ STABLEHLO_SELECT = 187
257
+ STABLEHLO_SUBTRACT = 188
258
+ STABLEHLO_TANH = 189
259
+ STABLEHLO_SCATTER = 190
260
+ STABLEHLO_COMPARE = 191
261
+ STABLEHLO_CONVERT = 192
262
+ STABLEHLO_DYNAMIC_SLICE = 193
263
+ STABLEHLO_DYNAMIC_UPDATE_SLICE = 194
264
+ STABLEHLO_PAD = 195
265
+ STABLEHLO_IOTA = 196
266
+ STABLEHLO_DOT_GENERAL = 197
267
+ STABLEHLO_REDUCE_WINDOW = 198
268
+ STABLEHLO_SORT = 199
269
+ STABLEHLO_WHILE = 200
270
+ STABLEHLO_GATHER = 201
271
+ STABLEHLO_TRANSPOSE = 202
272
+ DILATE = 203
273
+ STABLEHLO_RNG_BIT_GENERATOR = 204
274
+ REDUCE_WINDOW = 205
231
275
 
232
276
 
233
277
  class BuiltinOptions(object):
@@ -618,6 +662,105 @@ def BuiltinOptionsCreator(unionType, table):
618
662
  return None
619
663
 
620
664
 
665
+ class BuiltinOptions2(object):
666
+ NONE = 0
667
+ StablehloConcatenateOptions = 1
668
+ StablehloBroadcastInDimOptions = 2
669
+ StablehloSliceOptions = 3
670
+ StablehloConvolutionOptions = 4
671
+ StablehloCustomCallOptions = 5
672
+ StablehloReduceOptions = 6
673
+ StablehloScatterOptions = 7
674
+ StablehloCompareOptions = 8
675
+ StablehloDynamicSliceOptions = 9
676
+ StablehloPadOptions = 10
677
+ StablehloIotaOptions = 11
678
+ StablehloDotGeneralOptions = 12
679
+ StablehloReduceWindowOptions = 13
680
+ StablehloSortOptions = 14
681
+ StablehloWhileOptions = 15
682
+ StablehloGatherOptions = 16
683
+ StablehloTransposeOptions = 17
684
+ DilateOptions = 18
685
+ StablehloRngBitGeneratorOptions = 19
686
+ ReduceWindowOptions = 20
687
+
688
+ def BuiltinOptions2Creator(unionType, table):
689
+ from flatbuffers.table import Table
690
+ if not isinstance(table, Table):
691
+ return None
692
+ if unionType == BuiltinOptions2().StablehloConcatenateOptions:
693
+ return StablehloConcatenateOptionsT.InitFromBuf(table.Bytes, table.Pos)
694
+ if unionType == BuiltinOptions2().StablehloBroadcastInDimOptions:
695
+ return StablehloBroadcastInDimOptionsT.InitFromBuf(table.Bytes, table.Pos)
696
+ if unionType == BuiltinOptions2().StablehloSliceOptions:
697
+ return StablehloSliceOptionsT.InitFromBuf(table.Bytes, table.Pos)
698
+ if unionType == BuiltinOptions2().StablehloConvolutionOptions:
699
+ return StablehloConvolutionOptionsT.InitFromBuf(table.Bytes, table.Pos)
700
+ if unionType == BuiltinOptions2().StablehloCustomCallOptions:
701
+ return StablehloCustomCallOptionsT.InitFromBuf(table.Bytes, table.Pos)
702
+ if unionType == BuiltinOptions2().StablehloReduceOptions:
703
+ return StablehloReduceOptionsT.InitFromBuf(table.Bytes, table.Pos)
704
+ if unionType == BuiltinOptions2().StablehloScatterOptions:
705
+ return StablehloScatterOptionsT.InitFromBuf(table.Bytes, table.Pos)
706
+ if unionType == BuiltinOptions2().StablehloCompareOptions:
707
+ return StablehloCompareOptionsT.InitFromBuf(table.Bytes, table.Pos)
708
+ if unionType == BuiltinOptions2().StablehloDynamicSliceOptions:
709
+ return StablehloDynamicSliceOptionsT.InitFromBuf(table.Bytes, table.Pos)
710
+ if unionType == BuiltinOptions2().StablehloPadOptions:
711
+ return StablehloPadOptionsT.InitFromBuf(table.Bytes, table.Pos)
712
+ if unionType == BuiltinOptions2().StablehloIotaOptions:
713
+ return StablehloIotaOptionsT.InitFromBuf(table.Bytes, table.Pos)
714
+ if unionType == BuiltinOptions2().StablehloDotGeneralOptions:
715
+ return StablehloDotGeneralOptionsT.InitFromBuf(table.Bytes, table.Pos)
716
+ if unionType == BuiltinOptions2().StablehloReduceWindowOptions:
717
+ return StablehloReduceWindowOptionsT.InitFromBuf(table.Bytes, table.Pos)
718
+ if unionType == BuiltinOptions2().StablehloSortOptions:
719
+ return StablehloSortOptionsT.InitFromBuf(table.Bytes, table.Pos)
720
+ if unionType == BuiltinOptions2().StablehloWhileOptions:
721
+ return StablehloWhileOptionsT.InitFromBuf(table.Bytes, table.Pos)
722
+ if unionType == BuiltinOptions2().StablehloGatherOptions:
723
+ return StablehloGatherOptionsT.InitFromBuf(table.Bytes, table.Pos)
724
+ if unionType == BuiltinOptions2().StablehloTransposeOptions:
725
+ return StablehloTransposeOptionsT.InitFromBuf(table.Bytes, table.Pos)
726
+ if unionType == BuiltinOptions2().DilateOptions:
727
+ return DilateOptionsT.InitFromBuf(table.Bytes, table.Pos)
728
+ if unionType == BuiltinOptions2().StablehloRngBitGeneratorOptions:
729
+ return StablehloRngBitGeneratorOptionsT.InitFromBuf(table.Bytes, table.Pos)
730
+ if unionType == BuiltinOptions2().ReduceWindowOptions:
731
+ return ReduceWindowOptionsT.InitFromBuf(table.Bytes, table.Pos)
732
+ return None
733
+
734
+
735
+ class StablehloPrecisionConfig(object):
736
+ DEFAULT = 0
737
+ HIGH = 1
738
+ HIGHEST = 2
739
+
740
+
741
+ class StablehloComparisonDirection(object):
742
+ STABLEHLO_COMPARISON_DIRECTION_EQ = 0
743
+ STABLEHLO_COMPARISON_DIRECTION_NE = 1
744
+ STABLEHLO_COMPARISON_DIRECTION_GE = 2
745
+ STABLEHLO_COMPARISON_DIRECTION_GT = 3
746
+ STABLEHLO_COMPARISON_DIRECTION_LE = 4
747
+ STABLEHLO_COMPARISON_DIRECTION_LT = 5
748
+
749
+
750
+ class StablehloComparisonType(object):
751
+ STABLEHLO_COMPARISON_TYPE_NOTYPE = 0
752
+ STABLEHLO_COMPARISON_TYPE_FLOAT = 1
753
+ STABLEHLO_COMPARISON_TYPE_FLOAT_TOTAL_ORDER = 2
754
+ STABLEHLO_COMPARISON_TYPE_SIGNED = 3
755
+ STABLEHLO_COMPARISON_TYPE_UNSIGNED = 4
756
+
757
+
758
+ class RngAlgorithm(object):
759
+ DEFAULT = 0
760
+ PHILOX = 1
761
+ THREEFRY = 2
762
+
763
+
621
764
  class Padding(object):
622
765
  SAME = 0
623
766
  VALID = 1
@@ -659,6 +802,16 @@ class MirrorPadMode(object):
659
802
  SYMMETRIC = 1
660
803
 
661
804
 
805
+ class ReduceWindowFunction(object):
806
+ UNSUPPORTED = 0
807
+ ADD = 1
808
+ MUL = 2
809
+ MINIMUM = 3
810
+ MAXIMUM = 4
811
+ ALL = 5
812
+ ANY = 6
813
+
814
+
662
815
  class CustomOptionsFormat(object):
663
816
  FLEXBUFFERS = 0
664
817
 
@@ -2163,47 +2316,3656 @@ def TensorAddSparsity(builder, sparsity):
2163
2316
  def TensorAddShapeSignature(builder, shapeSignature):
2164
2317
  builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(shapeSignature), 0)
2165
2318
 
2166
- def TensorStartShapeSignatureVector(builder, numElems):
2167
- return builder.StartVector(4, numElems, 4)
2319
+ def TensorStartShapeSignatureVector(builder, numElems):
2320
+ return builder.StartVector(4, numElems, 4)
2321
+
2322
+ def TensorAddHasRank(builder, hasRank):
2323
+ builder.PrependBoolSlot(8, hasRank, 0)
2324
+
2325
+ def TensorAddVariantTensors(builder, variantTensors):
2326
+ builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(variantTensors), 0)
2327
+
2328
+ def TensorStartVariantTensorsVector(builder, numElems):
2329
+ return builder.StartVector(4, numElems, 4)
2330
+
2331
+ def TensorEnd(builder):
2332
+ return builder.EndObject()
2333
+
2334
+
2335
+ try:
2336
+ from typing import List, Optional
2337
+ except:
2338
+ pass
2339
+
2340
+ class TensorT(object):
2341
+
2342
+ # TensorT
2343
+ def __init__(self):
2344
+ self.shape = None # type: List[int]
2345
+ self.type = 0 # type: int
2346
+ self.buffer = 0 # type: int
2347
+ self.name = None # type: str
2348
+ self.quantization = None # type: Optional[QuantizationParametersT]
2349
+ self.isVariable = False # type: bool
2350
+ self.sparsity = None # type: Optional[SparsityParametersT]
2351
+ self.shapeSignature = None # type: List[int]
2352
+ self.hasRank = False # type: bool
2353
+ self.variantTensors = None # type: List[VariantSubTypeT]
2354
+
2355
+ @classmethod
2356
+ def InitFromBuf(cls, buf, pos):
2357
+ tensor = Tensor()
2358
+ tensor.Init(buf, pos)
2359
+ return cls.InitFromObj(tensor)
2360
+
2361
+ @classmethod
2362
+ def InitFromPackedBuf(cls, buf, pos=0):
2363
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
2364
+ return cls.InitFromBuf(buf, pos+n)
2365
+
2366
+ @classmethod
2367
+ def InitFromObj(cls, tensor):
2368
+ x = TensorT()
2369
+ x._UnPack(tensor)
2370
+ return x
2371
+
2372
+ # TensorT
2373
+ def _UnPack(self, tensor):
2374
+ if tensor is None:
2375
+ return
2376
+ if not tensor.ShapeIsNone():
2377
+ if np is None:
2378
+ self.shape = []
2379
+ for i in range(tensor.ShapeLength()):
2380
+ self.shape.append(tensor.Shape(i))
2381
+ else:
2382
+ self.shape = tensor.ShapeAsNumpy()
2383
+ self.type = tensor.Type()
2384
+ self.buffer = tensor.Buffer()
2385
+ self.name = tensor.Name()
2386
+ if tensor.Quantization() is not None:
2387
+ self.quantization = QuantizationParametersT.InitFromObj(tensor.Quantization())
2388
+ self.isVariable = tensor.IsVariable()
2389
+ if tensor.Sparsity() is not None:
2390
+ self.sparsity = SparsityParametersT.InitFromObj(tensor.Sparsity())
2391
+ if not tensor.ShapeSignatureIsNone():
2392
+ if np is None:
2393
+ self.shapeSignature = []
2394
+ for i in range(tensor.ShapeSignatureLength()):
2395
+ self.shapeSignature.append(tensor.ShapeSignature(i))
2396
+ else:
2397
+ self.shapeSignature = tensor.ShapeSignatureAsNumpy()
2398
+ self.hasRank = tensor.HasRank()
2399
+ if not tensor.VariantTensorsIsNone():
2400
+ self.variantTensors = []
2401
+ for i in range(tensor.VariantTensorsLength()):
2402
+ if tensor.VariantTensors(i) is None:
2403
+ self.variantTensors.append(None)
2404
+ else:
2405
+ variantSubType_ = VariantSubTypeT.InitFromObj(tensor.VariantTensors(i))
2406
+ self.variantTensors.append(variantSubType_)
2407
+
2408
+ # TensorT
2409
+ def Pack(self, builder):
2410
+ if self.shape is not None:
2411
+ if np is not None and type(self.shape) is np.ndarray:
2412
+ shape = builder.CreateNumpyVector(self.shape)
2413
+ else:
2414
+ TensorStartShapeVector(builder, len(self.shape))
2415
+ for i in reversed(range(len(self.shape))):
2416
+ builder.PrependInt32(self.shape[i])
2417
+ shape = builder.EndVector()
2418
+ if self.name is not None:
2419
+ name = builder.CreateString(self.name)
2420
+ if self.quantization is not None:
2421
+ quantization = self.quantization.Pack(builder)
2422
+ if self.sparsity is not None:
2423
+ sparsity = self.sparsity.Pack(builder)
2424
+ if self.shapeSignature is not None:
2425
+ if np is not None and type(self.shapeSignature) is np.ndarray:
2426
+ shapeSignature = builder.CreateNumpyVector(self.shapeSignature)
2427
+ else:
2428
+ TensorStartShapeSignatureVector(builder, len(self.shapeSignature))
2429
+ for i in reversed(range(len(self.shapeSignature))):
2430
+ builder.PrependInt32(self.shapeSignature[i])
2431
+ shapeSignature = builder.EndVector()
2432
+ if self.variantTensors is not None:
2433
+ variantTensorslist = []
2434
+ for i in range(len(self.variantTensors)):
2435
+ variantTensorslist.append(self.variantTensors[i].Pack(builder))
2436
+ TensorStartVariantTensorsVector(builder, len(self.variantTensors))
2437
+ for i in reversed(range(len(self.variantTensors))):
2438
+ builder.PrependUOffsetTRelative(variantTensorslist[i])
2439
+ variantTensors = builder.EndVector()
2440
+ TensorStart(builder)
2441
+ if self.shape is not None:
2442
+ TensorAddShape(builder, shape)
2443
+ TensorAddType(builder, self.type)
2444
+ TensorAddBuffer(builder, self.buffer)
2445
+ if self.name is not None:
2446
+ TensorAddName(builder, name)
2447
+ if self.quantization is not None:
2448
+ TensorAddQuantization(builder, quantization)
2449
+ TensorAddIsVariable(builder, self.isVariable)
2450
+ if self.sparsity is not None:
2451
+ TensorAddSparsity(builder, sparsity)
2452
+ if self.shapeSignature is not None:
2453
+ TensorAddShapeSignature(builder, shapeSignature)
2454
+ TensorAddHasRank(builder, self.hasRank)
2455
+ if self.variantTensors is not None:
2456
+ TensorAddVariantTensors(builder, variantTensors)
2457
+ tensor = TensorEnd(builder)
2458
+ return tensor
2459
+
2460
+
2461
+ class StablehloGatherOptions(object):
2462
+ __slots__ = ['_tab']
2463
+
2464
+ @classmethod
2465
+ def GetRootAs(cls, buf, offset=0):
2466
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2467
+ x = StablehloGatherOptions()
2468
+ x.Init(buf, n + offset)
2469
+ return x
2470
+
2471
+ @classmethod
2472
+ def GetRootAsStablehloGatherOptions(cls, buf, offset=0):
2473
+ """This method is deprecated. Please switch to GetRootAs."""
2474
+ return cls.GetRootAs(buf, offset)
2475
+ @classmethod
2476
+ def StablehloGatherOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
2477
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
2478
+
2479
+ # StablehloGatherOptions
2480
+ def Init(self, buf, pos):
2481
+ self._tab = flatbuffers.table.Table(buf, pos)
2482
+
2483
+ # StablehloGatherOptions
2484
+ def OffsetDims(self, j):
2485
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2486
+ if o != 0:
2487
+ a = self._tab.Vector(o)
2488
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
2489
+ return 0
2490
+
2491
+ # StablehloGatherOptions
2492
+ def OffsetDimsAsNumpy(self):
2493
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2494
+ if o != 0:
2495
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
2496
+ return 0
2497
+
2498
+ # StablehloGatherOptions
2499
+ def OffsetDimsLength(self):
2500
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2501
+ if o != 0:
2502
+ return self._tab.VectorLen(o)
2503
+ return 0
2504
+
2505
+ # StablehloGatherOptions
2506
+ def OffsetDimsIsNone(self):
2507
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2508
+ return o == 0
2509
+
2510
+ # StablehloGatherOptions
2511
+ def CollapsedSliceDims(self, j):
2512
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2513
+ if o != 0:
2514
+ a = self._tab.Vector(o)
2515
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
2516
+ return 0
2517
+
2518
+ # StablehloGatherOptions
2519
+ def CollapsedSliceDimsAsNumpy(self):
2520
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2521
+ if o != 0:
2522
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
2523
+ return 0
2524
+
2525
+ # StablehloGatherOptions
2526
+ def CollapsedSliceDimsLength(self):
2527
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2528
+ if o != 0:
2529
+ return self._tab.VectorLen(o)
2530
+ return 0
2531
+
2532
+ # StablehloGatherOptions
2533
+ def CollapsedSliceDimsIsNone(self):
2534
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2535
+ return o == 0
2536
+
2537
+ # StablehloGatherOptions
2538
+ def StartIndexMap(self, j):
2539
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2540
+ if o != 0:
2541
+ a = self._tab.Vector(o)
2542
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
2543
+ return 0
2544
+
2545
+ # StablehloGatherOptions
2546
+ def StartIndexMapAsNumpy(self):
2547
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2548
+ if o != 0:
2549
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
2550
+ return 0
2551
+
2552
+ # StablehloGatherOptions
2553
+ def StartIndexMapLength(self):
2554
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2555
+ if o != 0:
2556
+ return self._tab.VectorLen(o)
2557
+ return 0
2558
+
2559
+ # StablehloGatherOptions
2560
+ def StartIndexMapIsNone(self):
2561
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2562
+ return o == 0
2563
+
2564
+ # StablehloGatherOptions
2565
+ def IndexVectorDim(self):
2566
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2567
+ if o != 0:
2568
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
2569
+ return 0
2570
+
2571
+ # StablehloGatherOptions
2572
+ def SliceSizes(self, j):
2573
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2574
+ if o != 0:
2575
+ a = self._tab.Vector(o)
2576
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
2577
+ return 0
2578
+
2579
+ # StablehloGatherOptions
2580
+ def SliceSizesAsNumpy(self):
2581
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2582
+ if o != 0:
2583
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
2584
+ return 0
2585
+
2586
+ # StablehloGatherOptions
2587
+ def SliceSizesLength(self):
2588
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2589
+ if o != 0:
2590
+ return self._tab.VectorLen(o)
2591
+ return 0
2592
+
2593
+ # StablehloGatherOptions
2594
+ def SliceSizesIsNone(self):
2595
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2596
+ return o == 0
2597
+
2598
+ # StablehloGatherOptions
2599
+ def IndicesAreSorted(self):
2600
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
2601
+ if o != 0:
2602
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
2603
+ return False
2604
+
2605
+ def StablehloGatherOptionsStart(builder):
2606
+ builder.StartObject(6)
2607
+
2608
+ def StablehloGatherOptionsAddOffsetDims(builder, offsetDims):
2609
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(offsetDims), 0)
2610
+
2611
+ def StablehloGatherOptionsStartOffsetDimsVector(builder, numElems):
2612
+ return builder.StartVector(8, numElems, 8)
2613
+
2614
+ def StablehloGatherOptionsAddCollapsedSliceDims(builder, collapsedSliceDims):
2615
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(collapsedSliceDims), 0)
2616
+
2617
+ def StablehloGatherOptionsStartCollapsedSliceDimsVector(builder, numElems):
2618
+ return builder.StartVector(8, numElems, 8)
2619
+
2620
+ def StablehloGatherOptionsAddStartIndexMap(builder, startIndexMap):
2621
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(startIndexMap), 0)
2622
+
2623
+ def StablehloGatherOptionsStartStartIndexMapVector(builder, numElems):
2624
+ return builder.StartVector(8, numElems, 8)
2625
+
2626
+ def StablehloGatherOptionsAddIndexVectorDim(builder, indexVectorDim):
2627
+ builder.PrependInt64Slot(3, indexVectorDim, 0)
2628
+
2629
+ def StablehloGatherOptionsAddSliceSizes(builder, sliceSizes):
2630
+ builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(sliceSizes), 0)
2631
+
2632
+ def StablehloGatherOptionsStartSliceSizesVector(builder, numElems):
2633
+ return builder.StartVector(8, numElems, 8)
2634
+
2635
+ def StablehloGatherOptionsAddIndicesAreSorted(builder, indicesAreSorted):
2636
+ builder.PrependBoolSlot(5, indicesAreSorted, 0)
2637
+
2638
+ def StablehloGatherOptionsEnd(builder):
2639
+ return builder.EndObject()
2640
+
2641
+
2642
+ try:
2643
+ from typing import List
2644
+ except:
2645
+ pass
2646
+
2647
+ class StablehloGatherOptionsT(object):
2648
+
2649
+ # StablehloGatherOptionsT
2650
+ def __init__(self):
2651
+ self.offsetDims = None # type: List[int]
2652
+ self.collapsedSliceDims = None # type: List[int]
2653
+ self.startIndexMap = None # type: List[int]
2654
+ self.indexVectorDim = 0 # type: int
2655
+ self.sliceSizes = None # type: List[int]
2656
+ self.indicesAreSorted = False # type: bool
2657
+
2658
+ @classmethod
2659
+ def InitFromBuf(cls, buf, pos):
2660
+ stablehloGatherOptions = StablehloGatherOptions()
2661
+ stablehloGatherOptions.Init(buf, pos)
2662
+ return cls.InitFromObj(stablehloGatherOptions)
2663
+
2664
+ @classmethod
2665
+ def InitFromPackedBuf(cls, buf, pos=0):
2666
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
2667
+ return cls.InitFromBuf(buf, pos+n)
2668
+
2669
+ @classmethod
2670
+ def InitFromObj(cls, stablehloGatherOptions):
2671
+ x = StablehloGatherOptionsT()
2672
+ x._UnPack(stablehloGatherOptions)
2673
+ return x
2674
+
2675
+ # StablehloGatherOptionsT
2676
+ def _UnPack(self, stablehloGatherOptions):
2677
+ if stablehloGatherOptions is None:
2678
+ return
2679
+ if not stablehloGatherOptions.OffsetDimsIsNone():
2680
+ if np is None:
2681
+ self.offsetDims = []
2682
+ for i in range(stablehloGatherOptions.OffsetDimsLength()):
2683
+ self.offsetDims.append(stablehloGatherOptions.OffsetDims(i))
2684
+ else:
2685
+ self.offsetDims = stablehloGatherOptions.OffsetDimsAsNumpy()
2686
+ if not stablehloGatherOptions.CollapsedSliceDimsIsNone():
2687
+ if np is None:
2688
+ self.collapsedSliceDims = []
2689
+ for i in range(stablehloGatherOptions.CollapsedSliceDimsLength()):
2690
+ self.collapsedSliceDims.append(stablehloGatherOptions.CollapsedSliceDims(i))
2691
+ else:
2692
+ self.collapsedSliceDims = stablehloGatherOptions.CollapsedSliceDimsAsNumpy()
2693
+ if not stablehloGatherOptions.StartIndexMapIsNone():
2694
+ if np is None:
2695
+ self.startIndexMap = []
2696
+ for i in range(stablehloGatherOptions.StartIndexMapLength()):
2697
+ self.startIndexMap.append(stablehloGatherOptions.StartIndexMap(i))
2698
+ else:
2699
+ self.startIndexMap = stablehloGatherOptions.StartIndexMapAsNumpy()
2700
+ self.indexVectorDim = stablehloGatherOptions.IndexVectorDim()
2701
+ if not stablehloGatherOptions.SliceSizesIsNone():
2702
+ if np is None:
2703
+ self.sliceSizes = []
2704
+ for i in range(stablehloGatherOptions.SliceSizesLength()):
2705
+ self.sliceSizes.append(stablehloGatherOptions.SliceSizes(i))
2706
+ else:
2707
+ self.sliceSizes = stablehloGatherOptions.SliceSizesAsNumpy()
2708
+ self.indicesAreSorted = stablehloGatherOptions.IndicesAreSorted()
2709
+
2710
+ # StablehloGatherOptionsT
2711
+ def Pack(self, builder):
2712
+ if self.offsetDims is not None:
2713
+ if np is not None and type(self.offsetDims) is np.ndarray:
2714
+ offsetDims = builder.CreateNumpyVector(self.offsetDims)
2715
+ else:
2716
+ StablehloGatherOptionsStartOffsetDimsVector(builder, len(self.offsetDims))
2717
+ for i in reversed(range(len(self.offsetDims))):
2718
+ builder.PrependInt64(self.offsetDims[i])
2719
+ offsetDims = builder.EndVector()
2720
+ if self.collapsedSliceDims is not None:
2721
+ if np is not None and type(self.collapsedSliceDims) is np.ndarray:
2722
+ collapsedSliceDims = builder.CreateNumpyVector(self.collapsedSliceDims)
2723
+ else:
2724
+ StablehloGatherOptionsStartCollapsedSliceDimsVector(builder, len(self.collapsedSliceDims))
2725
+ for i in reversed(range(len(self.collapsedSliceDims))):
2726
+ builder.PrependInt64(self.collapsedSliceDims[i])
2727
+ collapsedSliceDims = builder.EndVector()
2728
+ if self.startIndexMap is not None:
2729
+ if np is not None and type(self.startIndexMap) is np.ndarray:
2730
+ startIndexMap = builder.CreateNumpyVector(self.startIndexMap)
2731
+ else:
2732
+ StablehloGatherOptionsStartStartIndexMapVector(builder, len(self.startIndexMap))
2733
+ for i in reversed(range(len(self.startIndexMap))):
2734
+ builder.PrependInt64(self.startIndexMap[i])
2735
+ startIndexMap = builder.EndVector()
2736
+ if self.sliceSizes is not None:
2737
+ if np is not None and type(self.sliceSizes) is np.ndarray:
2738
+ sliceSizes = builder.CreateNumpyVector(self.sliceSizes)
2739
+ else:
2740
+ StablehloGatherOptionsStartSliceSizesVector(builder, len(self.sliceSizes))
2741
+ for i in reversed(range(len(self.sliceSizes))):
2742
+ builder.PrependInt64(self.sliceSizes[i])
2743
+ sliceSizes = builder.EndVector()
2744
+ StablehloGatherOptionsStart(builder)
2745
+ if self.offsetDims is not None:
2746
+ StablehloGatherOptionsAddOffsetDims(builder, offsetDims)
2747
+ if self.collapsedSliceDims is not None:
2748
+ StablehloGatherOptionsAddCollapsedSliceDims(builder, collapsedSliceDims)
2749
+ if self.startIndexMap is not None:
2750
+ StablehloGatherOptionsAddStartIndexMap(builder, startIndexMap)
2751
+ StablehloGatherOptionsAddIndexVectorDim(builder, self.indexVectorDim)
2752
+ if self.sliceSizes is not None:
2753
+ StablehloGatherOptionsAddSliceSizes(builder, sliceSizes)
2754
+ StablehloGatherOptionsAddIndicesAreSorted(builder, self.indicesAreSorted)
2755
+ stablehloGatherOptions = StablehloGatherOptionsEnd(builder)
2756
+ return stablehloGatherOptions
2757
+
2758
+
2759
+ class StablehloTransposeOptions(object):
2760
+ __slots__ = ['_tab']
2761
+
2762
+ @classmethod
2763
+ def GetRootAs(cls, buf, offset=0):
2764
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2765
+ x = StablehloTransposeOptions()
2766
+ x.Init(buf, n + offset)
2767
+ return x
2768
+
2769
+ @classmethod
2770
+ def GetRootAsStablehloTransposeOptions(cls, buf, offset=0):
2771
+ """This method is deprecated. Please switch to GetRootAs."""
2772
+ return cls.GetRootAs(buf, offset)
2773
+ @classmethod
2774
+ def StablehloTransposeOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
2775
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
2776
+
2777
+ # StablehloTransposeOptions
2778
+ def Init(self, buf, pos):
2779
+ self._tab = flatbuffers.table.Table(buf, pos)
2780
+
2781
+ # StablehloTransposeOptions
2782
+ def Permutation(self, j):
2783
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2784
+ if o != 0:
2785
+ a = self._tab.Vector(o)
2786
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
2787
+ return 0
2788
+
2789
+ # StablehloTransposeOptions
2790
+ def PermutationAsNumpy(self):
2791
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2792
+ if o != 0:
2793
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
2794
+ return 0
2795
+
2796
+ # StablehloTransposeOptions
2797
+ def PermutationLength(self):
2798
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2799
+ if o != 0:
2800
+ return self._tab.VectorLen(o)
2801
+ return 0
2802
+
2803
+ # StablehloTransposeOptions
2804
+ def PermutationIsNone(self):
2805
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2806
+ return o == 0
2807
+
2808
+ def StablehloTransposeOptionsStart(builder):
2809
+ builder.StartObject(1)
2810
+
2811
+ def StablehloTransposeOptionsAddPermutation(builder, permutation):
2812
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(permutation), 0)
2813
+
2814
+ def StablehloTransposeOptionsStartPermutationVector(builder, numElems):
2815
+ return builder.StartVector(8, numElems, 8)
2816
+
2817
+ def StablehloTransposeOptionsEnd(builder):
2818
+ return builder.EndObject()
2819
+
2820
+
2821
+ try:
2822
+ from typing import List
2823
+ except:
2824
+ pass
2825
+
2826
+ class StablehloTransposeOptionsT(object):
2827
+
2828
+ # StablehloTransposeOptionsT
2829
+ def __init__(self):
2830
+ self.permutation = None # type: List[int]
2831
+
2832
+ @classmethod
2833
+ def InitFromBuf(cls, buf, pos):
2834
+ stablehloTransposeOptions = StablehloTransposeOptions()
2835
+ stablehloTransposeOptions.Init(buf, pos)
2836
+ return cls.InitFromObj(stablehloTransposeOptions)
2837
+
2838
+ @classmethod
2839
+ def InitFromPackedBuf(cls, buf, pos=0):
2840
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
2841
+ return cls.InitFromBuf(buf, pos+n)
2842
+
2843
+ @classmethod
2844
+ def InitFromObj(cls, stablehloTransposeOptions):
2845
+ x = StablehloTransposeOptionsT()
2846
+ x._UnPack(stablehloTransposeOptions)
2847
+ return x
2848
+
2849
+ # StablehloTransposeOptionsT
2850
+ def _UnPack(self, stablehloTransposeOptions):
2851
+ if stablehloTransposeOptions is None:
2852
+ return
2853
+ if not stablehloTransposeOptions.PermutationIsNone():
2854
+ if np is None:
2855
+ self.permutation = []
2856
+ for i in range(stablehloTransposeOptions.PermutationLength()):
2857
+ self.permutation.append(stablehloTransposeOptions.Permutation(i))
2858
+ else:
2859
+ self.permutation = stablehloTransposeOptions.PermutationAsNumpy()
2860
+
2861
+ # StablehloTransposeOptionsT
2862
+ def Pack(self, builder):
2863
+ if self.permutation is not None:
2864
+ if np is not None and type(self.permutation) is np.ndarray:
2865
+ permutation = builder.CreateNumpyVector(self.permutation)
2866
+ else:
2867
+ StablehloTransposeOptionsStartPermutationVector(builder, len(self.permutation))
2868
+ for i in reversed(range(len(self.permutation))):
2869
+ builder.PrependInt64(self.permutation[i])
2870
+ permutation = builder.EndVector()
2871
+ StablehloTransposeOptionsStart(builder)
2872
+ if self.permutation is not None:
2873
+ StablehloTransposeOptionsAddPermutation(builder, permutation)
2874
+ stablehloTransposeOptions = StablehloTransposeOptionsEnd(builder)
2875
+ return stablehloTransposeOptions
2876
+
2877
+
2878
+ class StablehloDotGeneralOptions(object):
2879
+ __slots__ = ['_tab']
2880
+
2881
+ @classmethod
2882
+ def GetRootAs(cls, buf, offset=0):
2883
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2884
+ x = StablehloDotGeneralOptions()
2885
+ x.Init(buf, n + offset)
2886
+ return x
2887
+
2888
+ @classmethod
2889
+ def GetRootAsStablehloDotGeneralOptions(cls, buf, offset=0):
2890
+ """This method is deprecated. Please switch to GetRootAs."""
2891
+ return cls.GetRootAs(buf, offset)
2892
+ @classmethod
2893
+ def StablehloDotGeneralOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
2894
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
2895
+
2896
+ # StablehloDotGeneralOptions
2897
+ def Init(self, buf, pos):
2898
+ self._tab = flatbuffers.table.Table(buf, pos)
2899
+
2900
+ # StablehloDotGeneralOptions
2901
+ def LhsBatchingDimensions(self, j):
2902
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2903
+ if o != 0:
2904
+ a = self._tab.Vector(o)
2905
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
2906
+ return 0
2907
+
2908
+ # StablehloDotGeneralOptions
2909
+ def LhsBatchingDimensionsAsNumpy(self):
2910
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2911
+ if o != 0:
2912
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
2913
+ return 0
2914
+
2915
+ # StablehloDotGeneralOptions
2916
+ def LhsBatchingDimensionsLength(self):
2917
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2918
+ if o != 0:
2919
+ return self._tab.VectorLen(o)
2920
+ return 0
2921
+
2922
+ # StablehloDotGeneralOptions
2923
+ def LhsBatchingDimensionsIsNone(self):
2924
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2925
+ return o == 0
2926
+
2927
+ # StablehloDotGeneralOptions
2928
+ def RhsBatchingDimensions(self, j):
2929
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2930
+ if o != 0:
2931
+ a = self._tab.Vector(o)
2932
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
2933
+ return 0
2934
+
2935
+ # StablehloDotGeneralOptions
2936
+ def RhsBatchingDimensionsAsNumpy(self):
2937
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2938
+ if o != 0:
2939
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
2940
+ return 0
2941
+
2942
+ # StablehloDotGeneralOptions
2943
+ def RhsBatchingDimensionsLength(self):
2944
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2945
+ if o != 0:
2946
+ return self._tab.VectorLen(o)
2947
+ return 0
2948
+
2949
+ # StablehloDotGeneralOptions
2950
+ def RhsBatchingDimensionsIsNone(self):
2951
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2952
+ return o == 0
2953
+
2954
+ # StablehloDotGeneralOptions
2955
+ def LhsContractingDimensions(self, j):
2956
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2957
+ if o != 0:
2958
+ a = self._tab.Vector(o)
2959
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
2960
+ return 0
2961
+
2962
+ # StablehloDotGeneralOptions
2963
+ def LhsContractingDimensionsAsNumpy(self):
2964
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2965
+ if o != 0:
2966
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
2967
+ return 0
2968
+
2969
+ # StablehloDotGeneralOptions
2970
+ def LhsContractingDimensionsLength(self):
2971
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2972
+ if o != 0:
2973
+ return self._tab.VectorLen(o)
2974
+ return 0
2975
+
2976
+ # StablehloDotGeneralOptions
2977
+ def LhsContractingDimensionsIsNone(self):
2978
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2979
+ return o == 0
2980
+
2981
+ # StablehloDotGeneralOptions
2982
+ def RhsContractingDimensions(self, j):
2983
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2984
+ if o != 0:
2985
+ a = self._tab.Vector(o)
2986
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
2987
+ return 0
2988
+
2989
+ # StablehloDotGeneralOptions
2990
+ def RhsContractingDimensionsAsNumpy(self):
2991
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2992
+ if o != 0:
2993
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
2994
+ return 0
2995
+
2996
+ # StablehloDotGeneralOptions
2997
+ def RhsContractingDimensionsLength(self):
2998
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2999
+ if o != 0:
3000
+ return self._tab.VectorLen(o)
3001
+ return 0
3002
+
3003
+ # StablehloDotGeneralOptions
3004
+ def RhsContractingDimensionsIsNone(self):
3005
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
3006
+ return o == 0
3007
+
3008
+ # StablehloDotGeneralOptions
3009
+ def PrecisionConfig(self, j):
3010
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
3011
+ if o != 0:
3012
+ a = self._tab.Vector(o)
3013
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
3014
+ return 0
3015
+
3016
+ # StablehloDotGeneralOptions
3017
+ def PrecisionConfigAsNumpy(self):
3018
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
3019
+ if o != 0:
3020
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint32Flags, o)
3021
+ return 0
3022
+
3023
+ # StablehloDotGeneralOptions
3024
+ def PrecisionConfigLength(self):
3025
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
3026
+ if o != 0:
3027
+ return self._tab.VectorLen(o)
3028
+ return 0
3029
+
3030
+ # StablehloDotGeneralOptions
3031
+ def PrecisionConfigIsNone(self):
3032
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
3033
+ return o == 0
3034
+
3035
+ def StablehloDotGeneralOptionsStart(builder):
3036
+ builder.StartObject(5)
3037
+
3038
+ def StablehloDotGeneralOptionsAddLhsBatchingDimensions(builder, lhsBatchingDimensions):
3039
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(lhsBatchingDimensions), 0)
3040
+
3041
+ def StablehloDotGeneralOptionsStartLhsBatchingDimensionsVector(builder, numElems):
3042
+ return builder.StartVector(8, numElems, 8)
3043
+
3044
+ def StablehloDotGeneralOptionsAddRhsBatchingDimensions(builder, rhsBatchingDimensions):
3045
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(rhsBatchingDimensions), 0)
3046
+
3047
+ def StablehloDotGeneralOptionsStartRhsBatchingDimensionsVector(builder, numElems):
3048
+ return builder.StartVector(8, numElems, 8)
3049
+
3050
+ def StablehloDotGeneralOptionsAddLhsContractingDimensions(builder, lhsContractingDimensions):
3051
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(lhsContractingDimensions), 0)
3052
+
3053
+ def StablehloDotGeneralOptionsStartLhsContractingDimensionsVector(builder, numElems):
3054
+ return builder.StartVector(8, numElems, 8)
3055
+
3056
+ def StablehloDotGeneralOptionsAddRhsContractingDimensions(builder, rhsContractingDimensions):
3057
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(rhsContractingDimensions), 0)
3058
+
3059
+ def StablehloDotGeneralOptionsStartRhsContractingDimensionsVector(builder, numElems):
3060
+ return builder.StartVector(8, numElems, 8)
3061
+
3062
+ def StablehloDotGeneralOptionsAddPrecisionConfig(builder, precisionConfig):
3063
+ builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(precisionConfig), 0)
3064
+
3065
+ def StablehloDotGeneralOptionsStartPrecisionConfigVector(builder, numElems):
3066
+ return builder.StartVector(4, numElems, 4)
3067
+
3068
+ def StablehloDotGeneralOptionsEnd(builder):
3069
+ return builder.EndObject()
3070
+
3071
+
3072
+ try:
3073
+ from typing import List
3074
+ except:
3075
+ pass
3076
+
3077
+ class StablehloDotGeneralOptionsT(object):
3078
+
3079
+ # StablehloDotGeneralOptionsT
3080
+ def __init__(self):
3081
+ self.lhsBatchingDimensions = None # type: List[int]
3082
+ self.rhsBatchingDimensions = None # type: List[int]
3083
+ self.lhsContractingDimensions = None # type: List[int]
3084
+ self.rhsContractingDimensions = None # type: List[int]
3085
+ self.precisionConfig = None # type: List[int]
3086
+
3087
+ @classmethod
3088
+ def InitFromBuf(cls, buf, pos):
3089
+ stablehloDotGeneralOptions = StablehloDotGeneralOptions()
3090
+ stablehloDotGeneralOptions.Init(buf, pos)
3091
+ return cls.InitFromObj(stablehloDotGeneralOptions)
3092
+
3093
+ @classmethod
3094
+ def InitFromPackedBuf(cls, buf, pos=0):
3095
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
3096
+ return cls.InitFromBuf(buf, pos+n)
3097
+
3098
+ @classmethod
3099
+ def InitFromObj(cls, stablehloDotGeneralOptions):
3100
+ x = StablehloDotGeneralOptionsT()
3101
+ x._UnPack(stablehloDotGeneralOptions)
3102
+ return x
3103
+
3104
+ # StablehloDotGeneralOptionsT
3105
+ def _UnPack(self, stablehloDotGeneralOptions):
3106
+ if stablehloDotGeneralOptions is None:
3107
+ return
3108
+ if not stablehloDotGeneralOptions.LhsBatchingDimensionsIsNone():
3109
+ if np is None:
3110
+ self.lhsBatchingDimensions = []
3111
+ for i in range(stablehloDotGeneralOptions.LhsBatchingDimensionsLength()):
3112
+ self.lhsBatchingDimensions.append(stablehloDotGeneralOptions.LhsBatchingDimensions(i))
3113
+ else:
3114
+ self.lhsBatchingDimensions = stablehloDotGeneralOptions.LhsBatchingDimensionsAsNumpy()
3115
+ if not stablehloDotGeneralOptions.RhsBatchingDimensionsIsNone():
3116
+ if np is None:
3117
+ self.rhsBatchingDimensions = []
3118
+ for i in range(stablehloDotGeneralOptions.RhsBatchingDimensionsLength()):
3119
+ self.rhsBatchingDimensions.append(stablehloDotGeneralOptions.RhsBatchingDimensions(i))
3120
+ else:
3121
+ self.rhsBatchingDimensions = stablehloDotGeneralOptions.RhsBatchingDimensionsAsNumpy()
3122
+ if not stablehloDotGeneralOptions.LhsContractingDimensionsIsNone():
3123
+ if np is None:
3124
+ self.lhsContractingDimensions = []
3125
+ for i in range(stablehloDotGeneralOptions.LhsContractingDimensionsLength()):
3126
+ self.lhsContractingDimensions.append(stablehloDotGeneralOptions.LhsContractingDimensions(i))
3127
+ else:
3128
+ self.lhsContractingDimensions = stablehloDotGeneralOptions.LhsContractingDimensionsAsNumpy()
3129
+ if not stablehloDotGeneralOptions.RhsContractingDimensionsIsNone():
3130
+ if np is None:
3131
+ self.rhsContractingDimensions = []
3132
+ for i in range(stablehloDotGeneralOptions.RhsContractingDimensionsLength()):
3133
+ self.rhsContractingDimensions.append(stablehloDotGeneralOptions.RhsContractingDimensions(i))
3134
+ else:
3135
+ self.rhsContractingDimensions = stablehloDotGeneralOptions.RhsContractingDimensionsAsNumpy()
3136
+ if not stablehloDotGeneralOptions.PrecisionConfigIsNone():
3137
+ if np is None:
3138
+ self.precisionConfig = []
3139
+ for i in range(stablehloDotGeneralOptions.PrecisionConfigLength()):
3140
+ self.precisionConfig.append(stablehloDotGeneralOptions.PrecisionConfig(i))
3141
+ else:
3142
+ self.precisionConfig = stablehloDotGeneralOptions.PrecisionConfigAsNumpy()
3143
+
3144
+ # StablehloDotGeneralOptionsT
3145
+ def Pack(self, builder):
3146
+ if self.lhsBatchingDimensions is not None:
3147
+ if np is not None and type(self.lhsBatchingDimensions) is np.ndarray:
3148
+ lhsBatchingDimensions = builder.CreateNumpyVector(self.lhsBatchingDimensions)
3149
+ else:
3150
+ StablehloDotGeneralOptionsStartLhsBatchingDimensionsVector(builder, len(self.lhsBatchingDimensions))
3151
+ for i in reversed(range(len(self.lhsBatchingDimensions))):
3152
+ builder.PrependInt64(self.lhsBatchingDimensions[i])
3153
+ lhsBatchingDimensions = builder.EndVector()
3154
+ if self.rhsBatchingDimensions is not None:
3155
+ if np is not None and type(self.rhsBatchingDimensions) is np.ndarray:
3156
+ rhsBatchingDimensions = builder.CreateNumpyVector(self.rhsBatchingDimensions)
3157
+ else:
3158
+ StablehloDotGeneralOptionsStartRhsBatchingDimensionsVector(builder, len(self.rhsBatchingDimensions))
3159
+ for i in reversed(range(len(self.rhsBatchingDimensions))):
3160
+ builder.PrependInt64(self.rhsBatchingDimensions[i])
3161
+ rhsBatchingDimensions = builder.EndVector()
3162
+ if self.lhsContractingDimensions is not None:
3163
+ if np is not None and type(self.lhsContractingDimensions) is np.ndarray:
3164
+ lhsContractingDimensions = builder.CreateNumpyVector(self.lhsContractingDimensions)
3165
+ else:
3166
+ StablehloDotGeneralOptionsStartLhsContractingDimensionsVector(builder, len(self.lhsContractingDimensions))
3167
+ for i in reversed(range(len(self.lhsContractingDimensions))):
3168
+ builder.PrependInt64(self.lhsContractingDimensions[i])
3169
+ lhsContractingDimensions = builder.EndVector()
3170
+ if self.rhsContractingDimensions is not None:
3171
+ if np is not None and type(self.rhsContractingDimensions) is np.ndarray:
3172
+ rhsContractingDimensions = builder.CreateNumpyVector(self.rhsContractingDimensions)
3173
+ else:
3174
+ StablehloDotGeneralOptionsStartRhsContractingDimensionsVector(builder, len(self.rhsContractingDimensions))
3175
+ for i in reversed(range(len(self.rhsContractingDimensions))):
3176
+ builder.PrependInt64(self.rhsContractingDimensions[i])
3177
+ rhsContractingDimensions = builder.EndVector()
3178
+ if self.precisionConfig is not None:
3179
+ if np is not None and type(self.precisionConfig) is np.ndarray:
3180
+ precisionConfig = builder.CreateNumpyVector(self.precisionConfig)
3181
+ else:
3182
+ StablehloDotGeneralOptionsStartPrecisionConfigVector(builder, len(self.precisionConfig))
3183
+ for i in reversed(range(len(self.precisionConfig))):
3184
+ builder.PrependUint32(self.precisionConfig[i])
3185
+ precisionConfig = builder.EndVector()
3186
+ StablehloDotGeneralOptionsStart(builder)
3187
+ if self.lhsBatchingDimensions is not None:
3188
+ StablehloDotGeneralOptionsAddLhsBatchingDimensions(builder, lhsBatchingDimensions)
3189
+ if self.rhsBatchingDimensions is not None:
3190
+ StablehloDotGeneralOptionsAddRhsBatchingDimensions(builder, rhsBatchingDimensions)
3191
+ if self.lhsContractingDimensions is not None:
3192
+ StablehloDotGeneralOptionsAddLhsContractingDimensions(builder, lhsContractingDimensions)
3193
+ if self.rhsContractingDimensions is not None:
3194
+ StablehloDotGeneralOptionsAddRhsContractingDimensions(builder, rhsContractingDimensions)
3195
+ if self.precisionConfig is not None:
3196
+ StablehloDotGeneralOptionsAddPrecisionConfig(builder, precisionConfig)
3197
+ stablehloDotGeneralOptions = StablehloDotGeneralOptionsEnd(builder)
3198
+ return stablehloDotGeneralOptions
3199
+
3200
+
3201
+ class StablehloReduceWindowOptions(object):
3202
+ __slots__ = ['_tab']
3203
+
3204
+ @classmethod
3205
+ def GetRootAs(cls, buf, offset=0):
3206
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
3207
+ x = StablehloReduceWindowOptions()
3208
+ x.Init(buf, n + offset)
3209
+ return x
3210
+
3211
+ @classmethod
3212
+ def GetRootAsStablehloReduceWindowOptions(cls, buf, offset=0):
3213
+ """This method is deprecated. Please switch to GetRootAs."""
3214
+ return cls.GetRootAs(buf, offset)
3215
+ @classmethod
3216
+ def StablehloReduceWindowOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
3217
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
3218
+
3219
+ # StablehloReduceWindowOptions
3220
+ def Init(self, buf, pos):
3221
+ self._tab = flatbuffers.table.Table(buf, pos)
3222
+
3223
+ # StablehloReduceWindowOptions
3224
+ def WindowDimensions(self, j):
3225
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
3226
+ if o != 0:
3227
+ a = self._tab.Vector(o)
3228
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
3229
+ return 0
3230
+
3231
+ # StablehloReduceWindowOptions
3232
+ def WindowDimensionsAsNumpy(self):
3233
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
3234
+ if o != 0:
3235
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
3236
+ return 0
3237
+
3238
+ # StablehloReduceWindowOptions
3239
+ def WindowDimensionsLength(self):
3240
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
3241
+ if o != 0:
3242
+ return self._tab.VectorLen(o)
3243
+ return 0
3244
+
3245
+ # StablehloReduceWindowOptions
3246
+ def WindowDimensionsIsNone(self):
3247
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
3248
+ return o == 0
3249
+
3250
+ # StablehloReduceWindowOptions
3251
+ def WindowStrides(self, j):
3252
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
3253
+ if o != 0:
3254
+ a = self._tab.Vector(o)
3255
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
3256
+ return 0
3257
+
3258
+ # StablehloReduceWindowOptions
3259
+ def WindowStridesAsNumpy(self):
3260
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
3261
+ if o != 0:
3262
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
3263
+ return 0
3264
+
3265
+ # StablehloReduceWindowOptions
3266
+ def WindowStridesLength(self):
3267
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
3268
+ if o != 0:
3269
+ return self._tab.VectorLen(o)
3270
+ return 0
3271
+
3272
+ # StablehloReduceWindowOptions
3273
+ def WindowStridesIsNone(self):
3274
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
3275
+ return o == 0
3276
+
3277
+ # StablehloReduceWindowOptions
3278
+ def BaseDilations(self, j):
3279
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
3280
+ if o != 0:
3281
+ a = self._tab.Vector(o)
3282
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
3283
+ return 0
3284
+
3285
+ # StablehloReduceWindowOptions
3286
+ def BaseDilationsAsNumpy(self):
3287
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
3288
+ if o != 0:
3289
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
3290
+ return 0
3291
+
3292
+ # StablehloReduceWindowOptions
3293
+ def BaseDilationsLength(self):
3294
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
3295
+ if o != 0:
3296
+ return self._tab.VectorLen(o)
3297
+ return 0
3298
+
3299
+ # StablehloReduceWindowOptions
3300
+ def BaseDilationsIsNone(self):
3301
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
3302
+ return o == 0
3303
+
3304
+ # StablehloReduceWindowOptions
3305
+ def WindowDilations(self, j):
3306
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
3307
+ if o != 0:
3308
+ a = self._tab.Vector(o)
3309
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
3310
+ return 0
3311
+
3312
+ # StablehloReduceWindowOptions
3313
+ def WindowDilationsAsNumpy(self):
3314
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
3315
+ if o != 0:
3316
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
3317
+ return 0
3318
+
3319
+ # StablehloReduceWindowOptions
3320
+ def WindowDilationsLength(self):
3321
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
3322
+ if o != 0:
3323
+ return self._tab.VectorLen(o)
3324
+ return 0
3325
+
3326
+ # StablehloReduceWindowOptions
3327
+ def WindowDilationsIsNone(self):
3328
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
3329
+ return o == 0
3330
+
3331
+ # StablehloReduceWindowOptions
3332
+ def Padding(self, j):
3333
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
3334
+ if o != 0:
3335
+ a = self._tab.Vector(o)
3336
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
3337
+ return 0
3338
+
3339
+ # StablehloReduceWindowOptions
3340
+ def PaddingAsNumpy(self):
3341
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
3342
+ if o != 0:
3343
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
3344
+ return 0
3345
+
3346
+ # StablehloReduceWindowOptions
3347
+ def PaddingLength(self):
3348
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
3349
+ if o != 0:
3350
+ return self._tab.VectorLen(o)
3351
+ return 0
3352
+
3353
+ # StablehloReduceWindowOptions
3354
+ def PaddingIsNone(self):
3355
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
3356
+ return o == 0
3357
+
3358
+ # StablehloReduceWindowOptions
3359
+ def BodySubgraphIndex(self):
3360
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
3361
+ if o != 0:
3362
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
3363
+ return 0
3364
+
3365
+ def StablehloReduceWindowOptionsStart(builder):
3366
+ builder.StartObject(6)
3367
+
3368
+ def StablehloReduceWindowOptionsAddWindowDimensions(builder, windowDimensions):
3369
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(windowDimensions), 0)
3370
+
3371
+ def StablehloReduceWindowOptionsStartWindowDimensionsVector(builder, numElems):
3372
+ return builder.StartVector(8, numElems, 8)
3373
+
3374
+ def StablehloReduceWindowOptionsAddWindowStrides(builder, windowStrides):
3375
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(windowStrides), 0)
3376
+
3377
+ def StablehloReduceWindowOptionsStartWindowStridesVector(builder, numElems):
3378
+ return builder.StartVector(8, numElems, 8)
3379
+
3380
+ def StablehloReduceWindowOptionsAddBaseDilations(builder, baseDilations):
3381
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(baseDilations), 0)
3382
+
3383
+ def StablehloReduceWindowOptionsStartBaseDilationsVector(builder, numElems):
3384
+ return builder.StartVector(8, numElems, 8)
3385
+
3386
+ def StablehloReduceWindowOptionsAddWindowDilations(builder, windowDilations):
3387
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(windowDilations), 0)
3388
+
3389
+ def StablehloReduceWindowOptionsStartWindowDilationsVector(builder, numElems):
3390
+ return builder.StartVector(8, numElems, 8)
3391
+
3392
+ def StablehloReduceWindowOptionsAddPadding(builder, padding):
3393
+ builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(padding), 0)
3394
+
3395
+ def StablehloReduceWindowOptionsStartPaddingVector(builder, numElems):
3396
+ return builder.StartVector(8, numElems, 8)
3397
+
3398
+ def StablehloReduceWindowOptionsAddBodySubgraphIndex(builder, bodySubgraphIndex):
3399
+ builder.PrependInt32Slot(5, bodySubgraphIndex, 0)
3400
+
3401
+ def StablehloReduceWindowOptionsEnd(builder):
3402
+ return builder.EndObject()
3403
+
3404
+
3405
+ try:
3406
+ from typing import List
3407
+ except:
3408
+ pass
3409
+
3410
+ class StablehloReduceWindowOptionsT(object):
3411
+
3412
+ # StablehloReduceWindowOptionsT
3413
+ def __init__(self):
3414
+ self.windowDimensions = None # type: List[int]
3415
+ self.windowStrides = None # type: List[int]
3416
+ self.baseDilations = None # type: List[int]
3417
+ self.windowDilations = None # type: List[int]
3418
+ self.padding = None # type: List[int]
3419
+ self.bodySubgraphIndex = 0 # type: int
3420
+
3421
+ @classmethod
3422
+ def InitFromBuf(cls, buf, pos):
3423
+ stablehloReduceWindowOptions = StablehloReduceWindowOptions()
3424
+ stablehloReduceWindowOptions.Init(buf, pos)
3425
+ return cls.InitFromObj(stablehloReduceWindowOptions)
3426
+
3427
+ @classmethod
3428
+ def InitFromPackedBuf(cls, buf, pos=0):
3429
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
3430
+ return cls.InitFromBuf(buf, pos+n)
3431
+
3432
+ @classmethod
3433
+ def InitFromObj(cls, stablehloReduceWindowOptions):
3434
+ x = StablehloReduceWindowOptionsT()
3435
+ x._UnPack(stablehloReduceWindowOptions)
3436
+ return x
3437
+
3438
+ # StablehloReduceWindowOptionsT
3439
+ def _UnPack(self, stablehloReduceWindowOptions):
3440
+ if stablehloReduceWindowOptions is None:
3441
+ return
3442
+ if not stablehloReduceWindowOptions.WindowDimensionsIsNone():
3443
+ if np is None:
3444
+ self.windowDimensions = []
3445
+ for i in range(stablehloReduceWindowOptions.WindowDimensionsLength()):
3446
+ self.windowDimensions.append(stablehloReduceWindowOptions.WindowDimensions(i))
3447
+ else:
3448
+ self.windowDimensions = stablehloReduceWindowOptions.WindowDimensionsAsNumpy()
3449
+ if not stablehloReduceWindowOptions.WindowStridesIsNone():
3450
+ if np is None:
3451
+ self.windowStrides = []
3452
+ for i in range(stablehloReduceWindowOptions.WindowStridesLength()):
3453
+ self.windowStrides.append(stablehloReduceWindowOptions.WindowStrides(i))
3454
+ else:
3455
+ self.windowStrides = stablehloReduceWindowOptions.WindowStridesAsNumpy()
3456
+ if not stablehloReduceWindowOptions.BaseDilationsIsNone():
3457
+ if np is None:
3458
+ self.baseDilations = []
3459
+ for i in range(stablehloReduceWindowOptions.BaseDilationsLength()):
3460
+ self.baseDilations.append(stablehloReduceWindowOptions.BaseDilations(i))
3461
+ else:
3462
+ self.baseDilations = stablehloReduceWindowOptions.BaseDilationsAsNumpy()
3463
+ if not stablehloReduceWindowOptions.WindowDilationsIsNone():
3464
+ if np is None:
3465
+ self.windowDilations = []
3466
+ for i in range(stablehloReduceWindowOptions.WindowDilationsLength()):
3467
+ self.windowDilations.append(stablehloReduceWindowOptions.WindowDilations(i))
3468
+ else:
3469
+ self.windowDilations = stablehloReduceWindowOptions.WindowDilationsAsNumpy()
3470
+ if not stablehloReduceWindowOptions.PaddingIsNone():
3471
+ if np is None:
3472
+ self.padding = []
3473
+ for i in range(stablehloReduceWindowOptions.PaddingLength()):
3474
+ self.padding.append(stablehloReduceWindowOptions.Padding(i))
3475
+ else:
3476
+ self.padding = stablehloReduceWindowOptions.PaddingAsNumpy()
3477
+ self.bodySubgraphIndex = stablehloReduceWindowOptions.BodySubgraphIndex()
3478
+
3479
+ # StablehloReduceWindowOptionsT
3480
+ def Pack(self, builder):
3481
+ if self.windowDimensions is not None:
3482
+ if np is not None and type(self.windowDimensions) is np.ndarray:
3483
+ windowDimensions = builder.CreateNumpyVector(self.windowDimensions)
3484
+ else:
3485
+ StablehloReduceWindowOptionsStartWindowDimensionsVector(builder, len(self.windowDimensions))
3486
+ for i in reversed(range(len(self.windowDimensions))):
3487
+ builder.PrependInt64(self.windowDimensions[i])
3488
+ windowDimensions = builder.EndVector()
3489
+ if self.windowStrides is not None:
3490
+ if np is not None and type(self.windowStrides) is np.ndarray:
3491
+ windowStrides = builder.CreateNumpyVector(self.windowStrides)
3492
+ else:
3493
+ StablehloReduceWindowOptionsStartWindowStridesVector(builder, len(self.windowStrides))
3494
+ for i in reversed(range(len(self.windowStrides))):
3495
+ builder.PrependInt64(self.windowStrides[i])
3496
+ windowStrides = builder.EndVector()
3497
+ if self.baseDilations is not None:
3498
+ if np is not None and type(self.baseDilations) is np.ndarray:
3499
+ baseDilations = builder.CreateNumpyVector(self.baseDilations)
3500
+ else:
3501
+ StablehloReduceWindowOptionsStartBaseDilationsVector(builder, len(self.baseDilations))
3502
+ for i in reversed(range(len(self.baseDilations))):
3503
+ builder.PrependInt64(self.baseDilations[i])
3504
+ baseDilations = builder.EndVector()
3505
+ if self.windowDilations is not None:
3506
+ if np is not None and type(self.windowDilations) is np.ndarray:
3507
+ windowDilations = builder.CreateNumpyVector(self.windowDilations)
3508
+ else:
3509
+ StablehloReduceWindowOptionsStartWindowDilationsVector(builder, len(self.windowDilations))
3510
+ for i in reversed(range(len(self.windowDilations))):
3511
+ builder.PrependInt64(self.windowDilations[i])
3512
+ windowDilations = builder.EndVector()
3513
+ if self.padding is not None:
3514
+ if np is not None and type(self.padding) is np.ndarray:
3515
+ padding = builder.CreateNumpyVector(self.padding)
3516
+ else:
3517
+ StablehloReduceWindowOptionsStartPaddingVector(builder, len(self.padding))
3518
+ for i in reversed(range(len(self.padding))):
3519
+ builder.PrependInt64(self.padding[i])
3520
+ padding = builder.EndVector()
3521
+ StablehloReduceWindowOptionsStart(builder)
3522
+ if self.windowDimensions is not None:
3523
+ StablehloReduceWindowOptionsAddWindowDimensions(builder, windowDimensions)
3524
+ if self.windowStrides is not None:
3525
+ StablehloReduceWindowOptionsAddWindowStrides(builder, windowStrides)
3526
+ if self.baseDilations is not None:
3527
+ StablehloReduceWindowOptionsAddBaseDilations(builder, baseDilations)
3528
+ if self.windowDilations is not None:
3529
+ StablehloReduceWindowOptionsAddWindowDilations(builder, windowDilations)
3530
+ if self.padding is not None:
3531
+ StablehloReduceWindowOptionsAddPadding(builder, padding)
3532
+ StablehloReduceWindowOptionsAddBodySubgraphIndex(builder, self.bodySubgraphIndex)
3533
+ stablehloReduceWindowOptions = StablehloReduceWindowOptionsEnd(builder)
3534
+ return stablehloReduceWindowOptions
3535
+
3536
+
3537
+ class StablehloWhileOptions(object):
3538
+ __slots__ = ['_tab']
3539
+
3540
+ @classmethod
3541
+ def GetRootAs(cls, buf, offset=0):
3542
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
3543
+ x = StablehloWhileOptions()
3544
+ x.Init(buf, n + offset)
3545
+ return x
3546
+
3547
+ @classmethod
3548
+ def GetRootAsStablehloWhileOptions(cls, buf, offset=0):
3549
+ """This method is deprecated. Please switch to GetRootAs."""
3550
+ return cls.GetRootAs(buf, offset)
3551
+ @classmethod
3552
+ def StablehloWhileOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
3553
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
3554
+
3555
+ # StablehloWhileOptions
3556
+ def Init(self, buf, pos):
3557
+ self._tab = flatbuffers.table.Table(buf, pos)
3558
+
3559
+ # StablehloWhileOptions
3560
+ def CondSubgraphIndex(self):
3561
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
3562
+ if o != 0:
3563
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
3564
+ return 0
3565
+
3566
+ # StablehloWhileOptions
3567
+ def BodySubgraphIndex(self):
3568
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
3569
+ if o != 0:
3570
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
3571
+ return 0
3572
+
3573
+ def StablehloWhileOptionsStart(builder):
3574
+ builder.StartObject(2)
3575
+
3576
+ def StablehloWhileOptionsAddCondSubgraphIndex(builder, condSubgraphIndex):
3577
+ builder.PrependInt32Slot(0, condSubgraphIndex, 0)
3578
+
3579
+ def StablehloWhileOptionsAddBodySubgraphIndex(builder, bodySubgraphIndex):
3580
+ builder.PrependInt32Slot(1, bodySubgraphIndex, 0)
3581
+
3582
+ def StablehloWhileOptionsEnd(builder):
3583
+ return builder.EndObject()
3584
+
3585
+
3586
+
3587
+ class StablehloWhileOptionsT(object):
3588
+
3589
+ # StablehloWhileOptionsT
3590
+ def __init__(self):
3591
+ self.condSubgraphIndex = 0 # type: int
3592
+ self.bodySubgraphIndex = 0 # type: int
3593
+
3594
+ @classmethod
3595
+ def InitFromBuf(cls, buf, pos):
3596
+ stablehloWhileOptions = StablehloWhileOptions()
3597
+ stablehloWhileOptions.Init(buf, pos)
3598
+ return cls.InitFromObj(stablehloWhileOptions)
3599
+
3600
+ @classmethod
3601
+ def InitFromPackedBuf(cls, buf, pos=0):
3602
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
3603
+ return cls.InitFromBuf(buf, pos+n)
3604
+
3605
+ @classmethod
3606
+ def InitFromObj(cls, stablehloWhileOptions):
3607
+ x = StablehloWhileOptionsT()
3608
+ x._UnPack(stablehloWhileOptions)
3609
+ return x
3610
+
3611
+ # StablehloWhileOptionsT
3612
+ def _UnPack(self, stablehloWhileOptions):
3613
+ if stablehloWhileOptions is None:
3614
+ return
3615
+ self.condSubgraphIndex = stablehloWhileOptions.CondSubgraphIndex()
3616
+ self.bodySubgraphIndex = stablehloWhileOptions.BodySubgraphIndex()
3617
+
3618
+ # StablehloWhileOptionsT
3619
+ def Pack(self, builder):
3620
+ StablehloWhileOptionsStart(builder)
3621
+ StablehloWhileOptionsAddCondSubgraphIndex(builder, self.condSubgraphIndex)
3622
+ StablehloWhileOptionsAddBodySubgraphIndex(builder, self.bodySubgraphIndex)
3623
+ stablehloWhileOptions = StablehloWhileOptionsEnd(builder)
3624
+ return stablehloWhileOptions
3625
+
3626
+
3627
+ class StablehloSortOptions(object):
3628
+ __slots__ = ['_tab']
3629
+
3630
+ @classmethod
3631
+ def GetRootAs(cls, buf, offset=0):
3632
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
3633
+ x = StablehloSortOptions()
3634
+ x.Init(buf, n + offset)
3635
+ return x
3636
+
3637
+ @classmethod
3638
+ def GetRootAsStablehloSortOptions(cls, buf, offset=0):
3639
+ """This method is deprecated. Please switch to GetRootAs."""
3640
+ return cls.GetRootAs(buf, offset)
3641
+ @classmethod
3642
+ def StablehloSortOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
3643
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
3644
+
3645
+ # StablehloSortOptions
3646
+ def Init(self, buf, pos):
3647
+ self._tab = flatbuffers.table.Table(buf, pos)
3648
+
3649
+ # StablehloSortOptions
3650
+ def Dimension(self):
3651
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
3652
+ if o != 0:
3653
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
3654
+ return 0
3655
+
3656
+ # StablehloSortOptions
3657
+ def IsStable(self):
3658
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
3659
+ if o != 0:
3660
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
3661
+ return False
3662
+
3663
+ # StablehloSortOptions
3664
+ def ComparatorSubgraphIndex(self):
3665
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
3666
+ if o != 0:
3667
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
3668
+ return 0
3669
+
3670
+ def StablehloSortOptionsStart(builder):
3671
+ builder.StartObject(3)
3672
+
3673
+ def StablehloSortOptionsAddDimension(builder, dimension):
3674
+ builder.PrependInt64Slot(0, dimension, 0)
3675
+
3676
+ def StablehloSortOptionsAddIsStable(builder, isStable):
3677
+ builder.PrependBoolSlot(1, isStable, 0)
3678
+
3679
+ def StablehloSortOptionsAddComparatorSubgraphIndex(builder, comparatorSubgraphIndex):
3680
+ builder.PrependInt32Slot(2, comparatorSubgraphIndex, 0)
3681
+
3682
+ def StablehloSortOptionsEnd(builder):
3683
+ return builder.EndObject()
3684
+
3685
+
3686
+
3687
+ class StablehloSortOptionsT(object):
3688
+
3689
+ # StablehloSortOptionsT
3690
+ def __init__(self):
3691
+ self.dimension = 0 # type: int
3692
+ self.isStable = False # type: bool
3693
+ self.comparatorSubgraphIndex = 0 # type: int
3694
+
3695
+ @classmethod
3696
+ def InitFromBuf(cls, buf, pos):
3697
+ stablehloSortOptions = StablehloSortOptions()
3698
+ stablehloSortOptions.Init(buf, pos)
3699
+ return cls.InitFromObj(stablehloSortOptions)
3700
+
3701
+ @classmethod
3702
+ def InitFromPackedBuf(cls, buf, pos=0):
3703
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
3704
+ return cls.InitFromBuf(buf, pos+n)
3705
+
3706
+ @classmethod
3707
+ def InitFromObj(cls, stablehloSortOptions):
3708
+ x = StablehloSortOptionsT()
3709
+ x._UnPack(stablehloSortOptions)
3710
+ return x
3711
+
3712
+ # StablehloSortOptionsT
3713
+ def _UnPack(self, stablehloSortOptions):
3714
+ if stablehloSortOptions is None:
3715
+ return
3716
+ self.dimension = stablehloSortOptions.Dimension()
3717
+ self.isStable = stablehloSortOptions.IsStable()
3718
+ self.comparatorSubgraphIndex = stablehloSortOptions.ComparatorSubgraphIndex()
3719
+
3720
+ # StablehloSortOptionsT
3721
+ def Pack(self, builder):
3722
+ StablehloSortOptionsStart(builder)
3723
+ StablehloSortOptionsAddDimension(builder, self.dimension)
3724
+ StablehloSortOptionsAddIsStable(builder, self.isStable)
3725
+ StablehloSortOptionsAddComparatorSubgraphIndex(builder, self.comparatorSubgraphIndex)
3726
+ stablehloSortOptions = StablehloSortOptionsEnd(builder)
3727
+ return stablehloSortOptions
3728
+
3729
+
3730
+ class StablehloConcatenateOptions(object):
3731
+ __slots__ = ['_tab']
3732
+
3733
+ @classmethod
3734
+ def GetRootAs(cls, buf, offset=0):
3735
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
3736
+ x = StablehloConcatenateOptions()
3737
+ x.Init(buf, n + offset)
3738
+ return x
3739
+
3740
+ @classmethod
3741
+ def GetRootAsStablehloConcatenateOptions(cls, buf, offset=0):
3742
+ """This method is deprecated. Please switch to GetRootAs."""
3743
+ return cls.GetRootAs(buf, offset)
3744
+ @classmethod
3745
+ def StablehloConcatenateOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
3746
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
3747
+
3748
+ # StablehloConcatenateOptions
3749
+ def Init(self, buf, pos):
3750
+ self._tab = flatbuffers.table.Table(buf, pos)
3751
+
3752
+ # StablehloConcatenateOptions
3753
+ def Dimension(self):
3754
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
3755
+ if o != 0:
3756
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
3757
+ return 0
3758
+
3759
+ def StablehloConcatenateOptionsStart(builder):
3760
+ builder.StartObject(1)
3761
+
3762
+ def StablehloConcatenateOptionsAddDimension(builder, dimension):
3763
+ builder.PrependInt64Slot(0, dimension, 0)
3764
+
3765
+ def StablehloConcatenateOptionsEnd(builder):
3766
+ return builder.EndObject()
3767
+
3768
+
3769
+
3770
+ class StablehloConcatenateOptionsT(object):
3771
+
3772
+ # StablehloConcatenateOptionsT
3773
+ def __init__(self):
3774
+ self.dimension = 0 # type: int
3775
+
3776
+ @classmethod
3777
+ def InitFromBuf(cls, buf, pos):
3778
+ stablehloConcatenateOptions = StablehloConcatenateOptions()
3779
+ stablehloConcatenateOptions.Init(buf, pos)
3780
+ return cls.InitFromObj(stablehloConcatenateOptions)
3781
+
3782
+ @classmethod
3783
+ def InitFromPackedBuf(cls, buf, pos=0):
3784
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
3785
+ return cls.InitFromBuf(buf, pos+n)
3786
+
3787
+ @classmethod
3788
+ def InitFromObj(cls, stablehloConcatenateOptions):
3789
+ x = StablehloConcatenateOptionsT()
3790
+ x._UnPack(stablehloConcatenateOptions)
3791
+ return x
3792
+
3793
+ # StablehloConcatenateOptionsT
3794
+ def _UnPack(self, stablehloConcatenateOptions):
3795
+ if stablehloConcatenateOptions is None:
3796
+ return
3797
+ self.dimension = stablehloConcatenateOptions.Dimension()
3798
+
3799
+ # StablehloConcatenateOptionsT
3800
+ def Pack(self, builder):
3801
+ StablehloConcatenateOptionsStart(builder)
3802
+ StablehloConcatenateOptionsAddDimension(builder, self.dimension)
3803
+ stablehloConcatenateOptions = StablehloConcatenateOptionsEnd(builder)
3804
+ return stablehloConcatenateOptions
3805
+
3806
+
3807
+ class StablehloBroadcastInDimOptions(object):
3808
+ __slots__ = ['_tab']
3809
+
3810
+ @classmethod
3811
+ def GetRootAs(cls, buf, offset=0):
3812
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
3813
+ x = StablehloBroadcastInDimOptions()
3814
+ x.Init(buf, n + offset)
3815
+ return x
3816
+
3817
+ @classmethod
3818
+ def GetRootAsStablehloBroadcastInDimOptions(cls, buf, offset=0):
3819
+ """This method is deprecated. Please switch to GetRootAs."""
3820
+ return cls.GetRootAs(buf, offset)
3821
+ @classmethod
3822
+ def StablehloBroadcastInDimOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
3823
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
3824
+
3825
+ # StablehloBroadcastInDimOptions
3826
+ def Init(self, buf, pos):
3827
+ self._tab = flatbuffers.table.Table(buf, pos)
3828
+
3829
+ # StablehloBroadcastInDimOptions
3830
+ def BroadcastDimensions(self, j):
3831
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
3832
+ if o != 0:
3833
+ a = self._tab.Vector(o)
3834
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
3835
+ return 0
3836
+
3837
+ # StablehloBroadcastInDimOptions
3838
+ def BroadcastDimensionsAsNumpy(self):
3839
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
3840
+ if o != 0:
3841
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
3842
+ return 0
3843
+
3844
+ # StablehloBroadcastInDimOptions
3845
+ def BroadcastDimensionsLength(self):
3846
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
3847
+ if o != 0:
3848
+ return self._tab.VectorLen(o)
3849
+ return 0
3850
+
3851
+ # StablehloBroadcastInDimOptions
3852
+ def BroadcastDimensionsIsNone(self):
3853
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
3854
+ return o == 0
3855
+
3856
+ def StablehloBroadcastInDimOptionsStart(builder):
3857
+ builder.StartObject(1)
3858
+
3859
+ def StablehloBroadcastInDimOptionsAddBroadcastDimensions(builder, broadcastDimensions):
3860
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(broadcastDimensions), 0)
3861
+
3862
+ def StablehloBroadcastInDimOptionsStartBroadcastDimensionsVector(builder, numElems):
3863
+ return builder.StartVector(8, numElems, 8)
3864
+
3865
+ def StablehloBroadcastInDimOptionsEnd(builder):
3866
+ return builder.EndObject()
3867
+
3868
+
3869
+ try:
3870
+ from typing import List
3871
+ except:
3872
+ pass
3873
+
3874
+ class StablehloBroadcastInDimOptionsT(object):
3875
+
3876
+ # StablehloBroadcastInDimOptionsT
3877
+ def __init__(self):
3878
+ self.broadcastDimensions = None # type: List[int]
3879
+
3880
+ @classmethod
3881
+ def InitFromBuf(cls, buf, pos):
3882
+ stablehloBroadcastInDimOptions = StablehloBroadcastInDimOptions()
3883
+ stablehloBroadcastInDimOptions.Init(buf, pos)
3884
+ return cls.InitFromObj(stablehloBroadcastInDimOptions)
3885
+
3886
+ @classmethod
3887
+ def InitFromPackedBuf(cls, buf, pos=0):
3888
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
3889
+ return cls.InitFromBuf(buf, pos+n)
3890
+
3891
+ @classmethod
3892
+ def InitFromObj(cls, stablehloBroadcastInDimOptions):
3893
+ x = StablehloBroadcastInDimOptionsT()
3894
+ x._UnPack(stablehloBroadcastInDimOptions)
3895
+ return x
3896
+
3897
+ # StablehloBroadcastInDimOptionsT
3898
+ def _UnPack(self, stablehloBroadcastInDimOptions):
3899
+ if stablehloBroadcastInDimOptions is None:
3900
+ return
3901
+ if not stablehloBroadcastInDimOptions.BroadcastDimensionsIsNone():
3902
+ if np is None:
3903
+ self.broadcastDimensions = []
3904
+ for i in range(stablehloBroadcastInDimOptions.BroadcastDimensionsLength()):
3905
+ self.broadcastDimensions.append(stablehloBroadcastInDimOptions.BroadcastDimensions(i))
3906
+ else:
3907
+ self.broadcastDimensions = stablehloBroadcastInDimOptions.BroadcastDimensionsAsNumpy()
3908
+
3909
+ # StablehloBroadcastInDimOptionsT
3910
+ def Pack(self, builder):
3911
+ if self.broadcastDimensions is not None:
3912
+ if np is not None and type(self.broadcastDimensions) is np.ndarray:
3913
+ broadcastDimensions = builder.CreateNumpyVector(self.broadcastDimensions)
3914
+ else:
3915
+ StablehloBroadcastInDimOptionsStartBroadcastDimensionsVector(builder, len(self.broadcastDimensions))
3916
+ for i in reversed(range(len(self.broadcastDimensions))):
3917
+ builder.PrependInt64(self.broadcastDimensions[i])
3918
+ broadcastDimensions = builder.EndVector()
3919
+ StablehloBroadcastInDimOptionsStart(builder)
3920
+ if self.broadcastDimensions is not None:
3921
+ StablehloBroadcastInDimOptionsAddBroadcastDimensions(builder, broadcastDimensions)
3922
+ stablehloBroadcastInDimOptions = StablehloBroadcastInDimOptionsEnd(builder)
3923
+ return stablehloBroadcastInDimOptions
3924
+
3925
+
3926
+ class StablehloCompareOptions(object):
3927
+ __slots__ = ['_tab']
3928
+
3929
+ @classmethod
3930
+ def GetRootAs(cls, buf, offset=0):
3931
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
3932
+ x = StablehloCompareOptions()
3933
+ x.Init(buf, n + offset)
3934
+ return x
3935
+
3936
+ @classmethod
3937
+ def GetRootAsStablehloCompareOptions(cls, buf, offset=0):
3938
+ """This method is deprecated. Please switch to GetRootAs."""
3939
+ return cls.GetRootAs(buf, offset)
3940
+ @classmethod
3941
+ def StablehloCompareOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
3942
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
3943
+
3944
+ # StablehloCompareOptions
3945
+ def Init(self, buf, pos):
3946
+ self._tab = flatbuffers.table.Table(buf, pos)
3947
+
3948
+ # StablehloCompareOptions
3949
+ def ComparisonDirection(self):
3950
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
3951
+ if o != 0:
3952
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
3953
+ return 0
3954
+
3955
+ # StablehloCompareOptions
3956
+ def CompareType(self):
3957
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
3958
+ if o != 0:
3959
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
3960
+ return 0
3961
+
3962
+ def StablehloCompareOptionsStart(builder):
3963
+ builder.StartObject(2)
3964
+
3965
+ def StablehloCompareOptionsAddComparisonDirection(builder, comparisonDirection):
3966
+ builder.PrependUint32Slot(0, comparisonDirection, 0)
3967
+
3968
+ def StablehloCompareOptionsAddCompareType(builder, compareType):
3969
+ builder.PrependUint32Slot(1, compareType, 0)
3970
+
3971
+ def StablehloCompareOptionsEnd(builder):
3972
+ return builder.EndObject()
3973
+
3974
+
3975
+
3976
+ class StablehloCompareOptionsT(object):
3977
+
3978
+ # StablehloCompareOptionsT
3979
+ def __init__(self):
3980
+ self.comparisonDirection = 0 # type: int
3981
+ self.compareType = 0 # type: int
3982
+
3983
+ @classmethod
3984
+ def InitFromBuf(cls, buf, pos):
3985
+ stablehloCompareOptions = StablehloCompareOptions()
3986
+ stablehloCompareOptions.Init(buf, pos)
3987
+ return cls.InitFromObj(stablehloCompareOptions)
3988
+
3989
+ @classmethod
3990
+ def InitFromPackedBuf(cls, buf, pos=0):
3991
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
3992
+ return cls.InitFromBuf(buf, pos+n)
3993
+
3994
+ @classmethod
3995
+ def InitFromObj(cls, stablehloCompareOptions):
3996
+ x = StablehloCompareOptionsT()
3997
+ x._UnPack(stablehloCompareOptions)
3998
+ return x
3999
+
4000
+ # StablehloCompareOptionsT
4001
+ def _UnPack(self, stablehloCompareOptions):
4002
+ if stablehloCompareOptions is None:
4003
+ return
4004
+ self.comparisonDirection = stablehloCompareOptions.ComparisonDirection()
4005
+ self.compareType = stablehloCompareOptions.CompareType()
4006
+
4007
+ # StablehloCompareOptionsT
4008
+ def Pack(self, builder):
4009
+ StablehloCompareOptionsStart(builder)
4010
+ StablehloCompareOptionsAddComparisonDirection(builder, self.comparisonDirection)
4011
+ StablehloCompareOptionsAddCompareType(builder, self.compareType)
4012
+ stablehloCompareOptions = StablehloCompareOptionsEnd(builder)
4013
+ return stablehloCompareOptions
4014
+
4015
+
4016
+ class StablehloDynamicSliceOptions(object):
4017
+ __slots__ = ['_tab']
4018
+
4019
+ @classmethod
4020
+ def GetRootAs(cls, buf, offset=0):
4021
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
4022
+ x = StablehloDynamicSliceOptions()
4023
+ x.Init(buf, n + offset)
4024
+ return x
4025
+
4026
+ @classmethod
4027
+ def GetRootAsStablehloDynamicSliceOptions(cls, buf, offset=0):
4028
+ """This method is deprecated. Please switch to GetRootAs."""
4029
+ return cls.GetRootAs(buf, offset)
4030
+ @classmethod
4031
+ def StablehloDynamicSliceOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
4032
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
4033
+
4034
+ # StablehloDynamicSliceOptions
4035
+ def Init(self, buf, pos):
4036
+ self._tab = flatbuffers.table.Table(buf, pos)
4037
+
4038
+ # StablehloDynamicSliceOptions
4039
+ def SliceSizes(self, j):
4040
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4041
+ if o != 0:
4042
+ a = self._tab.Vector(o)
4043
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
4044
+ return 0
4045
+
4046
+ # StablehloDynamicSliceOptions
4047
+ def SliceSizesAsNumpy(self):
4048
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4049
+ if o != 0:
4050
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
4051
+ return 0
4052
+
4053
+ # StablehloDynamicSliceOptions
4054
+ def SliceSizesLength(self):
4055
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4056
+ if o != 0:
4057
+ return self._tab.VectorLen(o)
4058
+ return 0
4059
+
4060
+ # StablehloDynamicSliceOptions
4061
+ def SliceSizesIsNone(self):
4062
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4063
+ return o == 0
4064
+
4065
+ def StablehloDynamicSliceOptionsStart(builder):
4066
+ builder.StartObject(1)
4067
+
4068
+ def StablehloDynamicSliceOptionsAddSliceSizes(builder, sliceSizes):
4069
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(sliceSizes), 0)
4070
+
4071
+ def StablehloDynamicSliceOptionsStartSliceSizesVector(builder, numElems):
4072
+ return builder.StartVector(8, numElems, 8)
4073
+
4074
+ def StablehloDynamicSliceOptionsEnd(builder):
4075
+ return builder.EndObject()
4076
+
4077
+
4078
+ try:
4079
+ from typing import List
4080
+ except:
4081
+ pass
4082
+
4083
+ class StablehloDynamicSliceOptionsT(object):
4084
+
4085
+ # StablehloDynamicSliceOptionsT
4086
+ def __init__(self):
4087
+ self.sliceSizes = None # type: List[int]
4088
+
4089
+ @classmethod
4090
+ def InitFromBuf(cls, buf, pos):
4091
+ stablehloDynamicSliceOptions = StablehloDynamicSliceOptions()
4092
+ stablehloDynamicSliceOptions.Init(buf, pos)
4093
+ return cls.InitFromObj(stablehloDynamicSliceOptions)
4094
+
4095
+ @classmethod
4096
+ def InitFromPackedBuf(cls, buf, pos=0):
4097
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
4098
+ return cls.InitFromBuf(buf, pos+n)
4099
+
4100
+ @classmethod
4101
+ def InitFromObj(cls, stablehloDynamicSliceOptions):
4102
+ x = StablehloDynamicSliceOptionsT()
4103
+ x._UnPack(stablehloDynamicSliceOptions)
4104
+ return x
4105
+
4106
+ # StablehloDynamicSliceOptionsT
4107
+ def _UnPack(self, stablehloDynamicSliceOptions):
4108
+ if stablehloDynamicSliceOptions is None:
4109
+ return
4110
+ if not stablehloDynamicSliceOptions.SliceSizesIsNone():
4111
+ if np is None:
4112
+ self.sliceSizes = []
4113
+ for i in range(stablehloDynamicSliceOptions.SliceSizesLength()):
4114
+ self.sliceSizes.append(stablehloDynamicSliceOptions.SliceSizes(i))
4115
+ else:
4116
+ self.sliceSizes = stablehloDynamicSliceOptions.SliceSizesAsNumpy()
4117
+
4118
+ # StablehloDynamicSliceOptionsT
4119
+ def Pack(self, builder):
4120
+ if self.sliceSizes is not None:
4121
+ if np is not None and type(self.sliceSizes) is np.ndarray:
4122
+ sliceSizes = builder.CreateNumpyVector(self.sliceSizes)
4123
+ else:
4124
+ StablehloDynamicSliceOptionsStartSliceSizesVector(builder, len(self.sliceSizes))
4125
+ for i in reversed(range(len(self.sliceSizes))):
4126
+ builder.PrependInt64(self.sliceSizes[i])
4127
+ sliceSizes = builder.EndVector()
4128
+ StablehloDynamicSliceOptionsStart(builder)
4129
+ if self.sliceSizes is not None:
4130
+ StablehloDynamicSliceOptionsAddSliceSizes(builder, sliceSizes)
4131
+ stablehloDynamicSliceOptions = StablehloDynamicSliceOptionsEnd(builder)
4132
+ return stablehloDynamicSliceOptions
4133
+
4134
+
4135
+ class StablehloPadOptions(object):
4136
+ __slots__ = ['_tab']
4137
+
4138
+ @classmethod
4139
+ def GetRootAs(cls, buf, offset=0):
4140
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
4141
+ x = StablehloPadOptions()
4142
+ x.Init(buf, n + offset)
4143
+ return x
4144
+
4145
+ @classmethod
4146
+ def GetRootAsStablehloPadOptions(cls, buf, offset=0):
4147
+ """This method is deprecated. Please switch to GetRootAs."""
4148
+ return cls.GetRootAs(buf, offset)
4149
+ @classmethod
4150
+ def StablehloPadOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
4151
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
4152
+
4153
+ # StablehloPadOptions
4154
+ def Init(self, buf, pos):
4155
+ self._tab = flatbuffers.table.Table(buf, pos)
4156
+
4157
+ # StablehloPadOptions
4158
+ def EdgePaddingLow(self, j):
4159
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4160
+ if o != 0:
4161
+ a = self._tab.Vector(o)
4162
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
4163
+ return 0
4164
+
4165
+ # StablehloPadOptions
4166
+ def EdgePaddingLowAsNumpy(self):
4167
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4168
+ if o != 0:
4169
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
4170
+ return 0
4171
+
4172
+ # StablehloPadOptions
4173
+ def EdgePaddingLowLength(self):
4174
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4175
+ if o != 0:
4176
+ return self._tab.VectorLen(o)
4177
+ return 0
4178
+
4179
+ # StablehloPadOptions
4180
+ def EdgePaddingLowIsNone(self):
4181
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4182
+ return o == 0
4183
+
4184
+ # StablehloPadOptions
4185
+ def EdgePaddingHigh(self, j):
4186
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
4187
+ if o != 0:
4188
+ a = self._tab.Vector(o)
4189
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
4190
+ return 0
4191
+
4192
+ # StablehloPadOptions
4193
+ def EdgePaddingHighAsNumpy(self):
4194
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
4195
+ if o != 0:
4196
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
4197
+ return 0
4198
+
4199
+ # StablehloPadOptions
4200
+ def EdgePaddingHighLength(self):
4201
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
4202
+ if o != 0:
4203
+ return self._tab.VectorLen(o)
4204
+ return 0
4205
+
4206
+ # StablehloPadOptions
4207
+ def EdgePaddingHighIsNone(self):
4208
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
4209
+ return o == 0
4210
+
4211
+ # StablehloPadOptions
4212
+ def InteriorPadding(self, j):
4213
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
4214
+ if o != 0:
4215
+ a = self._tab.Vector(o)
4216
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
4217
+ return 0
4218
+
4219
+ # StablehloPadOptions
4220
+ def InteriorPaddingAsNumpy(self):
4221
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
4222
+ if o != 0:
4223
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
4224
+ return 0
4225
+
4226
+ # StablehloPadOptions
4227
+ def InteriorPaddingLength(self):
4228
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
4229
+ if o != 0:
4230
+ return self._tab.VectorLen(o)
4231
+ return 0
4232
+
4233
+ # StablehloPadOptions
4234
+ def InteriorPaddingIsNone(self):
4235
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
4236
+ return o == 0
4237
+
4238
+ def StablehloPadOptionsStart(builder):
4239
+ builder.StartObject(3)
4240
+
4241
+ def StablehloPadOptionsAddEdgePaddingLow(builder, edgePaddingLow):
4242
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(edgePaddingLow), 0)
4243
+
4244
+ def StablehloPadOptionsStartEdgePaddingLowVector(builder, numElems):
4245
+ return builder.StartVector(8, numElems, 8)
4246
+
4247
+ def StablehloPadOptionsAddEdgePaddingHigh(builder, edgePaddingHigh):
4248
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(edgePaddingHigh), 0)
4249
+
4250
+ def StablehloPadOptionsStartEdgePaddingHighVector(builder, numElems):
4251
+ return builder.StartVector(8, numElems, 8)
4252
+
4253
+ def StablehloPadOptionsAddInteriorPadding(builder, interiorPadding):
4254
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(interiorPadding), 0)
4255
+
4256
+ def StablehloPadOptionsStartInteriorPaddingVector(builder, numElems):
4257
+ return builder.StartVector(8, numElems, 8)
4258
+
4259
+ def StablehloPadOptionsEnd(builder):
4260
+ return builder.EndObject()
4261
+
4262
+
4263
+ try:
4264
+ from typing import List
4265
+ except:
4266
+ pass
4267
+
4268
+ class StablehloPadOptionsT(object):
4269
+
4270
+ # StablehloPadOptionsT
4271
+ def __init__(self):
4272
+ self.edgePaddingLow = None # type: List[int]
4273
+ self.edgePaddingHigh = None # type: List[int]
4274
+ self.interiorPadding = None # type: List[int]
4275
+
4276
+ @classmethod
4277
+ def InitFromBuf(cls, buf, pos):
4278
+ stablehloPadOptions = StablehloPadOptions()
4279
+ stablehloPadOptions.Init(buf, pos)
4280
+ return cls.InitFromObj(stablehloPadOptions)
4281
+
4282
+ @classmethod
4283
+ def InitFromPackedBuf(cls, buf, pos=0):
4284
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
4285
+ return cls.InitFromBuf(buf, pos+n)
4286
+
4287
+ @classmethod
4288
+ def InitFromObj(cls, stablehloPadOptions):
4289
+ x = StablehloPadOptionsT()
4290
+ x._UnPack(stablehloPadOptions)
4291
+ return x
4292
+
4293
+ # StablehloPadOptionsT
4294
+ def _UnPack(self, stablehloPadOptions):
4295
+ if stablehloPadOptions is None:
4296
+ return
4297
+ if not stablehloPadOptions.EdgePaddingLowIsNone():
4298
+ if np is None:
4299
+ self.edgePaddingLow = []
4300
+ for i in range(stablehloPadOptions.EdgePaddingLowLength()):
4301
+ self.edgePaddingLow.append(stablehloPadOptions.EdgePaddingLow(i))
4302
+ else:
4303
+ self.edgePaddingLow = stablehloPadOptions.EdgePaddingLowAsNumpy()
4304
+ if not stablehloPadOptions.EdgePaddingHighIsNone():
4305
+ if np is None:
4306
+ self.edgePaddingHigh = []
4307
+ for i in range(stablehloPadOptions.EdgePaddingHighLength()):
4308
+ self.edgePaddingHigh.append(stablehloPadOptions.EdgePaddingHigh(i))
4309
+ else:
4310
+ self.edgePaddingHigh = stablehloPadOptions.EdgePaddingHighAsNumpy()
4311
+ if not stablehloPadOptions.InteriorPaddingIsNone():
4312
+ if np is None:
4313
+ self.interiorPadding = []
4314
+ for i in range(stablehloPadOptions.InteriorPaddingLength()):
4315
+ self.interiorPadding.append(stablehloPadOptions.InteriorPadding(i))
4316
+ else:
4317
+ self.interiorPadding = stablehloPadOptions.InteriorPaddingAsNumpy()
4318
+
4319
+ # StablehloPadOptionsT
4320
+ def Pack(self, builder):
4321
+ if self.edgePaddingLow is not None:
4322
+ if np is not None and type(self.edgePaddingLow) is np.ndarray:
4323
+ edgePaddingLow = builder.CreateNumpyVector(self.edgePaddingLow)
4324
+ else:
4325
+ StablehloPadOptionsStartEdgePaddingLowVector(builder, len(self.edgePaddingLow))
4326
+ for i in reversed(range(len(self.edgePaddingLow))):
4327
+ builder.PrependInt64(self.edgePaddingLow[i])
4328
+ edgePaddingLow = builder.EndVector()
4329
+ if self.edgePaddingHigh is not None:
4330
+ if np is not None and type(self.edgePaddingHigh) is np.ndarray:
4331
+ edgePaddingHigh = builder.CreateNumpyVector(self.edgePaddingHigh)
4332
+ else:
4333
+ StablehloPadOptionsStartEdgePaddingHighVector(builder, len(self.edgePaddingHigh))
4334
+ for i in reversed(range(len(self.edgePaddingHigh))):
4335
+ builder.PrependInt64(self.edgePaddingHigh[i])
4336
+ edgePaddingHigh = builder.EndVector()
4337
+ if self.interiorPadding is not None:
4338
+ if np is not None and type(self.interiorPadding) is np.ndarray:
4339
+ interiorPadding = builder.CreateNumpyVector(self.interiorPadding)
4340
+ else:
4341
+ StablehloPadOptionsStartInteriorPaddingVector(builder, len(self.interiorPadding))
4342
+ for i in reversed(range(len(self.interiorPadding))):
4343
+ builder.PrependInt64(self.interiorPadding[i])
4344
+ interiorPadding = builder.EndVector()
4345
+ StablehloPadOptionsStart(builder)
4346
+ if self.edgePaddingLow is not None:
4347
+ StablehloPadOptionsAddEdgePaddingLow(builder, edgePaddingLow)
4348
+ if self.edgePaddingHigh is not None:
4349
+ StablehloPadOptionsAddEdgePaddingHigh(builder, edgePaddingHigh)
4350
+ if self.interiorPadding is not None:
4351
+ StablehloPadOptionsAddInteriorPadding(builder, interiorPadding)
4352
+ stablehloPadOptions = StablehloPadOptionsEnd(builder)
4353
+ return stablehloPadOptions
4354
+
4355
+
4356
+ class StablehloIotaOptions(object):
4357
+ __slots__ = ['_tab']
4358
+
4359
+ @classmethod
4360
+ def GetRootAs(cls, buf, offset=0):
4361
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
4362
+ x = StablehloIotaOptions()
4363
+ x.Init(buf, n + offset)
4364
+ return x
4365
+
4366
+ @classmethod
4367
+ def GetRootAsStablehloIotaOptions(cls, buf, offset=0):
4368
+ """This method is deprecated. Please switch to GetRootAs."""
4369
+ return cls.GetRootAs(buf, offset)
4370
+ @classmethod
4371
+ def StablehloIotaOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
4372
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
4373
+
4374
+ # StablehloIotaOptions
4375
+ def Init(self, buf, pos):
4376
+ self._tab = flatbuffers.table.Table(buf, pos)
4377
+
4378
+ # StablehloIotaOptions
4379
+ def IotaDimension(self):
4380
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4381
+ if o != 0:
4382
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
4383
+ return 0
4384
+
4385
+ def StablehloIotaOptionsStart(builder):
4386
+ builder.StartObject(1)
4387
+
4388
+ def StablehloIotaOptionsAddIotaDimension(builder, iotaDimension):
4389
+ builder.PrependInt64Slot(0, iotaDimension, 0)
4390
+
4391
+ def StablehloIotaOptionsEnd(builder):
4392
+ return builder.EndObject()
4393
+
4394
+
4395
+
4396
+ class StablehloIotaOptionsT(object):
4397
+
4398
+ # StablehloIotaOptionsT
4399
+ def __init__(self):
4400
+ self.iotaDimension = 0 # type: int
4401
+
4402
+ @classmethod
4403
+ def InitFromBuf(cls, buf, pos):
4404
+ stablehloIotaOptions = StablehloIotaOptions()
4405
+ stablehloIotaOptions.Init(buf, pos)
4406
+ return cls.InitFromObj(stablehloIotaOptions)
4407
+
4408
+ @classmethod
4409
+ def InitFromPackedBuf(cls, buf, pos=0):
4410
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
4411
+ return cls.InitFromBuf(buf, pos+n)
4412
+
4413
+ @classmethod
4414
+ def InitFromObj(cls, stablehloIotaOptions):
4415
+ x = StablehloIotaOptionsT()
4416
+ x._UnPack(stablehloIotaOptions)
4417
+ return x
4418
+
4419
+ # StablehloIotaOptionsT
4420
+ def _UnPack(self, stablehloIotaOptions):
4421
+ if stablehloIotaOptions is None:
4422
+ return
4423
+ self.iotaDimension = stablehloIotaOptions.IotaDimension()
4424
+
4425
+ # StablehloIotaOptionsT
4426
+ def Pack(self, builder):
4427
+ StablehloIotaOptionsStart(builder)
4428
+ StablehloIotaOptionsAddIotaDimension(builder, self.iotaDimension)
4429
+ stablehloIotaOptions = StablehloIotaOptionsEnd(builder)
4430
+ return stablehloIotaOptions
4431
+
4432
+
4433
+ class StablehloCustomCallOptions(object):
4434
+ __slots__ = ['_tab']
4435
+
4436
+ @classmethod
4437
+ def GetRootAs(cls, buf, offset=0):
4438
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
4439
+ x = StablehloCustomCallOptions()
4440
+ x.Init(buf, n + offset)
4441
+ return x
4442
+
4443
+ @classmethod
4444
+ def GetRootAsStablehloCustomCallOptions(cls, buf, offset=0):
4445
+ """This method is deprecated. Please switch to GetRootAs."""
4446
+ return cls.GetRootAs(buf, offset)
4447
+ @classmethod
4448
+ def StablehloCustomCallOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
4449
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
4450
+
4451
+ # StablehloCustomCallOptions
4452
+ def Init(self, buf, pos):
4453
+ self._tab = flatbuffers.table.Table(buf, pos)
4454
+
4455
+ # StablehloCustomCallOptions
4456
+ def CallTargetName(self):
4457
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4458
+ if o != 0:
4459
+ return self._tab.String(o + self._tab.Pos)
4460
+ return None
4461
+
4462
+ # StablehloCustomCallOptions
4463
+ def HasSideEffect(self):
4464
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
4465
+ if o != 0:
4466
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
4467
+ return False
4468
+
4469
+ # StablehloCustomCallOptions
4470
+ def BackendConfig(self):
4471
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
4472
+ if o != 0:
4473
+ return self._tab.String(o + self._tab.Pos)
4474
+ return None
4475
+
4476
+ # StablehloCustomCallOptions
4477
+ def ApiVersion(self):
4478
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
4479
+ if o != 0:
4480
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
4481
+ return 0
4482
+
4483
+ # StablehloCustomCallOptions
4484
+ def CalledComputations(self, j):
4485
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
4486
+ if o != 0:
4487
+ a = self._tab.Vector(o)
4488
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
4489
+ return 0
4490
+
4491
+ # StablehloCustomCallOptions
4492
+ def CalledComputationsAsNumpy(self):
4493
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
4494
+ if o != 0:
4495
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o)
4496
+ return 0
4497
+
4498
+ # StablehloCustomCallOptions
4499
+ def CalledComputationsLength(self):
4500
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
4501
+ if o != 0:
4502
+ return self._tab.VectorLen(o)
4503
+ return 0
4504
+
4505
+ # StablehloCustomCallOptions
4506
+ def CalledComputationsIsNone(self):
4507
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
4508
+ return o == 0
4509
+
4510
+ # StablehloCustomCallOptions
4511
+ def CustomAttributes(self, j):
4512
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
4513
+ if o != 0:
4514
+ a = self._tab.Vector(o)
4515
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
4516
+ return 0
4517
+
4518
+ # StablehloCustomCallOptions
4519
+ def CustomAttributesAsNumpy(self):
4520
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
4521
+ if o != 0:
4522
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
4523
+ return 0
4524
+
4525
+ # StablehloCustomCallOptions
4526
+ def CustomAttributesLength(self):
4527
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
4528
+ if o != 0:
4529
+ return self._tab.VectorLen(o)
4530
+ return 0
4531
+
4532
+ # StablehloCustomCallOptions
4533
+ def CustomAttributesIsNone(self):
4534
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
4535
+ return o == 0
4536
+
4537
+ def StablehloCustomCallOptionsStart(builder):
4538
+ builder.StartObject(6)
4539
+
4540
+ def StablehloCustomCallOptionsAddCallTargetName(builder, callTargetName):
4541
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(callTargetName), 0)
4542
+
4543
+ def StablehloCustomCallOptionsAddHasSideEffect(builder, hasSideEffect):
4544
+ builder.PrependBoolSlot(1, hasSideEffect, 0)
4545
+
4546
+ def StablehloCustomCallOptionsAddBackendConfig(builder, backendConfig):
4547
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(backendConfig), 0)
4548
+
4549
+ def StablehloCustomCallOptionsAddApiVersion(builder, apiVersion):
4550
+ builder.PrependInt32Slot(3, apiVersion, 0)
4551
+
4552
+ def StablehloCustomCallOptionsAddCalledComputations(builder, calledComputations):
4553
+ builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(calledComputations), 0)
4554
+
4555
+ def StablehloCustomCallOptionsStartCalledComputationsVector(builder, numElems):
4556
+ return builder.StartVector(4, numElems, 4)
4557
+
4558
+ def StablehloCustomCallOptionsAddCustomAttributes(builder, customAttributes):
4559
+ builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(customAttributes), 0)
4560
+
4561
+ def StablehloCustomCallOptionsStartCustomAttributesVector(builder, numElems):
4562
+ return builder.StartVector(1, numElems, 1)
4563
+
4564
+ def StablehloCustomCallOptionsEnd(builder):
4565
+ return builder.EndObject()
4566
+
4567
+
4568
+ try:
4569
+ from typing import List
4570
+ except:
4571
+ pass
4572
+
4573
+ class StablehloCustomCallOptionsT(object):
4574
+
4575
+ # StablehloCustomCallOptionsT
4576
+ def __init__(self):
4577
+ self.callTargetName = None # type: str
4578
+ self.hasSideEffect = False # type: bool
4579
+ self.backendConfig = None # type: str
4580
+ self.apiVersion = 0 # type: int
4581
+ self.calledComputations = None # type: List[int]
4582
+ self.customAttributes = None # type: List[int]
4583
+
4584
+ @classmethod
4585
+ def InitFromBuf(cls, buf, pos):
4586
+ stablehloCustomCallOptions = StablehloCustomCallOptions()
4587
+ stablehloCustomCallOptions.Init(buf, pos)
4588
+ return cls.InitFromObj(stablehloCustomCallOptions)
4589
+
4590
+ @classmethod
4591
+ def InitFromPackedBuf(cls, buf, pos=0):
4592
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
4593
+ return cls.InitFromBuf(buf, pos+n)
4594
+
4595
+ @classmethod
4596
+ def InitFromObj(cls, stablehloCustomCallOptions):
4597
+ x = StablehloCustomCallOptionsT()
4598
+ x._UnPack(stablehloCustomCallOptions)
4599
+ return x
4600
+
4601
+ # StablehloCustomCallOptionsT
4602
+ def _UnPack(self, stablehloCustomCallOptions):
4603
+ if stablehloCustomCallOptions is None:
4604
+ return
4605
+ self.callTargetName = stablehloCustomCallOptions.CallTargetName()
4606
+ self.hasSideEffect = stablehloCustomCallOptions.HasSideEffect()
4607
+ self.backendConfig = stablehloCustomCallOptions.BackendConfig()
4608
+ self.apiVersion = stablehloCustomCallOptions.ApiVersion()
4609
+ if not stablehloCustomCallOptions.CalledComputationsIsNone():
4610
+ if np is None:
4611
+ self.calledComputations = []
4612
+ for i in range(stablehloCustomCallOptions.CalledComputationsLength()):
4613
+ self.calledComputations.append(stablehloCustomCallOptions.CalledComputations(i))
4614
+ else:
4615
+ self.calledComputations = stablehloCustomCallOptions.CalledComputationsAsNumpy()
4616
+ if not stablehloCustomCallOptions.CustomAttributesIsNone():
4617
+ if np is None:
4618
+ self.customAttributes = []
4619
+ for i in range(stablehloCustomCallOptions.CustomAttributesLength()):
4620
+ self.customAttributes.append(stablehloCustomCallOptions.CustomAttributes(i))
4621
+ else:
4622
+ self.customAttributes = stablehloCustomCallOptions.CustomAttributesAsNumpy()
4623
+
4624
+ # StablehloCustomCallOptionsT
4625
+ def Pack(self, builder):
4626
+ if self.callTargetName is not None:
4627
+ callTargetName = builder.CreateString(self.callTargetName)
4628
+ if self.backendConfig is not None:
4629
+ backendConfig = builder.CreateString(self.backendConfig)
4630
+ if self.calledComputations is not None:
4631
+ if np is not None and type(self.calledComputations) is np.ndarray:
4632
+ calledComputations = builder.CreateNumpyVector(self.calledComputations)
4633
+ else:
4634
+ StablehloCustomCallOptionsStartCalledComputationsVector(builder, len(self.calledComputations))
4635
+ for i in reversed(range(len(self.calledComputations))):
4636
+ builder.PrependInt32(self.calledComputations[i])
4637
+ calledComputations = builder.EndVector()
4638
+ if self.customAttributes is not None:
4639
+ if np is not None and type(self.customAttributes) is np.ndarray:
4640
+ customAttributes = builder.CreateNumpyVector(self.customAttributes)
4641
+ else:
4642
+ StablehloCustomCallOptionsStartCustomAttributesVector(builder, len(self.customAttributes))
4643
+ for i in reversed(range(len(self.customAttributes))):
4644
+ builder.PrependUint8(self.customAttributes[i])
4645
+ customAttributes = builder.EndVector()
4646
+ StablehloCustomCallOptionsStart(builder)
4647
+ if self.callTargetName is not None:
4648
+ StablehloCustomCallOptionsAddCallTargetName(builder, callTargetName)
4649
+ StablehloCustomCallOptionsAddHasSideEffect(builder, self.hasSideEffect)
4650
+ if self.backendConfig is not None:
4651
+ StablehloCustomCallOptionsAddBackendConfig(builder, backendConfig)
4652
+ StablehloCustomCallOptionsAddApiVersion(builder, self.apiVersion)
4653
+ if self.calledComputations is not None:
4654
+ StablehloCustomCallOptionsAddCalledComputations(builder, calledComputations)
4655
+ if self.customAttributes is not None:
4656
+ StablehloCustomCallOptionsAddCustomAttributes(builder, customAttributes)
4657
+ stablehloCustomCallOptions = StablehloCustomCallOptionsEnd(builder)
4658
+ return stablehloCustomCallOptions
4659
+
4660
+
4661
+ class StablehloReduceOptions(object):
4662
+ __slots__ = ['_tab']
4663
+
4664
+ @classmethod
4665
+ def GetRootAs(cls, buf, offset=0):
4666
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
4667
+ x = StablehloReduceOptions()
4668
+ x.Init(buf, n + offset)
4669
+ return x
4670
+
4671
+ @classmethod
4672
+ def GetRootAsStablehloReduceOptions(cls, buf, offset=0):
4673
+ """This method is deprecated. Please switch to GetRootAs."""
4674
+ return cls.GetRootAs(buf, offset)
4675
+ @classmethod
4676
+ def StablehloReduceOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
4677
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
4678
+
4679
+ # StablehloReduceOptions
4680
+ def Init(self, buf, pos):
4681
+ self._tab = flatbuffers.table.Table(buf, pos)
4682
+
4683
+ # StablehloReduceOptions
4684
+ def Dimensions(self, j):
4685
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4686
+ if o != 0:
4687
+ a = self._tab.Vector(o)
4688
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
4689
+ return 0
4690
+
4691
+ # StablehloReduceOptions
4692
+ def DimensionsAsNumpy(self):
4693
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4694
+ if o != 0:
4695
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
4696
+ return 0
4697
+
4698
+ # StablehloReduceOptions
4699
+ def DimensionsLength(self):
4700
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4701
+ if o != 0:
4702
+ return self._tab.VectorLen(o)
4703
+ return 0
4704
+
4705
+ # StablehloReduceOptions
4706
+ def DimensionsIsNone(self):
4707
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4708
+ return o == 0
4709
+
4710
+ # StablehloReduceOptions
4711
+ def BodySubgraphIndex(self):
4712
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
4713
+ if o != 0:
4714
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
4715
+ return 0
4716
+
4717
+ def StablehloReduceOptionsStart(builder):
4718
+ builder.StartObject(2)
4719
+
4720
+ def StablehloReduceOptionsAddDimensions(builder, dimensions):
4721
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(dimensions), 0)
4722
+
4723
+ def StablehloReduceOptionsStartDimensionsVector(builder, numElems):
4724
+ return builder.StartVector(8, numElems, 8)
4725
+
4726
+ def StablehloReduceOptionsAddBodySubgraphIndex(builder, bodySubgraphIndex):
4727
+ builder.PrependInt32Slot(1, bodySubgraphIndex, 0)
4728
+
4729
+ def StablehloReduceOptionsEnd(builder):
4730
+ return builder.EndObject()
4731
+
4732
+
4733
+ try:
4734
+ from typing import List
4735
+ except:
4736
+ pass
4737
+
4738
+ class StablehloReduceOptionsT(object):
4739
+
4740
+ # StablehloReduceOptionsT
4741
+ def __init__(self):
4742
+ self.dimensions = None # type: List[int]
4743
+ self.bodySubgraphIndex = 0 # type: int
4744
+
4745
+ @classmethod
4746
+ def InitFromBuf(cls, buf, pos):
4747
+ stablehloReduceOptions = StablehloReduceOptions()
4748
+ stablehloReduceOptions.Init(buf, pos)
4749
+ return cls.InitFromObj(stablehloReduceOptions)
4750
+
4751
+ @classmethod
4752
+ def InitFromPackedBuf(cls, buf, pos=0):
4753
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
4754
+ return cls.InitFromBuf(buf, pos+n)
4755
+
4756
+ @classmethod
4757
+ def InitFromObj(cls, stablehloReduceOptions):
4758
+ x = StablehloReduceOptionsT()
4759
+ x._UnPack(stablehloReduceOptions)
4760
+ return x
4761
+
4762
+ # StablehloReduceOptionsT
4763
+ def _UnPack(self, stablehloReduceOptions):
4764
+ if stablehloReduceOptions is None:
4765
+ return
4766
+ if not stablehloReduceOptions.DimensionsIsNone():
4767
+ if np is None:
4768
+ self.dimensions = []
4769
+ for i in range(stablehloReduceOptions.DimensionsLength()):
4770
+ self.dimensions.append(stablehloReduceOptions.Dimensions(i))
4771
+ else:
4772
+ self.dimensions = stablehloReduceOptions.DimensionsAsNumpy()
4773
+ self.bodySubgraphIndex = stablehloReduceOptions.BodySubgraphIndex()
4774
+
4775
+ # StablehloReduceOptionsT
4776
+ def Pack(self, builder):
4777
+ if self.dimensions is not None:
4778
+ if np is not None and type(self.dimensions) is np.ndarray:
4779
+ dimensions = builder.CreateNumpyVector(self.dimensions)
4780
+ else:
4781
+ StablehloReduceOptionsStartDimensionsVector(builder, len(self.dimensions))
4782
+ for i in reversed(range(len(self.dimensions))):
4783
+ builder.PrependInt64(self.dimensions[i])
4784
+ dimensions = builder.EndVector()
4785
+ StablehloReduceOptionsStart(builder)
4786
+ if self.dimensions is not None:
4787
+ StablehloReduceOptionsAddDimensions(builder, dimensions)
4788
+ StablehloReduceOptionsAddBodySubgraphIndex(builder, self.bodySubgraphIndex)
4789
+ stablehloReduceOptions = StablehloReduceOptionsEnd(builder)
4790
+ return stablehloReduceOptions
4791
+
4792
+
4793
+ class StablehloSliceOptions(object):
4794
+ __slots__ = ['_tab']
4795
+
4796
+ @classmethod
4797
+ def GetRootAs(cls, buf, offset=0):
4798
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
4799
+ x = StablehloSliceOptions()
4800
+ x.Init(buf, n + offset)
4801
+ return x
4802
+
4803
+ @classmethod
4804
+ def GetRootAsStablehloSliceOptions(cls, buf, offset=0):
4805
+ """This method is deprecated. Please switch to GetRootAs."""
4806
+ return cls.GetRootAs(buf, offset)
4807
+ @classmethod
4808
+ def StablehloSliceOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
4809
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
4810
+
4811
+ # StablehloSliceOptions
4812
+ def Init(self, buf, pos):
4813
+ self._tab = flatbuffers.table.Table(buf, pos)
4814
+
4815
+ # StablehloSliceOptions
4816
+ def StartIndices(self, j):
4817
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4818
+ if o != 0:
4819
+ a = self._tab.Vector(o)
4820
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
4821
+ return 0
4822
+
4823
+ # StablehloSliceOptions
4824
+ def StartIndicesAsNumpy(self):
4825
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4826
+ if o != 0:
4827
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
4828
+ return 0
4829
+
4830
+ # StablehloSliceOptions
4831
+ def StartIndicesLength(self):
4832
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4833
+ if o != 0:
4834
+ return self._tab.VectorLen(o)
4835
+ return 0
4836
+
4837
+ # StablehloSliceOptions
4838
+ def StartIndicesIsNone(self):
4839
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
4840
+ return o == 0
4841
+
4842
+ # StablehloSliceOptions
4843
+ def LimitIndices(self, j):
4844
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
4845
+ if o != 0:
4846
+ a = self._tab.Vector(o)
4847
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
4848
+ return 0
4849
+
4850
+ # StablehloSliceOptions
4851
+ def LimitIndicesAsNumpy(self):
4852
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
4853
+ if o != 0:
4854
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
4855
+ return 0
4856
+
4857
+ # StablehloSliceOptions
4858
+ def LimitIndicesLength(self):
4859
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
4860
+ if o != 0:
4861
+ return self._tab.VectorLen(o)
4862
+ return 0
4863
+
4864
+ # StablehloSliceOptions
4865
+ def LimitIndicesIsNone(self):
4866
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
4867
+ return o == 0
4868
+
4869
+ # StablehloSliceOptions
4870
+ def Strides(self, j):
4871
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
4872
+ if o != 0:
4873
+ a = self._tab.Vector(o)
4874
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
4875
+ return 0
4876
+
4877
+ # StablehloSliceOptions
4878
+ def StridesAsNumpy(self):
4879
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
4880
+ if o != 0:
4881
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
4882
+ return 0
4883
+
4884
+ # StablehloSliceOptions
4885
+ def StridesLength(self):
4886
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
4887
+ if o != 0:
4888
+ return self._tab.VectorLen(o)
4889
+ return 0
4890
+
4891
+ # StablehloSliceOptions
4892
+ def StridesIsNone(self):
4893
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
4894
+ return o == 0
4895
+
4896
+ def StablehloSliceOptionsStart(builder):
4897
+ builder.StartObject(3)
4898
+
4899
+ def StablehloSliceOptionsAddStartIndices(builder, startIndices):
4900
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(startIndices), 0)
4901
+
4902
+ def StablehloSliceOptionsStartStartIndicesVector(builder, numElems):
4903
+ return builder.StartVector(8, numElems, 8)
4904
+
4905
+ def StablehloSliceOptionsAddLimitIndices(builder, limitIndices):
4906
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(limitIndices), 0)
4907
+
4908
+ def StablehloSliceOptionsStartLimitIndicesVector(builder, numElems):
4909
+ return builder.StartVector(8, numElems, 8)
4910
+
4911
+ def StablehloSliceOptionsAddStrides(builder, strides):
4912
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(strides), 0)
4913
+
4914
+ def StablehloSliceOptionsStartStridesVector(builder, numElems):
4915
+ return builder.StartVector(8, numElems, 8)
4916
+
4917
+ def StablehloSliceOptionsEnd(builder):
4918
+ return builder.EndObject()
4919
+
4920
+
4921
+ try:
4922
+ from typing import List
4923
+ except:
4924
+ pass
4925
+
4926
+ class StablehloSliceOptionsT(object):
4927
+
4928
+ # StablehloSliceOptionsT
4929
+ def __init__(self):
4930
+ self.startIndices = None # type: List[int]
4931
+ self.limitIndices = None # type: List[int]
4932
+ self.strides = None # type: List[int]
4933
+
4934
+ @classmethod
4935
+ def InitFromBuf(cls, buf, pos):
4936
+ stablehloSliceOptions = StablehloSliceOptions()
4937
+ stablehloSliceOptions.Init(buf, pos)
4938
+ return cls.InitFromObj(stablehloSliceOptions)
4939
+
4940
+ @classmethod
4941
+ def InitFromPackedBuf(cls, buf, pos=0):
4942
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
4943
+ return cls.InitFromBuf(buf, pos+n)
4944
+
4945
+ @classmethod
4946
+ def InitFromObj(cls, stablehloSliceOptions):
4947
+ x = StablehloSliceOptionsT()
4948
+ x._UnPack(stablehloSliceOptions)
4949
+ return x
4950
+
4951
+ # StablehloSliceOptionsT
4952
+ def _UnPack(self, stablehloSliceOptions):
4953
+ if stablehloSliceOptions is None:
4954
+ return
4955
+ if not stablehloSliceOptions.StartIndicesIsNone():
4956
+ if np is None:
4957
+ self.startIndices = []
4958
+ for i in range(stablehloSliceOptions.StartIndicesLength()):
4959
+ self.startIndices.append(stablehloSliceOptions.StartIndices(i))
4960
+ else:
4961
+ self.startIndices = stablehloSliceOptions.StartIndicesAsNumpy()
4962
+ if not stablehloSliceOptions.LimitIndicesIsNone():
4963
+ if np is None:
4964
+ self.limitIndices = []
4965
+ for i in range(stablehloSliceOptions.LimitIndicesLength()):
4966
+ self.limitIndices.append(stablehloSliceOptions.LimitIndices(i))
4967
+ else:
4968
+ self.limitIndices = stablehloSliceOptions.LimitIndicesAsNumpy()
4969
+ if not stablehloSliceOptions.StridesIsNone():
4970
+ if np is None:
4971
+ self.strides = []
4972
+ for i in range(stablehloSliceOptions.StridesLength()):
4973
+ self.strides.append(stablehloSliceOptions.Strides(i))
4974
+ else:
4975
+ self.strides = stablehloSliceOptions.StridesAsNumpy()
4976
+
4977
+ # StablehloSliceOptionsT
4978
+ def Pack(self, builder):
4979
+ if self.startIndices is not None:
4980
+ if np is not None and type(self.startIndices) is np.ndarray:
4981
+ startIndices = builder.CreateNumpyVector(self.startIndices)
4982
+ else:
4983
+ StablehloSliceOptionsStartStartIndicesVector(builder, len(self.startIndices))
4984
+ for i in reversed(range(len(self.startIndices))):
4985
+ builder.PrependInt64(self.startIndices[i])
4986
+ startIndices = builder.EndVector()
4987
+ if self.limitIndices is not None:
4988
+ if np is not None and type(self.limitIndices) is np.ndarray:
4989
+ limitIndices = builder.CreateNumpyVector(self.limitIndices)
4990
+ else:
4991
+ StablehloSliceOptionsStartLimitIndicesVector(builder, len(self.limitIndices))
4992
+ for i in reversed(range(len(self.limitIndices))):
4993
+ builder.PrependInt64(self.limitIndices[i])
4994
+ limitIndices = builder.EndVector()
4995
+ if self.strides is not None:
4996
+ if np is not None and type(self.strides) is np.ndarray:
4997
+ strides = builder.CreateNumpyVector(self.strides)
4998
+ else:
4999
+ StablehloSliceOptionsStartStridesVector(builder, len(self.strides))
5000
+ for i in reversed(range(len(self.strides))):
5001
+ builder.PrependInt64(self.strides[i])
5002
+ strides = builder.EndVector()
5003
+ StablehloSliceOptionsStart(builder)
5004
+ if self.startIndices is not None:
5005
+ StablehloSliceOptionsAddStartIndices(builder, startIndices)
5006
+ if self.limitIndices is not None:
5007
+ StablehloSliceOptionsAddLimitIndices(builder, limitIndices)
5008
+ if self.strides is not None:
5009
+ StablehloSliceOptionsAddStrides(builder, strides)
5010
+ stablehloSliceOptions = StablehloSliceOptionsEnd(builder)
5011
+ return stablehloSliceOptions
5012
+
5013
+
5014
+ class StablehloConvolutionOptions(object):
5015
+ __slots__ = ['_tab']
5016
+
5017
+ @classmethod
5018
+ def GetRootAs(cls, buf, offset=0):
5019
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
5020
+ x = StablehloConvolutionOptions()
5021
+ x.Init(buf, n + offset)
5022
+ return x
5023
+
5024
+ @classmethod
5025
+ def GetRootAsStablehloConvolutionOptions(cls, buf, offset=0):
5026
+ """This method is deprecated. Please switch to GetRootAs."""
5027
+ return cls.GetRootAs(buf, offset)
5028
+ @classmethod
5029
+ def StablehloConvolutionOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
5030
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
5031
+
5032
+ # StablehloConvolutionOptions
5033
+ def Init(self, buf, pos):
5034
+ self._tab = flatbuffers.table.Table(buf, pos)
5035
+
5036
+ # StablehloConvolutionOptions
5037
+ def WindowStrides(self, j):
5038
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
5039
+ if o != 0:
5040
+ a = self._tab.Vector(o)
5041
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
5042
+ return 0
5043
+
5044
+ # StablehloConvolutionOptions
5045
+ def WindowStridesAsNumpy(self):
5046
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
5047
+ if o != 0:
5048
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
5049
+ return 0
5050
+
5051
+ # StablehloConvolutionOptions
5052
+ def WindowStridesLength(self):
5053
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
5054
+ if o != 0:
5055
+ return self._tab.VectorLen(o)
5056
+ return 0
5057
+
5058
+ # StablehloConvolutionOptions
5059
+ def WindowStridesIsNone(self):
5060
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
5061
+ return o == 0
5062
+
5063
+ # StablehloConvolutionOptions
5064
+ def Padding(self, j):
5065
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
5066
+ if o != 0:
5067
+ a = self._tab.Vector(o)
5068
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
5069
+ return 0
5070
+
5071
+ # StablehloConvolutionOptions
5072
+ def PaddingAsNumpy(self):
5073
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
5074
+ if o != 0:
5075
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
5076
+ return 0
5077
+
5078
+ # StablehloConvolutionOptions
5079
+ def PaddingLength(self):
5080
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
5081
+ if o != 0:
5082
+ return self._tab.VectorLen(o)
5083
+ return 0
5084
+
5085
+ # StablehloConvolutionOptions
5086
+ def PaddingIsNone(self):
5087
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
5088
+ return o == 0
5089
+
5090
+ # StablehloConvolutionOptions
5091
+ def LhsDilation(self, j):
5092
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
5093
+ if o != 0:
5094
+ a = self._tab.Vector(o)
5095
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
5096
+ return 0
5097
+
5098
+ # StablehloConvolutionOptions
5099
+ def LhsDilationAsNumpy(self):
5100
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
5101
+ if o != 0:
5102
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
5103
+ return 0
5104
+
5105
+ # StablehloConvolutionOptions
5106
+ def LhsDilationLength(self):
5107
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
5108
+ if o != 0:
5109
+ return self._tab.VectorLen(o)
5110
+ return 0
5111
+
5112
+ # StablehloConvolutionOptions
5113
+ def LhsDilationIsNone(self):
5114
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
5115
+ return o == 0
5116
+
5117
+ # StablehloConvolutionOptions
5118
+ def RhsDilation(self, j):
5119
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
5120
+ if o != 0:
5121
+ a = self._tab.Vector(o)
5122
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
5123
+ return 0
5124
+
5125
+ # StablehloConvolutionOptions
5126
+ def RhsDilationAsNumpy(self):
5127
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
5128
+ if o != 0:
5129
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
5130
+ return 0
5131
+
5132
+ # StablehloConvolutionOptions
5133
+ def RhsDilationLength(self):
5134
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
5135
+ if o != 0:
5136
+ return self._tab.VectorLen(o)
5137
+ return 0
5138
+
5139
+ # StablehloConvolutionOptions
5140
+ def RhsDilationIsNone(self):
5141
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
5142
+ return o == 0
5143
+
5144
+ # StablehloConvolutionOptions
5145
+ def WindowReversal(self, j):
5146
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
5147
+ if o != 0:
5148
+ a = self._tab.Vector(o)
5149
+ return self._tab.Get(flatbuffers.number_types.BoolFlags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
5150
+ return 0
5151
+
5152
+ # StablehloConvolutionOptions
5153
+ def WindowReversalAsNumpy(self):
5154
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
5155
+ if o != 0:
5156
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.BoolFlags, o)
5157
+ return 0
5158
+
5159
+ # StablehloConvolutionOptions
5160
+ def WindowReversalLength(self):
5161
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
5162
+ if o != 0:
5163
+ return self._tab.VectorLen(o)
5164
+ return 0
5165
+
5166
+ # StablehloConvolutionOptions
5167
+ def WindowReversalIsNone(self):
5168
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
5169
+ return o == 0
5170
+
5171
+ # StablehloConvolutionOptions
5172
+ def InputBatchDimension(self):
5173
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
5174
+ if o != 0:
5175
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
5176
+ return 0
5177
+
5178
+ # StablehloConvolutionOptions
5179
+ def InputFeatureDimension(self):
5180
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
5181
+ if o != 0:
5182
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
5183
+ return 0
5184
+
5185
+ # StablehloConvolutionOptions
5186
+ def InputSpatialDimensions(self, j):
5187
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
5188
+ if o != 0:
5189
+ a = self._tab.Vector(o)
5190
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
5191
+ return 0
5192
+
5193
+ # StablehloConvolutionOptions
5194
+ def InputSpatialDimensionsAsNumpy(self):
5195
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
5196
+ if o != 0:
5197
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
5198
+ return 0
5199
+
5200
+ # StablehloConvolutionOptions
5201
+ def InputSpatialDimensionsLength(self):
5202
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
5203
+ if o != 0:
5204
+ return self._tab.VectorLen(o)
5205
+ return 0
5206
+
5207
+ # StablehloConvolutionOptions
5208
+ def InputSpatialDimensionsIsNone(self):
5209
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
5210
+ return o == 0
5211
+
5212
+ # StablehloConvolutionOptions
5213
+ def KernelInputFeatureDimension(self):
5214
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
5215
+ if o != 0:
5216
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
5217
+ return 0
5218
+
5219
+ # StablehloConvolutionOptions
5220
+ def KernelOutputFeatureDimension(self):
5221
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
5222
+ if o != 0:
5223
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
5224
+ return 0
5225
+
5226
+ # StablehloConvolutionOptions
5227
+ def KernelSpatialDimensions(self, j):
5228
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
5229
+ if o != 0:
5230
+ a = self._tab.Vector(o)
5231
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
5232
+ return 0
5233
+
5234
+ # StablehloConvolutionOptions
5235
+ def KernelSpatialDimensionsAsNumpy(self):
5236
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
5237
+ if o != 0:
5238
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
5239
+ return 0
5240
+
5241
+ # StablehloConvolutionOptions
5242
+ def KernelSpatialDimensionsLength(self):
5243
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
5244
+ if o != 0:
5245
+ return self._tab.VectorLen(o)
5246
+ return 0
5247
+
5248
+ # StablehloConvolutionOptions
5249
+ def KernelSpatialDimensionsIsNone(self):
5250
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
5251
+ return o == 0
5252
+
5253
+ # StablehloConvolutionOptions
5254
+ def OutputBatchDimension(self):
5255
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26))
5256
+ if o != 0:
5257
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
5258
+ return 0
5259
+
5260
+ # StablehloConvolutionOptions
5261
+ def OutputFeatureDimension(self):
5262
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28))
5263
+ if o != 0:
5264
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
5265
+ return 0
5266
+
5267
+ # StablehloConvolutionOptions
5268
+ def OutputSpatialDimensions(self, j):
5269
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30))
5270
+ if o != 0:
5271
+ a = self._tab.Vector(o)
5272
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
5273
+ return 0
5274
+
5275
+ # StablehloConvolutionOptions
5276
+ def OutputSpatialDimensionsAsNumpy(self):
5277
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30))
5278
+ if o != 0:
5279
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
5280
+ return 0
5281
+
5282
+ # StablehloConvolutionOptions
5283
+ def OutputSpatialDimensionsLength(self):
5284
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30))
5285
+ if o != 0:
5286
+ return self._tab.VectorLen(o)
5287
+ return 0
5288
+
5289
+ # StablehloConvolutionOptions
5290
+ def OutputSpatialDimensionsIsNone(self):
5291
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30))
5292
+ return o == 0
5293
+
5294
+ # StablehloConvolutionOptions
5295
+ def FeatureGroupCount(self):
5296
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(32))
5297
+ if o != 0:
5298
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
5299
+ return 0
5300
+
5301
+ # StablehloConvolutionOptions
5302
+ def BatchGroupCount(self):
5303
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(34))
5304
+ if o != 0:
5305
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
5306
+ return 0
5307
+
5308
+ # StablehloConvolutionOptions
5309
+ def PrecisionConfig(self, j):
5310
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(36))
5311
+ if o != 0:
5312
+ a = self._tab.Vector(o)
5313
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
5314
+ return 0
5315
+
5316
+ # StablehloConvolutionOptions
5317
+ def PrecisionConfigAsNumpy(self):
5318
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(36))
5319
+ if o != 0:
5320
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint32Flags, o)
5321
+ return 0
5322
+
5323
+ # StablehloConvolutionOptions
5324
+ def PrecisionConfigLength(self):
5325
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(36))
5326
+ if o != 0:
5327
+ return self._tab.VectorLen(o)
5328
+ return 0
5329
+
5330
+ # StablehloConvolutionOptions
5331
+ def PrecisionConfigIsNone(self):
5332
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(36))
5333
+ return o == 0
5334
+
5335
+ def StablehloConvolutionOptionsStart(builder):
5336
+ builder.StartObject(17)
5337
+
5338
+ def StablehloConvolutionOptionsAddWindowStrides(builder, windowStrides):
5339
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(windowStrides), 0)
5340
+
5341
+ def StablehloConvolutionOptionsStartWindowStridesVector(builder, numElems):
5342
+ return builder.StartVector(8, numElems, 8)
5343
+
5344
+ def StablehloConvolutionOptionsAddPadding(builder, padding):
5345
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(padding), 0)
5346
+
5347
+ def StablehloConvolutionOptionsStartPaddingVector(builder, numElems):
5348
+ return builder.StartVector(8, numElems, 8)
5349
+
5350
+ def StablehloConvolutionOptionsAddLhsDilation(builder, lhsDilation):
5351
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(lhsDilation), 0)
5352
+
5353
+ def StablehloConvolutionOptionsStartLhsDilationVector(builder, numElems):
5354
+ return builder.StartVector(8, numElems, 8)
5355
+
5356
+ def StablehloConvolutionOptionsAddRhsDilation(builder, rhsDilation):
5357
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(rhsDilation), 0)
5358
+
5359
+ def StablehloConvolutionOptionsStartRhsDilationVector(builder, numElems):
5360
+ return builder.StartVector(8, numElems, 8)
5361
+
5362
+ def StablehloConvolutionOptionsAddWindowReversal(builder, windowReversal):
5363
+ builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(windowReversal), 0)
5364
+
5365
+ def StablehloConvolutionOptionsStartWindowReversalVector(builder, numElems):
5366
+ return builder.StartVector(1, numElems, 1)
5367
+
5368
+ def StablehloConvolutionOptionsAddInputBatchDimension(builder, inputBatchDimension):
5369
+ builder.PrependInt64Slot(5, inputBatchDimension, 0)
5370
+
5371
+ def StablehloConvolutionOptionsAddInputFeatureDimension(builder, inputFeatureDimension):
5372
+ builder.PrependInt64Slot(6, inputFeatureDimension, 0)
5373
+
5374
+ def StablehloConvolutionOptionsAddInputSpatialDimensions(builder, inputSpatialDimensions):
5375
+ builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(inputSpatialDimensions), 0)
5376
+
5377
+ def StablehloConvolutionOptionsStartInputSpatialDimensionsVector(builder, numElems):
5378
+ return builder.StartVector(8, numElems, 8)
5379
+
5380
+ def StablehloConvolutionOptionsAddKernelInputFeatureDimension(builder, kernelInputFeatureDimension):
5381
+ builder.PrependInt64Slot(8, kernelInputFeatureDimension, 0)
5382
+
5383
+ def StablehloConvolutionOptionsAddKernelOutputFeatureDimension(builder, kernelOutputFeatureDimension):
5384
+ builder.PrependInt64Slot(9, kernelOutputFeatureDimension, 0)
5385
+
5386
+ def StablehloConvolutionOptionsAddKernelSpatialDimensions(builder, kernelSpatialDimensions):
5387
+ builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(kernelSpatialDimensions), 0)
5388
+
5389
+ def StablehloConvolutionOptionsStartKernelSpatialDimensionsVector(builder, numElems):
5390
+ return builder.StartVector(8, numElems, 8)
5391
+
5392
+ def StablehloConvolutionOptionsAddOutputBatchDimension(builder, outputBatchDimension):
5393
+ builder.PrependInt64Slot(11, outputBatchDimension, 0)
5394
+
5395
+ def StablehloConvolutionOptionsAddOutputFeatureDimension(builder, outputFeatureDimension):
5396
+ builder.PrependInt64Slot(12, outputFeatureDimension, 0)
5397
+
5398
+ def StablehloConvolutionOptionsAddOutputSpatialDimensions(builder, outputSpatialDimensions):
5399
+ builder.PrependUOffsetTRelativeSlot(13, flatbuffers.number_types.UOffsetTFlags.py_type(outputSpatialDimensions), 0)
5400
+
5401
+ def StablehloConvolutionOptionsStartOutputSpatialDimensionsVector(builder, numElems):
5402
+ return builder.StartVector(8, numElems, 8)
5403
+
5404
+ def StablehloConvolutionOptionsAddFeatureGroupCount(builder, featureGroupCount):
5405
+ builder.PrependInt64Slot(14, featureGroupCount, 0)
5406
+
5407
+ def StablehloConvolutionOptionsAddBatchGroupCount(builder, batchGroupCount):
5408
+ builder.PrependInt64Slot(15, batchGroupCount, 0)
5409
+
5410
+ def StablehloConvolutionOptionsAddPrecisionConfig(builder, precisionConfig):
5411
+ builder.PrependUOffsetTRelativeSlot(16, flatbuffers.number_types.UOffsetTFlags.py_type(precisionConfig), 0)
5412
+
5413
+ def StablehloConvolutionOptionsStartPrecisionConfigVector(builder, numElems):
5414
+ return builder.StartVector(4, numElems, 4)
5415
+
5416
+ def StablehloConvolutionOptionsEnd(builder):
5417
+ return builder.EndObject()
5418
+
5419
+
5420
+ try:
5421
+ from typing import List
5422
+ except:
5423
+ pass
5424
+
5425
+ class StablehloConvolutionOptionsT(object):
5426
+
5427
+ # StablehloConvolutionOptionsT
5428
+ def __init__(self):
5429
+ self.windowStrides = None # type: List[int]
5430
+ self.padding = None # type: List[int]
5431
+ self.lhsDilation = None # type: List[int]
5432
+ self.rhsDilation = None # type: List[int]
5433
+ self.windowReversal = None # type: List[bool]
5434
+ self.inputBatchDimension = 0 # type: int
5435
+ self.inputFeatureDimension = 0 # type: int
5436
+ self.inputSpatialDimensions = None # type: List[int]
5437
+ self.kernelInputFeatureDimension = 0 # type: int
5438
+ self.kernelOutputFeatureDimension = 0 # type: int
5439
+ self.kernelSpatialDimensions = None # type: List[int]
5440
+ self.outputBatchDimension = 0 # type: int
5441
+ self.outputFeatureDimension = 0 # type: int
5442
+ self.outputSpatialDimensions = None # type: List[int]
5443
+ self.featureGroupCount = 0 # type: int
5444
+ self.batchGroupCount = 0 # type: int
5445
+ self.precisionConfig = None # type: List[int]
5446
+
5447
+ @classmethod
5448
+ def InitFromBuf(cls, buf, pos):
5449
+ stablehloConvolutionOptions = StablehloConvolutionOptions()
5450
+ stablehloConvolutionOptions.Init(buf, pos)
5451
+ return cls.InitFromObj(stablehloConvolutionOptions)
5452
+
5453
+ @classmethod
5454
+ def InitFromPackedBuf(cls, buf, pos=0):
5455
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
5456
+ return cls.InitFromBuf(buf, pos+n)
5457
+
5458
+ @classmethod
5459
+ def InitFromObj(cls, stablehloConvolutionOptions):
5460
+ x = StablehloConvolutionOptionsT()
5461
+ x._UnPack(stablehloConvolutionOptions)
5462
+ return x
5463
+
5464
+ # StablehloConvolutionOptionsT
5465
+ def _UnPack(self, stablehloConvolutionOptions):
5466
+ if stablehloConvolutionOptions is None:
5467
+ return
5468
+ if not stablehloConvolutionOptions.WindowStridesIsNone():
5469
+ if np is None:
5470
+ self.windowStrides = []
5471
+ for i in range(stablehloConvolutionOptions.WindowStridesLength()):
5472
+ self.windowStrides.append(stablehloConvolutionOptions.WindowStrides(i))
5473
+ else:
5474
+ self.windowStrides = stablehloConvolutionOptions.WindowStridesAsNumpy()
5475
+ if not stablehloConvolutionOptions.PaddingIsNone():
5476
+ if np is None:
5477
+ self.padding = []
5478
+ for i in range(stablehloConvolutionOptions.PaddingLength()):
5479
+ self.padding.append(stablehloConvolutionOptions.Padding(i))
5480
+ else:
5481
+ self.padding = stablehloConvolutionOptions.PaddingAsNumpy()
5482
+ if not stablehloConvolutionOptions.LhsDilationIsNone():
5483
+ if np is None:
5484
+ self.lhsDilation = []
5485
+ for i in range(stablehloConvolutionOptions.LhsDilationLength()):
5486
+ self.lhsDilation.append(stablehloConvolutionOptions.LhsDilation(i))
5487
+ else:
5488
+ self.lhsDilation = stablehloConvolutionOptions.LhsDilationAsNumpy()
5489
+ if not stablehloConvolutionOptions.RhsDilationIsNone():
5490
+ if np is None:
5491
+ self.rhsDilation = []
5492
+ for i in range(stablehloConvolutionOptions.RhsDilationLength()):
5493
+ self.rhsDilation.append(stablehloConvolutionOptions.RhsDilation(i))
5494
+ else:
5495
+ self.rhsDilation = stablehloConvolutionOptions.RhsDilationAsNumpy()
5496
+ if not stablehloConvolutionOptions.WindowReversalIsNone():
5497
+ if np is None:
5498
+ self.windowReversal = []
5499
+ for i in range(stablehloConvolutionOptions.WindowReversalLength()):
5500
+ self.windowReversal.append(stablehloConvolutionOptions.WindowReversal(i))
5501
+ else:
5502
+ self.windowReversal = stablehloConvolutionOptions.WindowReversalAsNumpy()
5503
+ self.inputBatchDimension = stablehloConvolutionOptions.InputBatchDimension()
5504
+ self.inputFeatureDimension = stablehloConvolutionOptions.InputFeatureDimension()
5505
+ if not stablehloConvolutionOptions.InputSpatialDimensionsIsNone():
5506
+ if np is None:
5507
+ self.inputSpatialDimensions = []
5508
+ for i in range(stablehloConvolutionOptions.InputSpatialDimensionsLength()):
5509
+ self.inputSpatialDimensions.append(stablehloConvolutionOptions.InputSpatialDimensions(i))
5510
+ else:
5511
+ self.inputSpatialDimensions = stablehloConvolutionOptions.InputSpatialDimensionsAsNumpy()
5512
+ self.kernelInputFeatureDimension = stablehloConvolutionOptions.KernelInputFeatureDimension()
5513
+ self.kernelOutputFeatureDimension = stablehloConvolutionOptions.KernelOutputFeatureDimension()
5514
+ if not stablehloConvolutionOptions.KernelSpatialDimensionsIsNone():
5515
+ if np is None:
5516
+ self.kernelSpatialDimensions = []
5517
+ for i in range(stablehloConvolutionOptions.KernelSpatialDimensionsLength()):
5518
+ self.kernelSpatialDimensions.append(stablehloConvolutionOptions.KernelSpatialDimensions(i))
5519
+ else:
5520
+ self.kernelSpatialDimensions = stablehloConvolutionOptions.KernelSpatialDimensionsAsNumpy()
5521
+ self.outputBatchDimension = stablehloConvolutionOptions.OutputBatchDimension()
5522
+ self.outputFeatureDimension = stablehloConvolutionOptions.OutputFeatureDimension()
5523
+ if not stablehloConvolutionOptions.OutputSpatialDimensionsIsNone():
5524
+ if np is None:
5525
+ self.outputSpatialDimensions = []
5526
+ for i in range(stablehloConvolutionOptions.OutputSpatialDimensionsLength()):
5527
+ self.outputSpatialDimensions.append(stablehloConvolutionOptions.OutputSpatialDimensions(i))
5528
+ else:
5529
+ self.outputSpatialDimensions = stablehloConvolutionOptions.OutputSpatialDimensionsAsNumpy()
5530
+ self.featureGroupCount = stablehloConvolutionOptions.FeatureGroupCount()
5531
+ self.batchGroupCount = stablehloConvolutionOptions.BatchGroupCount()
5532
+ if not stablehloConvolutionOptions.PrecisionConfigIsNone():
5533
+ if np is None:
5534
+ self.precisionConfig = []
5535
+ for i in range(stablehloConvolutionOptions.PrecisionConfigLength()):
5536
+ self.precisionConfig.append(stablehloConvolutionOptions.PrecisionConfig(i))
5537
+ else:
5538
+ self.precisionConfig = stablehloConvolutionOptions.PrecisionConfigAsNumpy()
5539
+
5540
+ # StablehloConvolutionOptionsT
5541
+ def Pack(self, builder):
5542
+ if self.windowStrides is not None:
5543
+ if np is not None and type(self.windowStrides) is np.ndarray:
5544
+ windowStrides = builder.CreateNumpyVector(self.windowStrides)
5545
+ else:
5546
+ StablehloConvolutionOptionsStartWindowStridesVector(builder, len(self.windowStrides))
5547
+ for i in reversed(range(len(self.windowStrides))):
5548
+ builder.PrependInt64(self.windowStrides[i])
5549
+ windowStrides = builder.EndVector()
5550
+ if self.padding is not None:
5551
+ if np is not None and type(self.padding) is np.ndarray:
5552
+ padding = builder.CreateNumpyVector(self.padding)
5553
+ else:
5554
+ StablehloConvolutionOptionsStartPaddingVector(builder, len(self.padding))
5555
+ for i in reversed(range(len(self.padding))):
5556
+ builder.PrependInt64(self.padding[i])
5557
+ padding = builder.EndVector()
5558
+ if self.lhsDilation is not None:
5559
+ if np is not None and type(self.lhsDilation) is np.ndarray:
5560
+ lhsDilation = builder.CreateNumpyVector(self.lhsDilation)
5561
+ else:
5562
+ StablehloConvolutionOptionsStartLhsDilationVector(builder, len(self.lhsDilation))
5563
+ for i in reversed(range(len(self.lhsDilation))):
5564
+ builder.PrependInt64(self.lhsDilation[i])
5565
+ lhsDilation = builder.EndVector()
5566
+ if self.rhsDilation is not None:
5567
+ if np is not None and type(self.rhsDilation) is np.ndarray:
5568
+ rhsDilation = builder.CreateNumpyVector(self.rhsDilation)
5569
+ else:
5570
+ StablehloConvolutionOptionsStartRhsDilationVector(builder, len(self.rhsDilation))
5571
+ for i in reversed(range(len(self.rhsDilation))):
5572
+ builder.PrependInt64(self.rhsDilation[i])
5573
+ rhsDilation = builder.EndVector()
5574
+ if self.windowReversal is not None:
5575
+ if np is not None and type(self.windowReversal) is np.ndarray:
5576
+ windowReversal = builder.CreateNumpyVector(self.windowReversal)
5577
+ else:
5578
+ StablehloConvolutionOptionsStartWindowReversalVector(builder, len(self.windowReversal))
5579
+ for i in reversed(range(len(self.windowReversal))):
5580
+ builder.PrependBool(self.windowReversal[i])
5581
+ windowReversal = builder.EndVector()
5582
+ if self.inputSpatialDimensions is not None:
5583
+ if np is not None and type(self.inputSpatialDimensions) is np.ndarray:
5584
+ inputSpatialDimensions = builder.CreateNumpyVector(self.inputSpatialDimensions)
5585
+ else:
5586
+ StablehloConvolutionOptionsStartInputSpatialDimensionsVector(builder, len(self.inputSpatialDimensions))
5587
+ for i in reversed(range(len(self.inputSpatialDimensions))):
5588
+ builder.PrependInt64(self.inputSpatialDimensions[i])
5589
+ inputSpatialDimensions = builder.EndVector()
5590
+ if self.kernelSpatialDimensions is not None:
5591
+ if np is not None and type(self.kernelSpatialDimensions) is np.ndarray:
5592
+ kernelSpatialDimensions = builder.CreateNumpyVector(self.kernelSpatialDimensions)
5593
+ else:
5594
+ StablehloConvolutionOptionsStartKernelSpatialDimensionsVector(builder, len(self.kernelSpatialDimensions))
5595
+ for i in reversed(range(len(self.kernelSpatialDimensions))):
5596
+ builder.PrependInt64(self.kernelSpatialDimensions[i])
5597
+ kernelSpatialDimensions = builder.EndVector()
5598
+ if self.outputSpatialDimensions is not None:
5599
+ if np is not None and type(self.outputSpatialDimensions) is np.ndarray:
5600
+ outputSpatialDimensions = builder.CreateNumpyVector(self.outputSpatialDimensions)
5601
+ else:
5602
+ StablehloConvolutionOptionsStartOutputSpatialDimensionsVector(builder, len(self.outputSpatialDimensions))
5603
+ for i in reversed(range(len(self.outputSpatialDimensions))):
5604
+ builder.PrependInt64(self.outputSpatialDimensions[i])
5605
+ outputSpatialDimensions = builder.EndVector()
5606
+ if self.precisionConfig is not None:
5607
+ if np is not None and type(self.precisionConfig) is np.ndarray:
5608
+ precisionConfig = builder.CreateNumpyVector(self.precisionConfig)
5609
+ else:
5610
+ StablehloConvolutionOptionsStartPrecisionConfigVector(builder, len(self.precisionConfig))
5611
+ for i in reversed(range(len(self.precisionConfig))):
5612
+ builder.PrependUint32(self.precisionConfig[i])
5613
+ precisionConfig = builder.EndVector()
5614
+ StablehloConvolutionOptionsStart(builder)
5615
+ if self.windowStrides is not None:
5616
+ StablehloConvolutionOptionsAddWindowStrides(builder, windowStrides)
5617
+ if self.padding is not None:
5618
+ StablehloConvolutionOptionsAddPadding(builder, padding)
5619
+ if self.lhsDilation is not None:
5620
+ StablehloConvolutionOptionsAddLhsDilation(builder, lhsDilation)
5621
+ if self.rhsDilation is not None:
5622
+ StablehloConvolutionOptionsAddRhsDilation(builder, rhsDilation)
5623
+ if self.windowReversal is not None:
5624
+ StablehloConvolutionOptionsAddWindowReversal(builder, windowReversal)
5625
+ StablehloConvolutionOptionsAddInputBatchDimension(builder, self.inputBatchDimension)
5626
+ StablehloConvolutionOptionsAddInputFeatureDimension(builder, self.inputFeatureDimension)
5627
+ if self.inputSpatialDimensions is not None:
5628
+ StablehloConvolutionOptionsAddInputSpatialDimensions(builder, inputSpatialDimensions)
5629
+ StablehloConvolutionOptionsAddKernelInputFeatureDimension(builder, self.kernelInputFeatureDimension)
5630
+ StablehloConvolutionOptionsAddKernelOutputFeatureDimension(builder, self.kernelOutputFeatureDimension)
5631
+ if self.kernelSpatialDimensions is not None:
5632
+ StablehloConvolutionOptionsAddKernelSpatialDimensions(builder, kernelSpatialDimensions)
5633
+ StablehloConvolutionOptionsAddOutputBatchDimension(builder, self.outputBatchDimension)
5634
+ StablehloConvolutionOptionsAddOutputFeatureDimension(builder, self.outputFeatureDimension)
5635
+ if self.outputSpatialDimensions is not None:
5636
+ StablehloConvolutionOptionsAddOutputSpatialDimensions(builder, outputSpatialDimensions)
5637
+ StablehloConvolutionOptionsAddFeatureGroupCount(builder, self.featureGroupCount)
5638
+ StablehloConvolutionOptionsAddBatchGroupCount(builder, self.batchGroupCount)
5639
+ if self.precisionConfig is not None:
5640
+ StablehloConvolutionOptionsAddPrecisionConfig(builder, precisionConfig)
5641
+ stablehloConvolutionOptions = StablehloConvolutionOptionsEnd(builder)
5642
+ return stablehloConvolutionOptions
5643
+
5644
+
5645
+ class StablehloScatterOptions(object):
5646
+ __slots__ = ['_tab']
5647
+
5648
+ @classmethod
5649
+ def GetRootAs(cls, buf, offset=0):
5650
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
5651
+ x = StablehloScatterOptions()
5652
+ x.Init(buf, n + offset)
5653
+ return x
5654
+
5655
+ @classmethod
5656
+ def GetRootAsStablehloScatterOptions(cls, buf, offset=0):
5657
+ """This method is deprecated. Please switch to GetRootAs."""
5658
+ return cls.GetRootAs(buf, offset)
5659
+ @classmethod
5660
+ def StablehloScatterOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
5661
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
5662
+
5663
+ # StablehloScatterOptions
5664
+ def Init(self, buf, pos):
5665
+ self._tab = flatbuffers.table.Table(buf, pos)
5666
+
5667
+ # StablehloScatterOptions
5668
+ def IndicesAreSorted(self):
5669
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
5670
+ if o != 0:
5671
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
5672
+ return False
5673
+
5674
+ # StablehloScatterOptions
5675
+ def UpdateWindowDims(self, j):
5676
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
5677
+ if o != 0:
5678
+ a = self._tab.Vector(o)
5679
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
5680
+ return 0
5681
+
5682
+ # StablehloScatterOptions
5683
+ def UpdateWindowDimsAsNumpy(self):
5684
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
5685
+ if o != 0:
5686
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
5687
+ return 0
5688
+
5689
+ # StablehloScatterOptions
5690
+ def UpdateWindowDimsLength(self):
5691
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
5692
+ if o != 0:
5693
+ return self._tab.VectorLen(o)
5694
+ return 0
5695
+
5696
+ # StablehloScatterOptions
5697
+ def UpdateWindowDimsIsNone(self):
5698
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
5699
+ return o == 0
5700
+
5701
+ # StablehloScatterOptions
5702
+ def InsertedWindowDims(self, j):
5703
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
5704
+ if o != 0:
5705
+ a = self._tab.Vector(o)
5706
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
5707
+ return 0
5708
+
5709
+ # StablehloScatterOptions
5710
+ def InsertedWindowDimsAsNumpy(self):
5711
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
5712
+ if o != 0:
5713
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
5714
+ return 0
5715
+
5716
+ # StablehloScatterOptions
5717
+ def InsertedWindowDimsLength(self):
5718
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
5719
+ if o != 0:
5720
+ return self._tab.VectorLen(o)
5721
+ return 0
5722
+
5723
+ # StablehloScatterOptions
5724
+ def InsertedWindowDimsIsNone(self):
5725
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
5726
+ return o == 0
5727
+
5728
+ # StablehloScatterOptions
5729
+ def ScatterDimsToOperandDims(self, j):
5730
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
5731
+ if o != 0:
5732
+ a = self._tab.Vector(o)
5733
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
5734
+ return 0
5735
+
5736
+ # StablehloScatterOptions
5737
+ def ScatterDimsToOperandDimsAsNumpy(self):
5738
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
5739
+ if o != 0:
5740
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
5741
+ return 0
5742
+
5743
+ # StablehloScatterOptions
5744
+ def ScatterDimsToOperandDimsLength(self):
5745
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
5746
+ if o != 0:
5747
+ return self._tab.VectorLen(o)
5748
+ return 0
5749
+
5750
+ # StablehloScatterOptions
5751
+ def ScatterDimsToOperandDimsIsNone(self):
5752
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
5753
+ return o == 0
5754
+
5755
+ # StablehloScatterOptions
5756
+ def IndexVectorDim(self):
5757
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
5758
+ if o != 0:
5759
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
5760
+ return 0
5761
+
5762
+ # StablehloScatterOptions
5763
+ def UniqueIndices(self):
5764
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
5765
+ if o != 0:
5766
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
5767
+ return False
5768
+
5769
+ # StablehloScatterOptions
5770
+ def UpdateComputationSubgraphIndex(self):
5771
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
5772
+ if o != 0:
5773
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
5774
+ return 0
5775
+
5776
+ def StablehloScatterOptionsStart(builder):
5777
+ builder.StartObject(7)
5778
+
5779
+ def StablehloScatterOptionsAddIndicesAreSorted(builder, indicesAreSorted):
5780
+ builder.PrependBoolSlot(0, indicesAreSorted, 0)
5781
+
5782
+ def StablehloScatterOptionsAddUpdateWindowDims(builder, updateWindowDims):
5783
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(updateWindowDims), 0)
5784
+
5785
+ def StablehloScatterOptionsStartUpdateWindowDimsVector(builder, numElems):
5786
+ return builder.StartVector(8, numElems, 8)
5787
+
5788
+ def StablehloScatterOptionsAddInsertedWindowDims(builder, insertedWindowDims):
5789
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(insertedWindowDims), 0)
5790
+
5791
+ def StablehloScatterOptionsStartInsertedWindowDimsVector(builder, numElems):
5792
+ return builder.StartVector(8, numElems, 8)
5793
+
5794
+ def StablehloScatterOptionsAddScatterDimsToOperandDims(builder, scatterDimsToOperandDims):
5795
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(scatterDimsToOperandDims), 0)
5796
+
5797
+ def StablehloScatterOptionsStartScatterDimsToOperandDimsVector(builder, numElems):
5798
+ return builder.StartVector(8, numElems, 8)
5799
+
5800
+ def StablehloScatterOptionsAddIndexVectorDim(builder, indexVectorDim):
5801
+ builder.PrependInt64Slot(4, indexVectorDim, 0)
5802
+
5803
+ def StablehloScatterOptionsAddUniqueIndices(builder, uniqueIndices):
5804
+ builder.PrependBoolSlot(5, uniqueIndices, 0)
5805
+
5806
+ def StablehloScatterOptionsAddUpdateComputationSubgraphIndex(builder, updateComputationSubgraphIndex):
5807
+ builder.PrependInt32Slot(6, updateComputationSubgraphIndex, 0)
5808
+
5809
+ def StablehloScatterOptionsEnd(builder):
5810
+ return builder.EndObject()
5811
+
5812
+
5813
+ try:
5814
+ from typing import List
5815
+ except:
5816
+ pass
5817
+
5818
+ class StablehloScatterOptionsT(object):
5819
+
5820
+ # StablehloScatterOptionsT
5821
+ def __init__(self):
5822
+ self.indicesAreSorted = False # type: bool
5823
+ self.updateWindowDims = None # type: List[int]
5824
+ self.insertedWindowDims = None # type: List[int]
5825
+ self.scatterDimsToOperandDims = None # type: List[int]
5826
+ self.indexVectorDim = 0 # type: int
5827
+ self.uniqueIndices = False # type: bool
5828
+ self.updateComputationSubgraphIndex = 0 # type: int
5829
+
5830
+ @classmethod
5831
+ def InitFromBuf(cls, buf, pos):
5832
+ stablehloScatterOptions = StablehloScatterOptions()
5833
+ stablehloScatterOptions.Init(buf, pos)
5834
+ return cls.InitFromObj(stablehloScatterOptions)
5835
+
5836
+ @classmethod
5837
+ def InitFromPackedBuf(cls, buf, pos=0):
5838
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
5839
+ return cls.InitFromBuf(buf, pos+n)
5840
+
5841
+ @classmethod
5842
+ def InitFromObj(cls, stablehloScatterOptions):
5843
+ x = StablehloScatterOptionsT()
5844
+ x._UnPack(stablehloScatterOptions)
5845
+ return x
5846
+
5847
+ # StablehloScatterOptionsT
5848
+ def _UnPack(self, stablehloScatterOptions):
5849
+ if stablehloScatterOptions is None:
5850
+ return
5851
+ self.indicesAreSorted = stablehloScatterOptions.IndicesAreSorted()
5852
+ if not stablehloScatterOptions.UpdateWindowDimsIsNone():
5853
+ if np is None:
5854
+ self.updateWindowDims = []
5855
+ for i in range(stablehloScatterOptions.UpdateWindowDimsLength()):
5856
+ self.updateWindowDims.append(stablehloScatterOptions.UpdateWindowDims(i))
5857
+ else:
5858
+ self.updateWindowDims = stablehloScatterOptions.UpdateWindowDimsAsNumpy()
5859
+ if not stablehloScatterOptions.InsertedWindowDimsIsNone():
5860
+ if np is None:
5861
+ self.insertedWindowDims = []
5862
+ for i in range(stablehloScatterOptions.InsertedWindowDimsLength()):
5863
+ self.insertedWindowDims.append(stablehloScatterOptions.InsertedWindowDims(i))
5864
+ else:
5865
+ self.insertedWindowDims = stablehloScatterOptions.InsertedWindowDimsAsNumpy()
5866
+ if not stablehloScatterOptions.ScatterDimsToOperandDimsIsNone():
5867
+ if np is None:
5868
+ self.scatterDimsToOperandDims = []
5869
+ for i in range(stablehloScatterOptions.ScatterDimsToOperandDimsLength()):
5870
+ self.scatterDimsToOperandDims.append(stablehloScatterOptions.ScatterDimsToOperandDims(i))
5871
+ else:
5872
+ self.scatterDimsToOperandDims = stablehloScatterOptions.ScatterDimsToOperandDimsAsNumpy()
5873
+ self.indexVectorDim = stablehloScatterOptions.IndexVectorDim()
5874
+ self.uniqueIndices = stablehloScatterOptions.UniqueIndices()
5875
+ self.updateComputationSubgraphIndex = stablehloScatterOptions.UpdateComputationSubgraphIndex()
5876
+
5877
+ # StablehloScatterOptionsT
5878
+ def Pack(self, builder):
5879
+ if self.updateWindowDims is not None:
5880
+ if np is not None and type(self.updateWindowDims) is np.ndarray:
5881
+ updateWindowDims = builder.CreateNumpyVector(self.updateWindowDims)
5882
+ else:
5883
+ StablehloScatterOptionsStartUpdateWindowDimsVector(builder, len(self.updateWindowDims))
5884
+ for i in reversed(range(len(self.updateWindowDims))):
5885
+ builder.PrependInt64(self.updateWindowDims[i])
5886
+ updateWindowDims = builder.EndVector()
5887
+ if self.insertedWindowDims is not None:
5888
+ if np is not None and type(self.insertedWindowDims) is np.ndarray:
5889
+ insertedWindowDims = builder.CreateNumpyVector(self.insertedWindowDims)
5890
+ else:
5891
+ StablehloScatterOptionsStartInsertedWindowDimsVector(builder, len(self.insertedWindowDims))
5892
+ for i in reversed(range(len(self.insertedWindowDims))):
5893
+ builder.PrependInt64(self.insertedWindowDims[i])
5894
+ insertedWindowDims = builder.EndVector()
5895
+ if self.scatterDimsToOperandDims is not None:
5896
+ if np is not None and type(self.scatterDimsToOperandDims) is np.ndarray:
5897
+ scatterDimsToOperandDims = builder.CreateNumpyVector(self.scatterDimsToOperandDims)
5898
+ else:
5899
+ StablehloScatterOptionsStartScatterDimsToOperandDimsVector(builder, len(self.scatterDimsToOperandDims))
5900
+ for i in reversed(range(len(self.scatterDimsToOperandDims))):
5901
+ builder.PrependInt64(self.scatterDimsToOperandDims[i])
5902
+ scatterDimsToOperandDims = builder.EndVector()
5903
+ StablehloScatterOptionsStart(builder)
5904
+ StablehloScatterOptionsAddIndicesAreSorted(builder, self.indicesAreSorted)
5905
+ if self.updateWindowDims is not None:
5906
+ StablehloScatterOptionsAddUpdateWindowDims(builder, updateWindowDims)
5907
+ if self.insertedWindowDims is not None:
5908
+ StablehloScatterOptionsAddInsertedWindowDims(builder, insertedWindowDims)
5909
+ if self.scatterDimsToOperandDims is not None:
5910
+ StablehloScatterOptionsAddScatterDimsToOperandDims(builder, scatterDimsToOperandDims)
5911
+ StablehloScatterOptionsAddIndexVectorDim(builder, self.indexVectorDim)
5912
+ StablehloScatterOptionsAddUniqueIndices(builder, self.uniqueIndices)
5913
+ StablehloScatterOptionsAddUpdateComputationSubgraphIndex(builder, self.updateComputationSubgraphIndex)
5914
+ stablehloScatterOptions = StablehloScatterOptionsEnd(builder)
5915
+ return stablehloScatterOptions
5916
+
5917
+
5918
+ class StablehloRngBitGeneratorOptions(object):
5919
+ __slots__ = ['_tab']
5920
+
5921
+ @classmethod
5922
+ def GetRootAs(cls, buf, offset=0):
5923
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
5924
+ x = StablehloRngBitGeneratorOptions()
5925
+ x.Init(buf, n + offset)
5926
+ return x
5927
+
5928
+ @classmethod
5929
+ def GetRootAsStablehloRngBitGeneratorOptions(cls, buf, offset=0):
5930
+ """This method is deprecated. Please switch to GetRootAs."""
5931
+ return cls.GetRootAs(buf, offset)
5932
+ @classmethod
5933
+ def StablehloRngBitGeneratorOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
5934
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
5935
+
5936
+ # StablehloRngBitGeneratorOptions
5937
+ def Init(self, buf, pos):
5938
+ self._tab = flatbuffers.table.Table(buf, pos)
2168
5939
 
2169
- def TensorAddHasRank(builder, hasRank):
2170
- builder.PrependBoolSlot(8, hasRank, 0)
5940
+ # StablehloRngBitGeneratorOptions
5941
+ def Algorithm(self):
5942
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
5943
+ if o != 0:
5944
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
5945
+ return 0
2171
5946
 
2172
- def TensorAddVariantTensors(builder, variantTensors):
2173
- builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(variantTensors), 0)
5947
+ def StablehloRngBitGeneratorOptionsStart(builder):
5948
+ builder.StartObject(1)
2174
5949
 
2175
- def TensorStartVariantTensorsVector(builder, numElems):
2176
- return builder.StartVector(4, numElems, 4)
5950
+ def StablehloRngBitGeneratorOptionsAddAlgorithm(builder, algorithm):
5951
+ builder.PrependInt8Slot(0, algorithm, 0)
2177
5952
 
2178
- def TensorEnd(builder):
5953
+ def StablehloRngBitGeneratorOptionsEnd(builder):
2179
5954
  return builder.EndObject()
2180
5955
 
2181
5956
 
2182
- try:
2183
- from typing import List, Optional
2184
- except:
2185
- pass
2186
5957
 
2187
- class TensorT(object):
5958
+ class StablehloRngBitGeneratorOptionsT(object):
2188
5959
 
2189
- # TensorT
5960
+ # StablehloRngBitGeneratorOptionsT
2190
5961
  def __init__(self):
2191
- self.shape = None # type: List[int]
2192
- self.type = 0 # type: int
2193
- self.buffer = 0 # type: int
2194
- self.name = None # type: str
2195
- self.quantization = None # type: Optional[QuantizationParametersT]
2196
- self.isVariable = False # type: bool
2197
- self.sparsity = None # type: Optional[SparsityParametersT]
2198
- self.shapeSignature = None # type: List[int]
2199
- self.hasRank = False # type: bool
2200
- self.variantTensors = None # type: List[VariantSubTypeT]
5962
+ self.algorithm = 0 # type: int
2201
5963
 
2202
5964
  @classmethod
2203
5965
  def InitFromBuf(cls, buf, pos):
2204
- tensor = Tensor()
2205
- tensor.Init(buf, pos)
2206
- return cls.InitFromObj(tensor)
5966
+ stablehloRngBitGeneratorOptions = StablehloRngBitGeneratorOptions()
5967
+ stablehloRngBitGeneratorOptions.Init(buf, pos)
5968
+ return cls.InitFromObj(stablehloRngBitGeneratorOptions)
2207
5969
 
2208
5970
  @classmethod
2209
5971
  def InitFromPackedBuf(cls, buf, pos=0):
@@ -2211,98 +5973,23 @@ class TensorT(object):
2211
5973
  return cls.InitFromBuf(buf, pos+n)
2212
5974
 
2213
5975
  @classmethod
2214
- def InitFromObj(cls, tensor):
2215
- x = TensorT()
2216
- x._UnPack(tensor)
5976
+ def InitFromObj(cls, stablehloRngBitGeneratorOptions):
5977
+ x = StablehloRngBitGeneratorOptionsT()
5978
+ x._UnPack(stablehloRngBitGeneratorOptions)
2217
5979
  return x
2218
5980
 
2219
- # TensorT
2220
- def _UnPack(self, tensor):
2221
- if tensor is None:
5981
+ # StablehloRngBitGeneratorOptionsT
5982
+ def _UnPack(self, stablehloRngBitGeneratorOptions):
5983
+ if stablehloRngBitGeneratorOptions is None:
2222
5984
  return
2223
- if not tensor.ShapeIsNone():
2224
- if np is None:
2225
- self.shape = []
2226
- for i in range(tensor.ShapeLength()):
2227
- self.shape.append(tensor.Shape(i))
2228
- else:
2229
- self.shape = tensor.ShapeAsNumpy()
2230
- self.type = tensor.Type()
2231
- self.buffer = tensor.Buffer()
2232
- self.name = tensor.Name()
2233
- if tensor.Quantization() is not None:
2234
- self.quantization = QuantizationParametersT.InitFromObj(tensor.Quantization())
2235
- self.isVariable = tensor.IsVariable()
2236
- if tensor.Sparsity() is not None:
2237
- self.sparsity = SparsityParametersT.InitFromObj(tensor.Sparsity())
2238
- if not tensor.ShapeSignatureIsNone():
2239
- if np is None:
2240
- self.shapeSignature = []
2241
- for i in range(tensor.ShapeSignatureLength()):
2242
- self.shapeSignature.append(tensor.ShapeSignature(i))
2243
- else:
2244
- self.shapeSignature = tensor.ShapeSignatureAsNumpy()
2245
- self.hasRank = tensor.HasRank()
2246
- if not tensor.VariantTensorsIsNone():
2247
- self.variantTensors = []
2248
- for i in range(tensor.VariantTensorsLength()):
2249
- if tensor.VariantTensors(i) is None:
2250
- self.variantTensors.append(None)
2251
- else:
2252
- variantSubType_ = VariantSubTypeT.InitFromObj(tensor.VariantTensors(i))
2253
- self.variantTensors.append(variantSubType_)
5985
+ self.algorithm = stablehloRngBitGeneratorOptions.Algorithm()
2254
5986
 
2255
- # TensorT
5987
+ # StablehloRngBitGeneratorOptionsT
2256
5988
  def Pack(self, builder):
2257
- if self.shape is not None:
2258
- if np is not None and type(self.shape) is np.ndarray:
2259
- shape = builder.CreateNumpyVector(self.shape)
2260
- else:
2261
- TensorStartShapeVector(builder, len(self.shape))
2262
- for i in reversed(range(len(self.shape))):
2263
- builder.PrependInt32(self.shape[i])
2264
- shape = builder.EndVector()
2265
- if self.name is not None:
2266
- name = builder.CreateString(self.name)
2267
- if self.quantization is not None:
2268
- quantization = self.quantization.Pack(builder)
2269
- if self.sparsity is not None:
2270
- sparsity = self.sparsity.Pack(builder)
2271
- if self.shapeSignature is not None:
2272
- if np is not None and type(self.shapeSignature) is np.ndarray:
2273
- shapeSignature = builder.CreateNumpyVector(self.shapeSignature)
2274
- else:
2275
- TensorStartShapeSignatureVector(builder, len(self.shapeSignature))
2276
- for i in reversed(range(len(self.shapeSignature))):
2277
- builder.PrependInt32(self.shapeSignature[i])
2278
- shapeSignature = builder.EndVector()
2279
- if self.variantTensors is not None:
2280
- variantTensorslist = []
2281
- for i in range(len(self.variantTensors)):
2282
- variantTensorslist.append(self.variantTensors[i].Pack(builder))
2283
- TensorStartVariantTensorsVector(builder, len(self.variantTensors))
2284
- for i in reversed(range(len(self.variantTensors))):
2285
- builder.PrependUOffsetTRelative(variantTensorslist[i])
2286
- variantTensors = builder.EndVector()
2287
- TensorStart(builder)
2288
- if self.shape is not None:
2289
- TensorAddShape(builder, shape)
2290
- TensorAddType(builder, self.type)
2291
- TensorAddBuffer(builder, self.buffer)
2292
- if self.name is not None:
2293
- TensorAddName(builder, name)
2294
- if self.quantization is not None:
2295
- TensorAddQuantization(builder, quantization)
2296
- TensorAddIsVariable(builder, self.isVariable)
2297
- if self.sparsity is not None:
2298
- TensorAddSparsity(builder, sparsity)
2299
- if self.shapeSignature is not None:
2300
- TensorAddShapeSignature(builder, shapeSignature)
2301
- TensorAddHasRank(builder, self.hasRank)
2302
- if self.variantTensors is not None:
2303
- TensorAddVariantTensors(builder, variantTensors)
2304
- tensor = TensorEnd(builder)
2305
- return tensor
5989
+ StablehloRngBitGeneratorOptionsStart(builder)
5990
+ StablehloRngBitGeneratorOptionsAddAlgorithm(builder, self.algorithm)
5991
+ stablehloRngBitGeneratorOptions = StablehloRngBitGeneratorOptionsEnd(builder)
5992
+ return stablehloRngBitGeneratorOptions
2306
5993
 
2307
5994
 
2308
5995
  class Conv2DOptions(object):
@@ -2369,8 +6056,15 @@ class Conv2DOptions(object):
2369
6056
  return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
2370
6057
  return 1
2371
6058
 
6059
+ # Conv2DOptions
6060
+ def QuantizedBiasType(self):
6061
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
6062
+ if o != 0:
6063
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
6064
+ return 0
6065
+
2372
6066
  def Conv2DOptionsStart(builder):
2373
- builder.StartObject(6)
6067
+ builder.StartObject(7)
2374
6068
 
2375
6069
  def Conv2DOptionsAddPadding(builder, padding):
2376
6070
  builder.PrependInt8Slot(0, padding, 0)
@@ -2390,6 +6084,9 @@ def Conv2DOptionsAddDilationWFactor(builder, dilationWFactor):
2390
6084
  def Conv2DOptionsAddDilationHFactor(builder, dilationHFactor):
2391
6085
  builder.PrependInt32Slot(5, dilationHFactor, 1)
2392
6086
 
6087
+ def Conv2DOptionsAddQuantizedBiasType(builder, quantizedBiasType):
6088
+ builder.PrependInt8Slot(6, quantizedBiasType, 0)
6089
+
2393
6090
  def Conv2DOptionsEnd(builder):
2394
6091
  return builder.EndObject()
2395
6092
 
@@ -2405,6 +6102,7 @@ class Conv2DOptionsT(object):
2405
6102
  self.fusedActivationFunction = 0 # type: int
2406
6103
  self.dilationWFactor = 1 # type: int
2407
6104
  self.dilationHFactor = 1 # type: int
6105
+ self.quantizedBiasType = 0 # type: int
2408
6106
 
2409
6107
  @classmethod
2410
6108
  def InitFromBuf(cls, buf, pos):
@@ -2433,6 +6131,7 @@ class Conv2DOptionsT(object):
2433
6131
  self.fusedActivationFunction = conv2Doptions.FusedActivationFunction()
2434
6132
  self.dilationWFactor = conv2Doptions.DilationWFactor()
2435
6133
  self.dilationHFactor = conv2Doptions.DilationHFactor()
6134
+ self.quantizedBiasType = conv2Doptions.QuantizedBiasType()
2436
6135
 
2437
6136
  # Conv2DOptionsT
2438
6137
  def Pack(self, builder):
@@ -2443,6 +6142,7 @@ class Conv2DOptionsT(object):
2443
6142
  Conv2DOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction)
2444
6143
  Conv2DOptionsAddDilationWFactor(builder, self.dilationWFactor)
2445
6144
  Conv2DOptionsAddDilationHFactor(builder, self.dilationHFactor)
6145
+ Conv2DOptionsAddQuantizedBiasType(builder, self.quantizedBiasType)
2446
6146
  conv2Doptions = Conv2DOptionsEnd(builder)
2447
6147
  return conv2Doptions
2448
6148
 
@@ -3634,8 +7334,15 @@ class FullyConnectedOptions(object):
3634
7334
  return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
3635
7335
  return False
3636
7336
 
7337
+ # FullyConnectedOptions
7338
+ def QuantizedBiasType(self):
7339
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
7340
+ if o != 0:
7341
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
7342
+ return 0
7343
+
3637
7344
  def FullyConnectedOptionsStart(builder):
3638
- builder.StartObject(4)
7345
+ builder.StartObject(5)
3639
7346
 
3640
7347
  def FullyConnectedOptionsAddFusedActivationFunction(builder, fusedActivationFunction):
3641
7348
  builder.PrependInt8Slot(0, fusedActivationFunction, 0)
@@ -3649,6 +7356,9 @@ def FullyConnectedOptionsAddKeepNumDims(builder, keepNumDims):
3649
7356
  def FullyConnectedOptionsAddAsymmetricQuantizeInputs(builder, asymmetricQuantizeInputs):
3650
7357
  builder.PrependBoolSlot(3, asymmetricQuantizeInputs, 0)
3651
7358
 
7359
+ def FullyConnectedOptionsAddQuantizedBiasType(builder, quantizedBiasType):
7360
+ builder.PrependInt8Slot(4, quantizedBiasType, 0)
7361
+
3652
7362
  def FullyConnectedOptionsEnd(builder):
3653
7363
  return builder.EndObject()
3654
7364
 
@@ -3662,6 +7372,7 @@ class FullyConnectedOptionsT(object):
3662
7372
  self.weightsFormat = 0 # type: int
3663
7373
  self.keepNumDims = False # type: bool
3664
7374
  self.asymmetricQuantizeInputs = False # type: bool
7375
+ self.quantizedBiasType = 0 # type: int
3665
7376
 
3666
7377
  @classmethod
3667
7378
  def InitFromBuf(cls, buf, pos):
@@ -3688,6 +7399,7 @@ class FullyConnectedOptionsT(object):
3688
7399
  self.weightsFormat = fullyConnectedOptions.WeightsFormat()
3689
7400
  self.keepNumDims = fullyConnectedOptions.KeepNumDims()
3690
7401
  self.asymmetricQuantizeInputs = fullyConnectedOptions.AsymmetricQuantizeInputs()
7402
+ self.quantizedBiasType = fullyConnectedOptions.QuantizedBiasType()
3691
7403
 
3692
7404
  # FullyConnectedOptionsT
3693
7405
  def Pack(self, builder):
@@ -3696,6 +7408,7 @@ class FullyConnectedOptionsT(object):
3696
7408
  FullyConnectedOptionsAddWeightsFormat(builder, self.weightsFormat)
3697
7409
  FullyConnectedOptionsAddKeepNumDims(builder, self.keepNumDims)
3698
7410
  FullyConnectedOptionsAddAsymmetricQuantizeInputs(builder, self.asymmetricQuantizeInputs)
7411
+ FullyConnectedOptionsAddQuantizedBiasType(builder, self.quantizedBiasType)
3699
7412
  fullyConnectedOptions = FullyConnectedOptionsEnd(builder)
3700
7413
  return fullyConnectedOptions
3701
7414
 
@@ -7628,8 +11341,15 @@ class TransposeConvOptions(object):
7628
11341
  return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
7629
11342
  return 0
7630
11343
 
11344
+ # TransposeConvOptions
11345
+ def QuantizedBiasType(self):
11346
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
11347
+ if o != 0:
11348
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
11349
+ return 0
11350
+
7631
11351
  def TransposeConvOptionsStart(builder):
7632
- builder.StartObject(4)
11352
+ builder.StartObject(5)
7633
11353
 
7634
11354
  def TransposeConvOptionsAddPadding(builder, padding):
7635
11355
  builder.PrependInt8Slot(0, padding, 0)
@@ -7643,6 +11363,9 @@ def TransposeConvOptionsAddStrideH(builder, strideH):
7643
11363
  def TransposeConvOptionsAddFusedActivationFunction(builder, fusedActivationFunction):
7644
11364
  builder.PrependInt8Slot(3, fusedActivationFunction, 0)
7645
11365
 
11366
+ def TransposeConvOptionsAddQuantizedBiasType(builder, quantizedBiasType):
11367
+ builder.PrependInt8Slot(4, quantizedBiasType, 0)
11368
+
7646
11369
  def TransposeConvOptionsEnd(builder):
7647
11370
  return builder.EndObject()
7648
11371
 
@@ -7656,6 +11379,7 @@ class TransposeConvOptionsT(object):
7656
11379
  self.strideW = 0 # type: int
7657
11380
  self.strideH = 0 # type: int
7658
11381
  self.fusedActivationFunction = 0 # type: int
11382
+ self.quantizedBiasType = 0 # type: int
7659
11383
 
7660
11384
  @classmethod
7661
11385
  def InitFromBuf(cls, buf, pos):
@@ -7682,6 +11406,7 @@ class TransposeConvOptionsT(object):
7682
11406
  self.strideW = transposeConvOptions.StrideW()
7683
11407
  self.strideH = transposeConvOptions.StrideH()
7684
11408
  self.fusedActivationFunction = transposeConvOptions.FusedActivationFunction()
11409
+ self.quantizedBiasType = transposeConvOptions.QuantizedBiasType()
7685
11410
 
7686
11411
  # TransposeConvOptionsT
7687
11412
  def Pack(self, builder):
@@ -7690,6 +11415,7 @@ class TransposeConvOptionsT(object):
7690
11415
  TransposeConvOptionsAddStrideW(builder, self.strideW)
7691
11416
  TransposeConvOptionsAddStrideH(builder, self.strideH)
7692
11417
  TransposeConvOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction)
11418
+ TransposeConvOptionsAddQuantizedBiasType(builder, self.quantizedBiasType)
7693
11419
  transposeConvOptions = TransposeConvOptionsEnd(builder)
7694
11420
  return transposeConvOptions
7695
11421
 
@@ -12532,6 +16258,148 @@ class RightShiftOptionsT(object):
12532
16258
  return rightShiftOptions
12533
16259
 
12534
16260
 
16261
+ class DilateOptions(object):
16262
+ __slots__ = ['_tab']
16263
+
16264
+ @classmethod
16265
+ def GetRootAs(cls, buf, offset=0):
16266
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
16267
+ x = DilateOptions()
16268
+ x.Init(buf, n + offset)
16269
+ return x
16270
+
16271
+ @classmethod
16272
+ def GetRootAsDilateOptions(cls, buf, offset=0):
16273
+ """This method is deprecated. Please switch to GetRootAs."""
16274
+ return cls.GetRootAs(buf, offset)
16275
+ @classmethod
16276
+ def DilateOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
16277
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
16278
+
16279
+ # DilateOptions
16280
+ def Init(self, buf, pos):
16281
+ self._tab = flatbuffers.table.Table(buf, pos)
16282
+
16283
+ def DilateOptionsStart(builder):
16284
+ builder.StartObject(0)
16285
+
16286
+ def DilateOptionsEnd(builder):
16287
+ return builder.EndObject()
16288
+
16289
+
16290
+
16291
+ class DilateOptionsT(object):
16292
+
16293
+ # DilateOptionsT
16294
+ def __init__(self):
16295
+ pass
16296
+
16297
+ @classmethod
16298
+ def InitFromBuf(cls, buf, pos):
16299
+ dilateOptions = DilateOptions()
16300
+ dilateOptions.Init(buf, pos)
16301
+ return cls.InitFromObj(dilateOptions)
16302
+
16303
+ @classmethod
16304
+ def InitFromPackedBuf(cls, buf, pos=0):
16305
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
16306
+ return cls.InitFromBuf(buf, pos+n)
16307
+
16308
+ @classmethod
16309
+ def InitFromObj(cls, dilateOptions):
16310
+ x = DilateOptionsT()
16311
+ x._UnPack(dilateOptions)
16312
+ return x
16313
+
16314
+ # DilateOptionsT
16315
+ def _UnPack(self, dilateOptions):
16316
+ if dilateOptions is None:
16317
+ return
16318
+
16319
+ # DilateOptionsT
16320
+ def Pack(self, builder):
16321
+ DilateOptionsStart(builder)
16322
+ dilateOptions = DilateOptionsEnd(builder)
16323
+ return dilateOptions
16324
+
16325
+
16326
+ class ReduceWindowOptions(object):
16327
+ __slots__ = ['_tab']
16328
+
16329
+ @classmethod
16330
+ def GetRootAs(cls, buf, offset=0):
16331
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
16332
+ x = ReduceWindowOptions()
16333
+ x.Init(buf, n + offset)
16334
+ return x
16335
+
16336
+ @classmethod
16337
+ def GetRootAsReduceWindowOptions(cls, buf, offset=0):
16338
+ """This method is deprecated. Please switch to GetRootAs."""
16339
+ return cls.GetRootAs(buf, offset)
16340
+ @classmethod
16341
+ def ReduceWindowOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
16342
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
16343
+
16344
+ # ReduceWindowOptions
16345
+ def Init(self, buf, pos):
16346
+ self._tab = flatbuffers.table.Table(buf, pos)
16347
+
16348
+ # ReduceWindowOptions
16349
+ def ReduceFunction(self):
16350
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
16351
+ if o != 0:
16352
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
16353
+ return 0
16354
+
16355
+ def ReduceWindowOptionsStart(builder):
16356
+ builder.StartObject(1)
16357
+
16358
+ def ReduceWindowOptionsAddReduceFunction(builder, reduceFunction):
16359
+ builder.PrependInt32Slot(0, reduceFunction, 0)
16360
+
16361
+ def ReduceWindowOptionsEnd(builder):
16362
+ return builder.EndObject()
16363
+
16364
+
16365
+
16366
+ class ReduceWindowOptionsT(object):
16367
+
16368
+ # ReduceWindowOptionsT
16369
+ def __init__(self):
16370
+ self.reduceFunction = 0 # type: int
16371
+
16372
+ @classmethod
16373
+ def InitFromBuf(cls, buf, pos):
16374
+ reduceWindowOptions = ReduceWindowOptions()
16375
+ reduceWindowOptions.Init(buf, pos)
16376
+ return cls.InitFromObj(reduceWindowOptions)
16377
+
16378
+ @classmethod
16379
+ def InitFromPackedBuf(cls, buf, pos=0):
16380
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
16381
+ return cls.InitFromBuf(buf, pos+n)
16382
+
16383
+ @classmethod
16384
+ def InitFromObj(cls, reduceWindowOptions):
16385
+ x = ReduceWindowOptionsT()
16386
+ x._UnPack(reduceWindowOptions)
16387
+ return x
16388
+
16389
+ # ReduceWindowOptionsT
16390
+ def _UnPack(self, reduceWindowOptions):
16391
+ if reduceWindowOptions is None:
16392
+ return
16393
+ self.reduceFunction = reduceWindowOptions.ReduceFunction()
16394
+
16395
+ # ReduceWindowOptionsT
16396
+ def Pack(self, builder):
16397
+ ReduceWindowOptionsStart(builder)
16398
+ ReduceWindowOptionsAddReduceFunction(builder, self.reduceFunction)
16399
+ reduceWindowOptions = ReduceWindowOptionsEnd(builder)
16400
+ return reduceWindowOptions
16401
+
16402
+
12535
16403
  class OperatorCode(object):
12536
16404
  __slots__ = ['_tab']
12537
16405
 
@@ -12853,8 +16721,25 @@ class Operator(object):
12853
16721
  return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
12854
16722
  return 0
12855
16723
 
16724
+ # Operator
16725
+ def BuiltinOptions2Type(self):
16726
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26))
16727
+ if o != 0:
16728
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
16729
+ return 0
16730
+
16731
+ # Operator
16732
+ def BuiltinOptions2(self):
16733
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28))
16734
+ if o != 0:
16735
+ from flatbuffers.table import Table
16736
+ obj = Table(bytearray(), 0)
16737
+ self._tab.Union(obj, o)
16738
+ return obj
16739
+ return None
16740
+
12856
16741
  def OperatorStart(builder):
12857
- builder.StartObject(11)
16742
+ builder.StartObject(13)
12858
16743
 
12859
16744
  def OperatorAddOpcodeIndex(builder, opcodeIndex):
12860
16745
  builder.PrependUint32Slot(0, opcodeIndex, 0)
@@ -12904,6 +16789,12 @@ def OperatorAddLargeCustomOptionsOffset(builder, largeCustomOptionsOffset):
12904
16789
  def OperatorAddLargeCustomOptionsSize(builder, largeCustomOptionsSize):
12905
16790
  builder.PrependUint64Slot(10, largeCustomOptionsSize, 0)
12906
16791
 
16792
+ def OperatorAddBuiltinOptions2Type(builder, builtinOptions2Type):
16793
+ builder.PrependUint8Slot(11, builtinOptions2Type, 0)
16794
+
16795
+ def OperatorAddBuiltinOptions2(builder, builtinOptions2):
16796
+ builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(builtinOptions2), 0)
16797
+
12907
16798
  def OperatorEnd(builder):
12908
16799
  return builder.EndObject()
12909
16800
 
@@ -12928,6 +16819,8 @@ class OperatorT(object):
12928
16819
  self.intermediates = None # type: List[int]
12929
16820
  self.largeCustomOptionsOffset = 0 # type: int
12930
16821
  self.largeCustomOptionsSize = 0 # type: int
16822
+ self.builtinOptions2Type = 0 # type: int
16823
+ self.builtinOptions2 = None # type: Union[None, StablehloConcatenateOptionsT, StablehloBroadcastInDimOptionsT, StablehloSliceOptionsT, StablehloConvolutionOptionsT, StablehloCustomCallOptionsT, StablehloReduceOptionsT, StablehloScatterOptionsT, StablehloCompareOptionsT, StablehloDynamicSliceOptionsT, StablehloPadOptionsT, StablehloIotaOptionsT, StablehloDotGeneralOptionsT, StablehloReduceWindowOptionsT, StablehloSortOptionsT, StablehloWhileOptionsT, StablehloGatherOptionsT, StablehloTransposeOptionsT, DilateOptionsT, StablehloRngBitGeneratorOptionsT, ReduceWindowOptionsT]
12931
16824
 
12932
16825
  @classmethod
12933
16826
  def InitFromBuf(cls, buf, pos):
@@ -12991,6 +16884,8 @@ class OperatorT(object):
12991
16884
  self.intermediates = operator.IntermediatesAsNumpy()
12992
16885
  self.largeCustomOptionsOffset = operator.LargeCustomOptionsOffset()
12993
16886
  self.largeCustomOptionsSize = operator.LargeCustomOptionsSize()
16887
+ self.builtinOptions2Type = operator.BuiltinOptions2Type()
16888
+ self.builtinOptions2 = BuiltinOptions2Creator(self.builtinOptions2Type, operator.BuiltinOptions2())
12994
16889
 
12995
16890
  # OperatorT
12996
16891
  def Pack(self, builder):
@@ -13036,6 +16931,8 @@ class OperatorT(object):
13036
16931
  for i in reversed(range(len(self.intermediates))):
13037
16932
  builder.PrependInt32(self.intermediates[i])
13038
16933
  intermediates = builder.EndVector()
16934
+ if self.builtinOptions2 is not None:
16935
+ builtinOptions2 = self.builtinOptions2.Pack(builder)
13039
16936
  OperatorStart(builder)
13040
16937
  OperatorAddOpcodeIndex(builder, self.opcodeIndex)
13041
16938
  if self.inputs is not None:
@@ -13054,6 +16951,9 @@ class OperatorT(object):
13054
16951
  OperatorAddIntermediates(builder, intermediates)
13055
16952
  OperatorAddLargeCustomOptionsOffset(builder, self.largeCustomOptionsOffset)
13056
16953
  OperatorAddLargeCustomOptionsSize(builder, self.largeCustomOptionsSize)
16954
+ OperatorAddBuiltinOptions2Type(builder, self.builtinOptions2Type)
16955
+ if self.builtinOptions2 is not None:
16956
+ OperatorAddBuiltinOptions2(builder, builtinOptions2)
13057
16957
  operator = OperatorEnd(builder)
13058
16958
  return operator
13059
16959