-
Notifications
You must be signed in to change notification settings - Fork 179
Expand file tree
/
Copy pathselect_operator.py
More file actions
executable file
·1520 lines (1202 loc) · 64.9 KB
/
select_operator.py
File metadata and controls
executable file
·1520 lines (1202 loc) · 64.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
import numpy
import flatbuffers
import tflite.Model
import tflite.SubGraph
import tflite.BuiltinOptions
import argparse
import pkg_resources
import json
# On flatbuffers 2.0, EndVector doesn't require length argument any more.
# But flatbuffers under 2.0 (ex. 1.12) requires length argument.
# We need this workaround until we abandon flatbuffers 1.12.
# Reference: https://github.com/google/flatbuffers/issues/6858
def EndVector(builder, len):
flat_version = pkg_resources.get_distribution('flatbuffers').version
if pkg_resources.parse_version(flat_version) < pkg_resources.parse_version("2.0"):
return builder.EndVector(len)
else:
return builder.EndVector()
# Assume we use only main model in model file
# Get selected operators from file, and return operator index list
def GetOperatorList(oplist_file):
lines = oplist_file.readlines()
opcode_list = []
for line in lines:
words = line.split()
for word in words:
if word.isdigit():
opcode_list.append(int(word))
else:
opcode_range = word.split('-')
if ((len(opcode_range) == 2) and opcode_range[0].isdigit()
and opcode_range[1].isdigit()):
start = int(opcode_range[0])
end = int(opcode_range[1])
for num in range(start, end + 1):
opcode_list.append(int(num))
else:
print("Error: Cannot get operator list")
print(
"Please pass operators as operator index or range list split by space and/or line"
)
exit(1)
if len(opcode_list) == 0:
print("No selected operator")
exit(1)
return opcode_list
def GetUsedSubgraphsList(sample_model, subg_num, operator_list, used_subgraphs_list):
import tflite.IfOptions
import tflite.WhileOptions
subg_list = []
selected_subgraph = sample_model.Subgraphs(subg_num)
for operator_idx in operator_list:
selected_operator = selected_subgraph.Operators(operator_idx)
if selected_operator.BuiltinOptionsType() == tflite.BuiltinOptions.BuiltinOptions(
).IfOptions:
selected_builtin_option = selected_operator.BuiltinOptions()
if_option = tflite.IfOptions.IfOptions()
if_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
subg_list.append(if_option.ElseSubgraphIndex())
subg_list.append(if_option.ThenSubgraphIndex())
if selected_operator.BuiltinOptionsType() == tflite.BuiltinOptions.BuiltinOptions(
).WhileOptions:
selected_builtin_option = selected_operator.BuiltinOptions()
while_option = tflite.WhileOptions.WhileOptions()
while_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
subg_list.append(while_option.BodySubgraphIndex())
subg_list.append(while_option.CondSubgraphIndex())
for idx in subg_list:
if idx not in used_subgraphs_list:
used_subgraphs_list.append(idx)
GetUsedSubgraphsList(sample_model, idx,
range(sample_model.Subgraphs(idx).OperatorsLength() - 1),
used_subgraphs_list)
def GenerateOperatorCodes(new_builder, sample_model, used_opcodes_dic,
used_subgraphs_dic):
operator_code_num = sample_model.OperatorCodesLength()
new_operator_code_list = []
new_operator_code_string_list = {}
if operator_code_num == 0:
return 0
# Create operator_code string
for operator_code_idx in range(operator_code_num):
if operator_code_idx in used_opcodes_dic:
operator_code = sample_model.OperatorCodes(operator_code_idx)
operator_code_string = operator_code.CustomCode()
if operator_code_string and (operator_code_string != "") and (
not operator_code_string in new_operator_code_string_list):
new_operator_code_string_list[
operator_code_string] = new_builder.CreateString(operator_code_string)
# Create tables of operator_code
for operator_code_idx in range(operator_code_num):
if operator_code_idx in used_opcodes_dic:
operator_code = sample_model.OperatorCodes(operator_code_idx)
# Create operator_code table
tflite.OperatorCode.OperatorCodeStart(new_builder)
tflite.OperatorCode.OperatorCodeAddBuiltinCode(new_builder,
operator_code.BuiltinCode())
tflite.OperatorCode.OperatorCodeAddDeprecatedBuiltinCode(new_builder,
operator_code.DeprecatedBuiltinCode())
new_operator_code_string = operator_code.CustomCode()
if new_operator_code_string in new_operator_code_string_list:
tflite.OperatorCode.OperatorCodeAddCustomCode(
new_builder, new_operator_code_string_list[new_operator_code_string])
new_operator_code = tflite.OperatorCode.OperatorCodeEnd(new_builder)
new_operator_code_list.append(new_operator_code)
# Create operator_code vector
new_operator_code_num = len(new_operator_code_list)
tflite.Model.ModelStartOperatorCodesVector(new_builder, new_operator_code_num)
for operator_code_idx in reversed(range(new_operator_code_num)):
new_builder.PrependUOffsetTRelative(new_operator_code_list[operator_code_idx])
return EndVector(new_builder, new_operator_code_num)
def GenerateQuantization(new_builder, selected_quantization):
# Create min vector
min_num = selected_quantization.MinLength()
if min_num != 0:
tflite.QuantizationParameters.QuantizationParametersStartMinVector(
new_builder, min_num)
for min_idx in reversed(range(min_num)):
new_builder.PrependFloat32(selected_quantization.Min(min_idx))
new_min = EndVector(new_builder, min_num)
# Create max vector
max_num = selected_quantization.MaxLength()
if max_num != 0:
tflite.QuantizationParameters.QuantizationParametersStartMaxVector(
new_builder, max_num)
for max_idx in reversed(range(max_num)):
new_builder.PrependFloat32(selected_quantization.Max(max_idx))
new_max = EndVector(new_builder, max_num)
# Create scale vector
scale_num = selected_quantization.ScaleLength()
if scale_num != 0:
tflite.QuantizationParameters.QuantizationParametersStartScaleVector(
new_builder, scale_num)
for scale_idx in reversed(range(scale_num)):
new_builder.PrependFloat32(selected_quantization.Scale(scale_idx))
new_scale = EndVector(new_builder, scale_num)
# Create zero_point vector
zeropoint_num = selected_quantization.ZeroPointLength()
if zeropoint_num != 0:
tflite.QuantizationParameters.QuantizationParametersStartZeroPointVector(
new_builder, zeropoint_num)
for zeropoint_idx in reversed(range(zeropoint_num)):
new_builder.PrependInt64(selected_quantization.ZeroPoint(zeropoint_idx))
new_zeropoint = EndVector(new_builder, zeropoint_num)
# Create quantization
tflite.QuantizationParameters.QuantizationParametersStart(new_builder)
if min_num != 0:
tflite.QuantizationParameters.QuantizationParametersAddMin(new_builder, new_min)
if max_num != 0:
tflite.QuantizationParameters.QuantizationParametersAddMax(new_builder, new_max)
if scale_num != 0:
tflite.QuantizationParameters.QuantizationParametersAddScale(
new_builder, new_scale)
if zeropoint_num != 0:
tflite.QuantizationParameters.QuantizationParametersAddZeroPoint(
new_builder, new_zeropoint)
quantized_dimension = selected_quantization.QuantizedDimension()
if quantized_dimension != 0:
tflite.QuantizationParameters.QuantizationParametersAddQuantizedDimension(
new_builder, quantized_dimension)
return tflite.QuantizationParameters.QuantizationParametersEnd(new_builder)
def GenerateTensor(new_builder, selected_tensor, used_buffers_dic):
# Create shape vector for tensor
shape_num = selected_tensor.ShapeLength()
tflite.Tensor.TensorStartShapeVector(new_builder, shape_num)
if shape_num != 0:
for shape_idx in reversed(range(shape_num)):
new_builder.PrependInt32(selected_tensor.Shape(shape_idx))
new_shape = EndVector(new_builder, shape_num)
# Create tensor_type
tensor_type = selected_tensor.Type()
# Create input vector for tensor
buffer_idx = selected_tensor.Buffer()
new_buffer_idx = used_buffers_dic[buffer_idx]
# Create name string
name_string = selected_tensor.Name()
if name_string != "":
new_name = new_builder.CreateString(name_string)
# Create quantization
quantization = selected_tensor.Quantization()
if quantization != None:
new_quantization = GenerateQuantization(new_builder, quantization)
# Create IsVariable
is_variable = selected_tensor.IsVariable()
# Create Sparsity
sparsity = selected_tensor.Sparsity()
# Create tensor
tflite.Tensor.TensorStart(new_builder)
tflite.Tensor.TensorAddShape(new_builder, new_shape)
tflite.Tensor.TensorAddType(new_builder, tensor_type)
if (new_buffer_idx != 0):
tflite.Tensor.TensorAddBuffer(new_builder, new_buffer_idx)
if name_string != "":
tflite.Tensor.TensorAddName(new_builder, new_name)
if quantization != None:
tflite.Tensor.TensorAddQuantization(new_builder, new_quantization)
tflite.Tensor.TensorAddIsVariable(new_builder, is_variable)
if sparsity != None:
tflite.Tensor.TensorAddSparsity(new_builder, sparsity)
return tflite.Tensor.TensorEnd(new_builder)
def GenerateTensors(new_builder, selected_subgraph, used_tensors_dic, used_buffers_dic):
tensor_num = selected_subgraph.TensorsLength()
new_tensor_list = []
if tensor_num == 0:
return 0
for tensor_idx in range(tensor_num):
if tensor_idx in used_tensors_dic:
selected_tensor = selected_subgraph.Tensors(tensor_idx)
new_tensor = GenerateTensor(new_builder, selected_tensor, used_buffers_dic)
new_tensor_list.append(new_tensor)
new_tensor_num = len(new_tensor_list)
if new_tensor_num == 0:
return 0
tflite.SubGraph.SubGraphStartTensorsVector(new_builder, new_tensor_num)
for new_tensor in reversed(new_tensor_list):
new_builder.PrependUOffsetTRelative(new_tensor)
return EndVector(new_builder, new_tensor_num)
def GenerateBuiltinOption(new_builder, selected_builtin_option, builtin_option_type,
used_subgraphs_dic):
# Conv2D option
import tflite.Conv2DOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().Conv2DOptions:
conv2d_options = tflite.Conv2DOptions.Conv2DOptions()
conv2d_options.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.Conv2DOptions.Conv2DOptionsStart(new_builder)
tflite.Conv2DOptions.Conv2DOptionsAddPadding(new_builder,
conv2d_options.Padding())
tflite.Conv2DOptions.Conv2DOptionsAddStrideW(new_builder,
conv2d_options.StrideW())
tflite.Conv2DOptions.Conv2DOptionsAddStrideH(new_builder,
conv2d_options.StrideH())
tflite.Conv2DOptions.Conv2DOptionsAddDilationWFactor(
new_builder, conv2d_options.DilationWFactor())
tflite.Conv2DOptions.Conv2DOptionsAddDilationHFactor(
new_builder, conv2d_options.DilationHFactor())
tflite.Conv2DOptions.Conv2DOptionsAddFusedActivationFunction(
new_builder, conv2d_options.FusedActivationFunction())
return tflite.Conv2DOptions.Conv2DOptionsEnd(new_builder)
# DepthwiseConv2D option
import tflite.DepthwiseConv2DOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions(
).DepthwiseConv2DOptions:
depthconv2d_option = tflite.DepthwiseConv2DOptions.DepthwiseConv2DOptions()
depthconv2d_option.Init(selected_builtin_option.Bytes,
selected_builtin_option.Pos)
tflite.DepthwiseConv2DOptions.DepthwiseConv2DOptionsStart(new_builder)
tflite.DepthwiseConv2DOptions.DepthwiseConv2DOptionsAddPadding(
new_builder, depthconv2d_option.Padding())
tflite.DepthwiseConv2DOptions.DepthwiseConv2DOptionsAddStrideW(
new_builder, depthconv2d_option.StrideW())
tflite.DepthwiseConv2DOptions.DepthwiseConv2DOptionsAddStrideH(
new_builder, depthconv2d_option.StrideH())
tflite.DepthwiseConv2DOptions.DepthwiseConv2DOptionsAddDepthMultiplier(
new_builder, depthconv2d_option.DepthMultiplier())
tflite.DepthwiseConv2DOptions.DepthwiseConv2DOptionsAddFusedActivationFunction(
new_builder, depthconv2d_option.FusedActivationFunction())
tflite.DepthwiseConv2DOptions.DepthwiseConv2DOptionsAddDilationWFactor(
new_builder, depthconv2d_option.DilationWFactor())
tflite.DepthwiseConv2DOptions.DepthwiseConv2DOptionsAddDilationHFactor(
new_builder, depthconv2d_option.DilationHFactor())
return tflite.DepthwiseConv2DOptions.DepthwiseConv2DOptionsEnd(new_builder)
# ConcatEmbeddingsOptions: not supported
# LSHProjectionOptions: not supported
# Pool2DPOption
import tflite.Pool2DOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().Pool2DOptions:
pool2d_option = tflite.Pool2DOptions.Pool2DOptions()
pool2d_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.Pool2DOptions.Pool2DOptionsStart(new_builder)
tflite.Pool2DOptions.Pool2DOptionsAddPadding(new_builder, pool2d_option.Padding())
tflite.Pool2DOptions.Pool2DOptionsAddStrideW(new_builder, pool2d_option.StrideW())
tflite.Pool2DOptions.Pool2DOptionsAddStrideH(new_builder, pool2d_option.StrideH())
tflite.Pool2DOptions.Pool2DOptionsAddFilterWidth(new_builder,
pool2d_option.FilterWidth())
tflite.Pool2DOptions.Pool2DOptionsAddFilterHeight(new_builder,
pool2d_option.FilterHeight())
tflite.Pool2DOptions.Pool2DOptionsAddFusedActivationFunction(
new_builder, pool2d_option.FusedActivationFunction())
return tflite.Pool2DOptions.Pool2DOptionsEnd(new_builder)
# SVDFOptions: not supported
# RNNOptions
import tflite.RNNOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().RNNOptions:
rnn_option = tflite.RNNOptions.RNNOptions()
rnn_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.RNNOptions.RNNOptionsStart(new_builder)
tflite.RNNOptions.RNNOptionsAddFusedActivationFunction(
new_builder, rnn_option.FusedActivationFunction())
return tflite.RNNOptions.RNNOptionsEnd(new_builder)
# FullyConnectedOptions
import tflite.FullyConnectedOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions(
).FullyConnectedOptions:
fc_option = tflite.FullyConnectedOptions.FullyConnectedOptions()
fc_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.FullyConnectedOptions.FullyConnectedOptionsStart(new_builder)
tflite.FullyConnectedOptions.FullyConnectedOptionsAddFusedActivationFunction(
new_builder, fc_option.FusedActivationFunction())
return tflite.FullyConnectedOptions.FullyConnectedOptionsEnd(new_builder)
# SoftmaxOptions
import tflite.SoftmaxOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().SoftmaxOptions:
softmax_option = tflite.SoftmaxOptions.SoftmaxOptions()
softmax_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.SoftmaxOptions.SoftmaxOptionsStart(new_builder)
tflite.SoftmaxOptions.SoftmaxOptionsAddBeta(new_builder, softmax_option.Beta())
return tflite.SoftmaxOptions.SoftmaxOptionsEnd(new_builder)
# ConcatenationOptions
import tflite.ConcatenationOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().ConcatenationOptions:
concat_option = tflite.ConcatenationOptions.ConcatenationOptions()
concat_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.ConcatenationOptions.ConcatenationOptionsStart(new_builder)
tflite.ConcatenationOptions.ConcatenationOptionsAddAxis(
new_builder, concat_option.Axis())
tflite.ConcatenationOptions.ConcatenationOptionsAddFusedActivationFunction(
new_builder, concat_option.FusedActivationFunction())
return tflite.ConcatenationOptions.ConcatenationOptionsEnd(new_builder)
# AddOptions
import tflite.AddOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().AddOptions:
add_option = tflite.AddOptions.AddOptions()
add_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.AddOptions.AddOptionsStart(new_builder)
tflite.AddOptions.AddOptionsAddFusedActivationFunction(
new_builder, add_option.FusedActivationFunction())
return tflite.AddOptions.AddOptionsEnd(new_builder)
# L2NormOptions
import tflite.L2NormOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().L2NormOptions:
l2norm_option = tflite.L2NormOptions.L2NormOptions()
l2norm_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.L2NormOptions.L2NormOptionsStart(new_builder)
tflite.L2NormOptions.L2NormOptionsAddFusedActivationFunction(
new_builder, l2norm_option.FusedActivationFunction())
return tflite.L2NormOptions.L2NormOptionsEnd(new_builder)
# LocalResponseNormalizationOptions
import tflite.LocalResponseNormalizationOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions(
).LocalResponseNormalizationOptions:
lrn_option = tflite.LocalResponseNormalizationOptions.LocalResponseNormalizationOptions(
)
lrn_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.LocalResponseNormalizationOptions.LocalResponseNormalizationOptionsStart(
new_builder)
tflite.LocalResponseNormalizationOptions.LocalResponseNormalizationOptionsAddRadius(
new_builder, lrn_option.Radius())
tflite.LocalResponseNormalizationOptions.LocalResponseNormalizationOptionsAddBias(
new_builder, lrn_option.Bias())
tflite.LocalResponseNormalizationOptions.LocalResponseNormalizationOptionsAddAlpha(
new_builder, lrn_option.Alpha())
tflite.LocalResponseNormalizationOptions.LocalResponseNormalizationOptionsAddBeta(
new_builder, lrn_option.Beta())
return tflite.LocalResponseNormalizationOptions.LocalResponseNormalizationOptionsEnd(
new_builder)
# LSTMOptions: not supported
# ResizeBilinearOptions
import tflite.ResizeBilinearOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions(
).ResizeBilinearOptions:
resize_bilinear_option = tflite.ResizeBilinearOptions.ResizeBilinearOptions()
resize_bilinear_option.Init(selected_builtin_option.Bytes,
selected_builtin_option.Pos)
tflite.ResizeBilinearOptions.ResizeBilinearOptionsStart(new_builder)
tflite.ResizeBilinearOptions.ResizeBilinearOptionsAddAlignCorners(
new_builder, resize_bilinear_option.AlignCorners())
return tflite.ResizeBilinearOptions.ResizeBilinearOptionsEnd(new_builder)
# CallOptions: not supported
# ReshapeOptions
import tflite.ReshapeOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().ReshapeOptions:
reshape_option = tflite.ReshapeOptions.ReshapeOptions()
reshape_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
shape_num = reshape_option.NewShapeLength()
if shape_num != 0:
tflite.ReshapeOptions.ReshapeOptionsStartNewShapeVector(
new_builder, shape_num)
for new_shape_idx in reversed(range(shape_num)):
new_shape_val = reshape_option.NewShape(new_shape_idx)
new_builder.PrependInt32(new_shape_val)
new_shape = EndVector(new_builder, shape_num)
tflite.ReshapeOptions.ReshapeOptionsStart(new_builder)
if shape_num != 0:
tflite.ReshapeOptions.ReshapeOptionsAddNewShape(new_builder, new_shape)
return tflite.ReshapeOptions.ReshapeOptionsEnd(new_builder)
# SkipGramOptions: not supported
# SpaceToDepthOptions
import tflite.SpaceToDepthOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().SpaceToDepthOptions:
space_to_depth_option = tflite.SpaceToDepthOptions.SpaceToDepthOptions()
space_to_depth_option.Init(selected_builtin_option.Bytes,
selected_builtin_option.Pos)
tflite.SpaceToDepthOptions.SpaceToDepthOptionsStart(new_builder)
tflite.SpaceToDepthOptions.SpaceToDepthOptionsAddBlockSize(
new_builder, space_to_depth_option.BlockSize())
return tflite.SpaceToDepthOptions.SpaceToDepthOptionsEnd(new_builder)
# EmbeddingLookupSparseOptions: not supported
# MulOptions
import tflite.MulOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().MulOptions:
mul_option = tflite.MulOptions.MulOptions()
mul_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.MulOptions.MulOptionsStart(new_builder)
tflite.MulOptions.MulOptionsAddFusedActivationFunction(
new_builder, mul_option.FusedActivationFunction())
return tflite.MulOptions.MulOptionsEnd(new_builder)
# PadOptions
import tflite.PadOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().PadOptions:
pad_option = tflite.PadOptions.PadOptions()
pad_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.PadOptions.PadOptionsStart(new_builder)
return tflite.PadOptions.PadOptionsEnd(new_builder)
# GatherOptions
import tflite.GatherOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().GatherOptions:
gather_option = tflite.GatherOptions.GatherOptions()
gather_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.GatherOptions.GatherOptionsStart(new_builder)
tflite.GatherOptions.GatherOptionsAddAxis(new_builder, gather_option.Axis())
return tflite.GatherOptions.GatherOptionsEnd(new_builder)
# BatchToSpaceNDOptions
import tflite.BatchToSpaceNDOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions(
).BatchToSpaceNDOptions:
btsnd_option = tflite.BatchToSpaceNDOptions.BatchToSpaceNDOptions()
btsnd_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.BatchToSpaceNDOptions.BatchToSpaceNDOptionsStart(new_builder)
return tflite.BatchToSpaceNDOptions.BatchToSpaceNDOptionsEnd(new_builder)
# SpaceToBatchNDOptions
import tflite.SpaceToBatchNDOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions(
).SpaceToBatchNDOptions:
stbnd_option = tflite.SpaceToBatchNDOptions.SpaceToBatchNDOptions()
stbnd_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.SpaceToBatchNDOptions.SpaceToBatchNDOptionsStart(new_builder)
return tflite.SpaceToBatchNDOptions.SpaceToBatchNDOptionsEnd(new_builder)
# TransposeOptions:
import tflite.TransposeOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().TransposeOptions:
transpose_option = tflite.TransposeOptions.TransposeOptions()
transpose_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.TransposeOptions.TransposeOptionsStart(new_builder)
return tflite.TransposeOptions.TransposeOptionsEnd(new_builder)
# ReducerOptions
import tflite.ReducerOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().ReducerOptions:
reducer_option = tflite.ReducerOptions.ReducerOptions()
reducer_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.ReducerOptions.ReducerOptionsStart(new_builder)
tflite.ReducerOptions.ReducerOptionsAddKeepDims(new_builder,
reducer_option.KeepDims())
return tflite.ReducerOptions.ReducerOptionsEnd(new_builder)
# SubOptions
import tflite.SubOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().SubOptions:
sub_option = tflite.SubOptions.SubOptions()
sub_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.SubOptions.SubOptionsStart(new_builder)
tflite.SubOptions.SubOptionsAddFusedActivationFunction(
new_builder, sub_option.FusedActivationFunction())
return tflite.SubOptions.SubOptionsEnd(new_builder)
# DivOptions
import tflite.DivOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().DivOptions:
div_option = tflite.DivOptions.DivOptions()
div_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.DivOptions.DivOptionsStart(new_builder)
tflite.DivOptions.DivOptionsAddFusedActivationFunction(
new_builder, div_option.FusedActivationFunction())
return tflite.DivOptions.DivOptionsEnd(new_builder)
# SqueezeOptions
import tflite.SqueezeOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().SqueezeOptions:
squeeze_option = tflite.SqueezeOptions.SqueezeOptions()
squeeze_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
squeeze_dims_num = squeeze_option.SqueezeDimsLength()
if squeeze_dims_num != 0:
tflite.SqueezeOptions.SqueezeOptionsStartSqueezeDimsVector(
new_builder, squeeze_dims_num)
for squeeze_dims_idx in reversed(range(squeeze_dims_num)):
squeeze_dims_val = squeeze_option.SqueezeDims(squeeze_dims_idx)
new_builder.PrependInt32(squeeze_dims_val)
new_squeeze_dims = EndVector(new_builder, squeeze_dims_num)
tflite.SqueezeOptions.SqueezeOptionsStart(new_builder)
if squeeze_dims_num != 0:
tflite.SqueezeOptions.SqueezeOptionsAddSqueezeDims(new_builder,
new_squeeze_dims)
return tflite.SqueezeOptions.SqueezeOptionsEnd(new_builder)
# SequenceRNNOptions: not supported
# StridedSliceOptions
import tflite.StridedSliceOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().StridedSliceOptions:
stride_slice_option = tflite.StridedSliceOptions.StridedSliceOptions()
stride_slice_option.Init(selected_builtin_option.Bytes,
selected_builtin_option.Pos)
tflite.StridedSliceOptions.StridedSliceOptionsStart(new_builder)
tflite.StridedSliceOptions.StridedSliceOptionsAddBeginMask(
new_builder, stride_slice_option.BeginMask())
tflite.StridedSliceOptions.StridedSliceOptionsAddEndMask(
new_builder, stride_slice_option.EndMask())
tflite.StridedSliceOptions.StridedSliceOptionsAddEllipsisMask(
new_builder, stride_slice_option.EllipsisMask())
tflite.StridedSliceOptions.StridedSliceOptionsAddNewAxisMask(
new_builder, stride_slice_option.NewAxisMask())
tflite.StridedSliceOptions.StridedSliceOptionsAddShrinkAxisMask(
new_builder, stride_slice_option.ShrinkAxisMask())
return tflite.StridedSliceOptions.StridedSliceOptionsEnd(new_builder)
# ExpOptions
import tflite.ExpOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().ExpOptions:
exp_option = tflite.ExpOptions.ExpOptions()
exp_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.ExpOptions.ExpOptionsStart(new_builder)
return tflite.ExpOptions.ExpOptionsEnd(new_builder)
# TopKV2Options
import tflite.TopKV2Options
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().TopKV2Options:
topkv2_option = tflite.TopKV2Options.TopKV2Options()
topkv2_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.TopKV2Options.TopKV2OptionsStart(new_builder)
return tflite.TopKV2Options.TopKV2OptionsEnd(new_builder)
# SplitOptions
import tflite.SplitOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().SplitOptions:
split_option = tflite.SplitOptions.SplitOptions()
split_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.SplitOptions.SplitOptionsStart(new_builder)
tflite.SplitOptions.SplitOptionsAddNumSplits(new_builder,
split_option.NumSplits())
return tflite.SplitOptions.SplitOptionsEnd(new_builder)
# LogSoftmaxOptions: not supported
# CastOptions: not supported
import tflite.CastOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().CastOptions:
cast_option = tflite.CastOptions.CastOptions()
cast_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.CastOptions.CastOptionsStart(new_builder)
return tflite.CastOptions.CastOptionsEnd(new_builder)
# DequantizeOptions:
import tflite.DequantizeOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().DequantizeOptions:
dequantize_option = tflite.DequantizeOptions.DequantizeOptions()
dequantize_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.EqualOptions.DequantizeOptionsStart(new_builder)
return tflite.DequantizeOptions.DequantizeOptionsEnd(new_builder)
# MaximumMinimumOptions: not supported
# ArgMaxOptions
import tflite.ArgMaxOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().ArgMaxOptions:
arg_max_option = tflite.ArgMaxOptions.ArgMaxOptions()
arg_max_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.ArgMaxOptions.ArgMaxOptionsStart(new_builder)
tflite.ArgMaxOptions.ArgMaxOptionsAddOutputType(new_builder,
arg_max_option.OutputType())
return tflite.ArgMaxOptions.ArgMaxOptionsEnd(new_builder)
# LessOptions: not supported
# NegOptions
import tflite.NegOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().NegOptions:
neg_option = tflite.NegOptions.NegOptions()
neg_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.NegOptions.NegOptionsStart(new_builder)
return tflite.NegOptions.NegOptionsEnd(new_builder)
# EqualOptions
import tflite.EqualOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().EqualOptions:
equal_option = tflite.EqualOptions.EqualOptions()
equal_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.EqualOptions.EqualOptionsStart(new_builder)
return tflite.EqualOptions.EqualOptionsEnd(new_builder)
# PadV2Options: not supported
# GreaterOptions: not supported
# GreaterEqualOptions: not supported
# LessEqualOptions: not supported
# SelectOptions
import tflite.SelectOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().SelectOptions:
select_option = tflite.SelectOptions.SelectOptions()
select_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.SelectOptions.SelectOptionsStart(new_builder)
return tflite.SelectOptions.SelectOptionsEnd(new_builder)
# SliceOptions: not supported
# TransposeConvOptions
import tflite.TransposeConvOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().TransposeConvOptions:
transposeconv_option = tflite.TransposeConvOptions.TransposeConvOptions()
transposeconv_option.Init(selected_builtin_option.Bytes,
selected_builtin_option.Pos)
tflite.TransposeConvOptions.TransposeConvOptionsStart(new_builder)
tflite.TransposeConvOptions.TransposeConvOptionsAddPadding(
new_builder, transposeconv_option.Padding())
tflite.TransposeConvOptions.TransposeConvOptionsAddStrideW(
new_builder, transposeconv_option.StrideW())
tflite.TransposeConvOptions.TransposeConvOptionsAddStrideH(
new_builder, transposeconv_option.StrideH())
return tflite.TransposeConvOptions.TransposeConvOptionsEnd(new_builder)
# SparseToDenseOptions: not supported
# TileOptions: not supported
# ExpandDimsOptions:
import tflite.ExpandDimsOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().ExpandDimsOptions:
expanddims_option = tflite.ExpandDimsOptions.ExpandDimsOptions()
expanddims_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.ExpandDimsOptions.ExpandDimsOptionsStart(new_builder)
return tflite.ExpandDimsOptions.ExpandDimsOptionsEnd(new_builder)
# NotEqualOptions:
import tflite.NotEqualOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().NotEqualOptions:
notequal_option = tflite.NotEqualOptions.NotEqualOptions()
notequal_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.NotEqualOptions.NotEqualOptionsStart(new_builder)
return tflite.NotEqualOptions.NotEqualOptionsEnd(new_builder)
# ShapeOptions:
import tflite.ShapeOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().ShapeOptions:
shape_option = tflite.ShapeOptions.ShapeOptions()
shape_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.ShapeOptions.ShapeOptionsStart(new_builder)
tflite.ShapeOptions.ShapeOptionsAddOutType(new_builder, shape_option.OutType())
return tflite.ShapeOptions.ShapeOptionsEnd(new_builder)
# PowOptions: not supported
# ArgMinOptions: not supported
# FakeQuantOptions: not supported
# PackOptions:
import tflite.PackOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().PackOptions:
pack_option = tflite.PackOptions.PackOptions()
pack_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.PackOptions.PackOptionsStart(new_builder)
tflite.PackOptions.PackOptionsAddValuesCount(new_builder,
pack_option.ValuesCount())
tflite.PackOptions.PackOptionsAddAxis(new_builder, pack_option.Axis())
return tflite.PackOptions.PackOptionsEnd(new_builder)
# LogicalOrOptions:
import tflite.LogicalOrOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().LogicalOrOptions:
logical_or_option = tflite.LogicalAndOptions.LogicalOrOptions()
logical_or_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.LogicalOrOptions.LogicalOrOptionsStart(new_builder)
return tflite.LogicalOrOptions.LogicalOrOptionsEnd(new_builder)
# OneHotOptions: not supported
import tflite.OneHotOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().OneHotOptions:
one_hot_option = tflite.OneHotOptions.OneHotOptions()
one_hot_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.OneHotOptions.OneHotOptionsStart(new_builder)
tflite.OneHotOptions.OneHotOptionsAddAxis(new_builder, one_hot_option.Axis())
return tflite.OneHotOptions.OneHotOptionsEnd(new_builder)
# LogicalNotOptions
import tflite.LogicalNotOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().LogicalNotOptions:
equal_option = tflite.LogicalNotOptions.LogicalNotOptions()
equal_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.LogicalNotOptions.LogicalNotOptionsStart(new_builder)
return tflite.LogicalNotOptions.LogicalNotOptionsEnd(new_builder)
# UnpackOptions:
import tflite.UnpackOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().UnpackOptions:
unpack_option = tflite.UnpackOptions.UnpackOptions()
unpack_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.UnpackOptions.UnpackOptionsStart(new_builder)
tflite.UnpackOptions.UnpackOptionsAddNum(new_builder, unpack_option.Num())
tflite.UnpackOptions.UnpackOptionsAddAxis(new_builder, unpack_option.Axis())
return tflite.UnpackOptions.UnpackOptionsEnd(new_builder)
# FloorDivOptions: not supported
# SquareOptions: not supported
# ZerosLikeOptions: not supported
# FillOptions: not supported
# LogicalAndOptions
import tflite.LogicalAndOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().LogicalAndOptions:
logical_and_option = tflite.LogicalAndOptions.LogicalAndOptions()
logical_and_option.Init(selected_builtin_option.Bytes,
selected_builtin_option.Pos)
tflite.LogicalAndOptions.LogicalAndOptionsStart(new_builder)
return tflite.LogicalAndOptions.LogicalAndOptionsEnd(new_builder)
# LogicalNotOptions: not supported
# UnpackOptions: not supported
# FloorDivOptions: not supported
# SquareOptions: not supported
# ZerosLikeOptions: not supported
# FillOptions: not supported
# BidirectionalSequenceLSTMOptions: not supported
# BidirectionalSequenceRNNOptions: not supported
# FloorModOptions: not supported
# RangeOptions: not supported
# ResizeNearestNeighborOptions: not supported
# LeakyReluOptions
import tflite.LeakyReluOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().LeakyReluOptions:
leaky_relu_option = tflite.LeakyReluOptions.LeakyReluOptions()
leaky_relu_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.LeakyReluOptions.LeakyReluOptionsStart(new_builder)
tflite.LeakyReluOptions.LeakyReluOptionsAddAlpha(new_builder,
leaky_relu_option.Alpha())
return tflite.LeakyReluOptions.LeakyReluOptionsEnd(new_builder)
# SquaredDifferenceOptions
import tflite.SquaredDifferenceOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions(
).SquaredDifferenceOptions:
squared_difference_option = tflite.SquaredDifferenceOptions.SquaredDifferenceOptions(
)
squared_difference_option.Init(selected_builtin_option.Bytes,
selected_builtin_option.Pos)
tflite.SquaredDifferenceOptions.SquaredDifferenceOptionsStart(new_builder)
return tflite.SquaredDifferenceOptions.SquaredDifferenceOptionsEnd(new_builder)
# UnidirectionalSequenceLSTMOptions
import tflite.UnidirectionalSequenceLSTMOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions(
).UnidirectionalSequenceLSTMOptions:
unidirectional_sequence_lstm_option = tflite.UnidirectionalSequenceLSTMOptions.UnidirectionalSequenceLSTMOptions(
)
unidirectional_sequence_lstm_option.Init(selected_builtin_option.Bytes,
selected_builtin_option.Pos)
tflite.UnidirectionalSequenceLSTMOptions.UnidirectionalSequenceLSTMOptionsStart(
new_builder)
tflite.UnidirectionalSequenceLSTMOptions.UnidirectionalSequenceLSTMOptionsAddFusedActivationFunction(
new_builder, unidirectional_sequence_lstm_option.FusedActivationFunction())
tflite.UnidirectionalSequenceLSTMOptions.UnidirectionalSequenceLSTMOptionsAddCellClip(
new_builder, unidirectional_sequence_lstm_option.CellClip())
tflite.UnidirectionalSequenceLSTMOptions.UnidirectionalSequenceLSTMOptionsAddProjClip(
new_builder, unidirectional_sequence_lstm_option.ProjClip())
tflite.UnidirectionalSequenceLSTMOptions.UnidirectionalSequenceLSTMOptionsAddTimeMajor(
new_builder, unidirectional_sequence_lstm_option.TimeMajor())
tflite.UnidirectionalSequenceLSTMOptions.UnidirectionalSequenceLSTMOptionsAddAsymmetricQuantizeInputs(
new_builder, unidirectional_sequence_lstm_option.AsymmetricQuantizeInputs())
return tflite.UnidirectionalSequenceLSTMOptions.UnidirectionalSequenceLSTMOptionsEnd(
new_builder)
# MirrorPadOptions: not supported
# AbsOptions: not supported
# SplitVOptions: not supported
# IfOptions
import tflite.IfOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().IfOptions:
if_option = tflite.IfOptions.IfOptions()
if_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.IfOptions.IfOptionsStart(new_builder)
tflite.IfOptions.IfOptionsAddElseSubgraphIndex(
new_builder, used_subgraphs_dic[if_option.ElseSubgraphIndex()])
tflite.IfOptions.IfOptionsAddThenSubgraphIndex(
new_builder, used_subgraphs_dic[if_option.ThenSubgraphIndex()])
return tflite.IfOptions.IfOptionsEnd(new_builder)
# WhileOptions
import tflite.WhileOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().WhileOptions:
while_option = tflite.WhileOptions.WhileOptions()
while_option.Init(selected_builtin_option.Bytes, selected_builtin_option.Pos)
tflite.WhileOptions.WhileOptionsStart(new_builder)
tflite.WhileOptions.WhileOptionsAddBodySubgraphIndex(
new_builder, used_subgraphs_dic[while_option.BodySubgraphIndex()])
tflite.WhileOptions.WhileOptionsAddCondSubgraphIndex(
new_builder, used_subgraphs_dic[while_option.CondSubgraphIndex()])
return tflite.WhileOptions.WhileOptionsEnd(new_builder)
# BatchMatMulOptions
import tflite.BatchMatMulOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().BatchMatMulOptions:
batchmatmul_option = tflite.BatchMatMulOptions.BatchMatMulOptions()
batchmatmul_option.Init(selected_builtin_option.Bytes,
selected_builtin_option.Pos)
tflite.BatchMatMulOptions.BatchMatMulOptionsStart(new_builder)
tflite.BatchMatMulOptions.BatchMatMulOptionsAddAdjX(new_builder, batchmatmul_option.AdjX())