diff --git a/app/src/main/assets/README.md b/app/src/main/assets/README.md index a2f0c2e..bc014a1 100644 --- a/app/src/main/assets/README.md +++ b/app/src/main/assets/README.md @@ -1,4 +1,5 @@ -Place a FaceNet-compatible TensorFlow Lite model here as facenet.tflite. +Place a face recognition TensorFlow Lite model here as mobilefacenet.tflite +(MobileFaceNet@WebFace600K, 112x112 input, 512-d output). -Expected input: [1, 160, 160, 3]. -Expected output: a float embedding vector. +Expected input: [1, 112, 112, 3] (float32, RGB, values normalized to [-1, 1]). +Expected output: a 512-d L2-normalized float embedding vector. diff --git a/app/src/main/assets/debug.jpg b/app/src/main/assets/debug.jpg deleted file mode 100644 index 70682e8..0000000 Binary files a/app/src/main/assets/debug.jpg and /dev/null differ diff --git a/app/src/main/assets/mask_detector.tflite b/app/src/main/assets/mask_detector.tflite deleted file mode 100644 index b5687cc..0000000 Binary files a/app/src/main/assets/mask_detector.tflite and /dev/null differ diff --git a/app/src/main/assets/mobilefacenet.tflite b/app/src/main/assets/mobilefacenet.tflite new file mode 100644 index 0000000..34302c9 Binary files /dev/null and b/app/src/main/assets/mobilefacenet.tflite differ diff --git a/app/src/main/assets/schema.fbs b/app/src/main/assets/schema.fbs deleted file mode 100644 index ab01916..0000000 --- a/app/src/main/assets/schema.fbs +++ /dev/null @@ -1,1715 +0,0 @@ -// Copyright 2017 The TensorFlow Authors. 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. - -// Revision History -// Version 0: Initial version. -// Version 1: Add subgraphs to schema. -// Version 2: Rename operators to conform to NN API. -// Version 3: Move buffer data from Model.Subgraph.Tensors to Model.Buffers. -// Version 3a: Add new builtin op code field. Has backward compatibility with -// version 3. -// Version 3b: Rename fields in SignatureDef. Has backward compatibility with -// version 3 and 3a. -// Version 3c: Move constant tensor buffers & custom op buffers outside from -// Flatbuffers. Has backward compatibility with version 3, 3a and -// 3b. -// Version 3d: Add ExternalBuffer tables and tensor.external_buffer field for -// referencing immutable data stored in external files. - -namespace tflite; - -// This corresponds to the version. -file_identifier "TFL3"; -// File extension of any written files. -file_extension "tflite"; - -// IMPORTANT: All new members of tables, enums and unions must be added at the -// end to ensure backwards compatibility. - -// The type of data stored in a tensor. -enum TensorType : byte { - FLOAT32 = 0, - FLOAT16 = 1, - INT32 = 2, - UINT8 = 3, - INT64 = 4, - STRING = 5, - BOOL = 6, - INT16 = 7, - COMPLEX64 = 8, - INT8 = 9, - FLOAT64 = 10, - COMPLEX128 = 11, - UINT64 = 12, - // Experimental: Resource and variant types are experimental, that are subject - // to change. Do not implement custom kernels using resource & variant types - // now. - RESOURCE = 13, - VARIANT = 14, - UINT32 = 15, - UINT16 = 16, - INT4 = 17, - BFLOAT16 = 18, - INT2 = 19, - UINT4 = 20, -} - -// Custom quantization parameters for experimenting with new quantization -// techniques. -table CustomQuantization { - custom:[ubyte] (force_align: 16); -} - -// Represents a specific quantization technique's parameters. -union QuantizationDetails { - CustomQuantization, - BlockwiseQuantization, -} - -// Parameters for blockwise quantization. -table BlockwiseQuantization { - // index to the scale tensor, the tensor can be found in tensors array in - // subgraph. - scales: int; - // index to the zero point tensor. If zero_points is -1, the zero point is - // assumed to be 0, following the convention of optional tensors in tflite. - zero_points: int; - // The block size of the tensor. - block_size: int; -} - -// Parameters for converting a quantized tensor back to float. -table QuantizationParameters { - // These four parameters are the asymmetric linear quantization parameters. - // Given a quantized value q, the corresponding float value f should be: - // f = scale * (q - zero_point) - // For other quantization types, the QuantizationDetails below is used. - min:[float]; // For importing back into tensorflow. - max:[float]; // For importing back into tensorflow. - scale:[float]; // For dequantizing the tensor's values. - zero_point:[long]; - - // If this is not none, the other quantization parameters (i.e. min, max, - // scale, zero_point fields above) are ignored and the value of the - // QuantizationDetails union should be used. - details:QuantizationDetails; - - // Specifies the dimension of the Tensor's shape that the scales and - // zero_points correspond to. For example, a tensor t, with dims=[4, 3, 2, 1] - // with quantization params: - // scale=[1.0, 2.0, 3.0], zero_point=[1, 2, 3], quantization_dimension=1 - // will be quantized across the second dimension of t. - // t[:, 0, :, :] will have scale[0]=1.0, zero_point[0]=1 - // t[:, 1, :, :] will have scale[1]=2.0, zero_point[0]=2 - // t[:, 2, :, :] will have scale[2]=3.0, zero_point[0]=3 - quantized_dimension:int; -} - -// Sparse tensors. -// We use a modification of the TACO format. -// Reference: http://tensor-compiler.org/kjolstad-oopsla17-tensor-compiler.pdf -// -// To encode a conceptual n-dimensional dense tensor with dims (d0, ..., dn-1), -// potentially with a k-dimensional block (0 <= k <= n) with dims -// (dn, ..., dn+k-1), the format needs to specify: -// 1. In what order to traverse these dimensions. For example, to store a 2-D -// matrix in row major order, the traversal order would be (d0, d1), -// whereas to store it in column major order, the traversal order would be -// (d1, d0). If the 2-D matrix has a 2-D inner block, the traversal order -// could be (d0, d1, d2, d3). -// 2. How each block dimension in (dn, ..., dn+k-1) maps to the original -// tensor dimension in (d0, ..., dn-1). -// 3. In the traversal order defined above, the format (dense vs. sparse) and -// index metadata for each dimension. For a dense dimension, this is just -// the size of that dimension. For a sparse dimension, it's the same as -// the compressed index defined in the Compressed Sparse Row (CSR) format. -// (http://scipy-lectures.org/advanced/scipy_sparse/csr_matrix.html) - -// The storage type for a dimension. Currently we support: -// 1. DENSE: each coordinate in this dimension is stored implicitly. -// 2. SPARSE_CSR: only the coordinates with non-zero elements are stored. The -// compression technique is the same what CSR uses. -// More types like a sparse dimension with a different compression technique -// could be added to the list in the future. -enum DimensionType : byte { - DENSE = 0, - SPARSE_CSR = 1, -} - -table Int32Vector { - values:[int]; -} - -table Uint16Vector { - values:[ushort] (force_align: 4); -} - -table Uint8Vector { - values:[ubyte] (force_align: 4); -} - -// Variable-typed buffer to store the index metadata for a sparse dimension. -// The widest type is Int32 instead of UInt32 because tensor's shape is a int32 -// vector. We don't want the per-dimensional index to overflow that range. -union SparseIndexVector { - Int32Vector, - Uint16Vector, - Uint8Vector -} - -table DimensionMetadata { - // Whether a dimension is dense or sparse. - format:DimensionType; - // Index metadata used for a dimension. - // - If format is DimensionType.DENSE then we use the dense_size field to - // store the size of that dimension. Each index in that dimension is - // stored implicitly. - // - If format is DimensionType.SPARSE_CSR then we use array_segments and - // array_indices to encode that dimension. array_segments represents how - // to segment the indices array, each segment corresponds to one element - // in the previous dimension. array_indices represents the index of the - // non-zero elements within this dimension (as those in the CSR matrix - // format, where the first array is row pointers and the second array is - // column indices). - dense_size:int; - array_segments:SparseIndexVector; - array_indices:SparseIndexVector; -} - -// Parameters to encode a sparse TfLite tensor. -table SparsityParameters { - // The traversal order of the dimensions defined in the `shape` field of the - // conceptual dense tensor. For a n-dimensional tensors with dims (d0, d1, - // ..., dn-1), - // - if not block sparse, the traversal_order is just a permutation of (d0, - // ..., dn-1). For example, a 2-D matrix stored in row-major order would - // have traversal_order = (d0, d1). - // - if block sparse with a k-dimensional block (0 <= k <= n), the - // traversal_order has n + k elements. The first n elements are still a - // permutation of (d0, ..., dn-1). The lask k elements are a permutation - // of (dn, ..., dn+k-1), defining how to traverse a block internally. For - // example, a 2-D matrix with 2-D blocks, both stored in row-major order - // would have traversal_order = (d0, d1, d2, d3). - traversal_order:[int]; - // For an n-dimensional tensor with a k-dimensional block (0 <= k <= n), - // stores how a block dimension in (dn, ..., dn+k-1) maps to the original - // tensor dimension in (d0, ..., dn). - // It's stored in the order of (dn, ..., dn+k-1). - // If not block-sparse, this field is NULL. - block_map:[int]; - // In the traversal order defined above, the metadata needed for - // each dimension to locate the non-zero values in the original dense tensor. - // The size of the dim_metadata array = the size of the traversal_order array - // = n + k. - dim_metadata:[DimensionMetadata]; -} - -// The nested tensor type for VARIANT type. -table VariantSubType { - // The tensor shape. - shape:[int]; - type:TensorType; - // If false, the rank or the number of tensor dimensions is unknown. - // If false, "shape" must be []. - has_rank: bool = false; -} - -table Tensor { - // The tensor shape. The meaning of each entry is operator-specific but - // builtin ops use: [batch size, height, width, number of channels] (That's - // Tensorflow's NHWC). - shape:[int]; - type:TensorType; - // An index that refers to the buffers table at the root of the model. Or, - // if there is no data buffer associated (i.e. intermediate results), then - // this is 0 (which refers to an always existent empty buffer). - // - // The data_buffer itself is an opaque container, with the assumption that the - // target device is little-endian. In addition, all builtin operators assume - // the memory is ordered such that if `shape` is [4, 3, 2], then index - // [i, j, k] maps to data_buffer[i*3*2 + j*2 + k]. - buffer:uint; - name:string; // For debugging and importing back into tensorflow. - quantization:QuantizationParameters; // Optional. - - is_variable:bool = false; - - // Parameters to encode a sparse tensor. See the example in - // tensorflow/lite/testdata/sparse_tensor.json. - sparsity:SparsityParameters; // Optional. - - // Encodes `shape` with unknown dimensions. Unknown dimensions are - // represented with -1. - shape_signature:[int]; // Optional. - - // This field is added to distinguish between scalars and tensors of unknown - // ranks (both of which shape is []). - // For scalars (rank = 0), shape = [] and has_rank = true. - // For tensors with known rank (rank > 0) and shape, shape = [...] and - // has_rank = true. - // For tensors with unknown rank and shape, shape = [] and has_rank = false. - has_rank: bool = false; - - // The nested Tensor types for VARIANT type. This is always empty for - // non-VARIANT types. This is optional because the nested type can be omitted. - // Currently only 1 subtype is supported. The field is defined as an array for - // flexibility of supporting multiple subtypes in the future. - variant_tensors:[VariantSubType]; - - // Optional reference to an ExternalBuffer entry that stores constant tensor - // data outside of the FlatBuffer. A value of 0 indicates that the tensor uses - // the traditional embedded buffer field instead. - external_buffer:uint; -} - -// A list of builtin operators. Builtin operators are slightly faster than custom -// ones, but not by much. Moreover, while custom operators accept an opaque -// object containing configuration parameters, builtins have a predetermined -// set of acceptable options. -// LINT.IfChange -enum BuiltinOperator : int32 { - ADD = 0, - AVERAGE_POOL_2D = 1, - CONCATENATION = 2, - CONV_2D = 3, - DEPTHWISE_CONV_2D = 4, - DEPTH_TO_SPACE = 5, - DEQUANTIZE = 6, - EMBEDDING_LOOKUP = 7, - FLOOR = 8, - FULLY_CONNECTED = 9, - HASHTABLE_LOOKUP = 10, - L2_NORMALIZATION = 11, - L2_POOL_2D = 12, - LOCAL_RESPONSE_NORMALIZATION = 13, - LOGISTIC = 14, - LSH_PROJECTION = 15, - LSTM = 16, - MAX_POOL_2D = 17, - MUL = 18, - RELU = 19, - // NOTE(aselle): RELU_N1_TO_1 used to be called RELU1, but it was renamed - // since different model developers use RELU1 in different ways. Never - // create another op called RELU1. - RELU_N1_TO_1 = 20, - RELU6 = 21, - RESHAPE = 22, - RESIZE_BILINEAR = 23, - RNN = 24, - SOFTMAX = 25, - SPACE_TO_DEPTH = 26, - SVDF = 27, - TANH = 28, - CONCAT_EMBEDDINGS = 29, - SKIP_GRAM = 30, - CALL = 31, - CUSTOM = 32, - EMBEDDING_LOOKUP_SPARSE = 33, - PAD = 34, - UNIDIRECTIONAL_SEQUENCE_RNN = 35, - GATHER = 36, - BATCH_TO_SPACE_ND = 37, - SPACE_TO_BATCH_ND = 38, - TRANSPOSE = 39, - MEAN = 40, - SUB = 41, - DIV = 42, - SQUEEZE = 43, - UNIDIRECTIONAL_SEQUENCE_LSTM = 44, - STRIDED_SLICE = 45, - BIDIRECTIONAL_SEQUENCE_RNN = 46, - EXP = 47, - TOPK_V2 = 48, - SPLIT = 49, - LOG_SOFTMAX = 50, - // DELEGATE is a special op type for the operations which are delegated to - // other backends. - // WARNING: Experimental interface, subject to change - DELEGATE = 51, - BIDIRECTIONAL_SEQUENCE_LSTM = 52, - CAST = 53, - PRELU = 54, - MAXIMUM = 55, - ARG_MAX = 56, - MINIMUM = 57, - LESS = 58, - NEG = 59, - PADV2 = 60, - GREATER = 61, - GREATER_EQUAL = 62, - LESS_EQUAL = 63, - SELECT = 64, - SLICE = 65, - SIN = 66, - TRANSPOSE_CONV = 67, - SPARSE_TO_DENSE = 68, - TILE = 69, - EXPAND_DIMS = 70, - EQUAL = 71, - NOT_EQUAL = 72, - LOG = 73, - SUM = 74, - SQRT = 75, - RSQRT = 76, - SHAPE = 77, - POW = 78, - ARG_MIN = 79, - FAKE_QUANT = 80, - REDUCE_PROD = 81, - REDUCE_MAX = 82, - PACK = 83, - LOGICAL_OR = 84, - ONE_HOT = 85, - LOGICAL_AND = 86, - LOGICAL_NOT = 87, - UNPACK = 88, - REDUCE_MIN = 89, - FLOOR_DIV = 90, - REDUCE_ANY = 91, - SQUARE = 92, - ZEROS_LIKE = 93, - FILL = 94, - FLOOR_MOD = 95, - RANGE = 96, - RESIZE_NEAREST_NEIGHBOR = 97, - LEAKY_RELU = 98, - SQUARED_DIFFERENCE = 99, - MIRROR_PAD = 100, - ABS = 101, - SPLIT_V = 102, - UNIQUE = 103, - CEIL = 104, - REVERSE_V2 = 105, - ADD_N = 106, - GATHER_ND = 107, - COS = 108, - WHERE = 109, - RANK = 110, - ELU = 111, - REVERSE_SEQUENCE = 112, - MATRIX_DIAG = 113, - QUANTIZE = 114, - MATRIX_SET_DIAG = 115, - ROUND = 116, - HARD_SWISH = 117, - IF = 118, - WHILE = 119, - NON_MAX_SUPPRESSION_V4 = 120, - NON_MAX_SUPPRESSION_V5 = 121, - SCATTER_ND = 122, - SELECT_V2 = 123, - DENSIFY = 124, - SEGMENT_SUM = 125, - BATCH_MATMUL = 126, - PLACEHOLDER_FOR_GREATER_OP_CODES = 127, - CUMSUM = 128, - CALL_ONCE = 129, - BROADCAST_TO = 130, - RFFT2D = 131, - CONV_3D = 132, - IMAG=133, - REAL=134, - COMPLEX_ABS=135, - HASHTABLE = 136, - HASHTABLE_FIND = 137, - HASHTABLE_IMPORT = 138, - HASHTABLE_SIZE = 139, - REDUCE_ALL = 140, - CONV_3D_TRANSPOSE = 141, - VAR_HANDLE = 142, - READ_VARIABLE = 143, - ASSIGN_VARIABLE = 144, - BROADCAST_ARGS = 145, - RANDOM_STANDARD_NORMAL = 146, - BUCKETIZE = 147, - RANDOM_UNIFORM = 148, - MULTINOMIAL = 149, - GELU = 150, - DYNAMIC_UPDATE_SLICE = 151, - RELU_0_TO_1 = 152, - UNSORTED_SEGMENT_PROD = 153, - UNSORTED_SEGMENT_MAX = 154, - UNSORTED_SEGMENT_SUM = 155, - ATAN2 = 156, - UNSORTED_SEGMENT_MIN = 157, - SIGN = 158, - BITCAST = 159, - BITWISE_XOR = 160, - RIGHT_SHIFT = 161, - // All Operators start with STABLEHLO_ prefixes are subject to change - // Many of the ops below can not be executed by TFlite runtime - STABLEHLO_LOGISTIC = 162, // WARNING: Do not have runtime support - STABLEHLO_ADD = 163, - STABLEHLO_DIVIDE = 164, // WARNING: No runtime support yet - STABLEHLO_MULTIPLY = 165, - STABLEHLO_MAXIMUM = 166, - STABLEHLO_RESHAPE = 167, // WARNING: No runtime support yet - STABLEHLO_CLAMP = 168, // WARNING: No runtime support - STABLEHLO_CONCATENATE = 169, // WARNING: No runtime support - STABLEHLO_BROADCAST_IN_DIM = 170, // WARNING: No runtime support - STABLEHLO_CONVOLUTION = 171, // WARNING: No runtime support - STABLEHLO_SLICE = 172, // WARNING: No runtime support - STABLEHLO_CUSTOM_CALL = 173, // WARNING: No runtime support - STABLEHLO_REDUCE = 174, // WARNING: No runtime support - STABLEHLO_ABS = 175, // WARNING: No runtime support - STABLEHLO_AND = 176, // WARNING: No runtime support - STABLEHLO_COSINE = 177, // WARNING: No runtime support - STABLEHLO_EXPONENTIAL = 178, // WARNING: No runtime support - STABLEHLO_FLOOR = 179, // WARNING: No runtime support - STABLEHLO_LOG = 180, // WARNING: No runtime support - STABLEHLO_MINIMUM = 181, - STABLEHLO_NEGATE = 182, // WARNING: No runtime support - STABLEHLO_OR = 183, // WARNING: No runtime support - STABLEHLO_POWER = 184, // WARNING: No runtime support - STABLEHLO_REMAINDER = 185, // WARNING: No runtime support - STABLEHLO_RSQRT = 186, // WARNING: No runtime support - STABLEHLO_SELECT = 187, // WARNING: No runtime support - STABLEHLO_SUBTRACT = 188, // WARNING: No runtime support - STABLEHLO_TANH = 189, // WARNING: No runtime support - STABLEHLO_SCATTER = 190, - STABLEHLO_COMPARE = 191, // WARNING: No runtime support - STABLEHLO_CONVERT = 192, // WARNING: No runtime support - STABLEHLO_DYNAMIC_SLICE = 193, // WARNING: No runtime support - STABLEHLO_DYNAMIC_UPDATE_SLICE = 194, // WARNING: No runtime support - STABLEHLO_PAD = 195, - STABLEHLO_IOTA = 196, // WARNING: No runtime support - STABLEHLO_DOT_GENERAL = 197, // WARNING: No runtime support - STABLEHLO_REDUCE_WINDOW = 198, - STABLEHLO_SORT = 199, // WARNING: No runtime support - STABLEHLO_WHILE = 200, // WARNING: No runtime support - STABLEHLO_GATHER = 201, - STABLEHLO_TRANSPOSE = 202, // WARNING: No runtime support - DILATE = 203, - STABLEHLO_RNG_BIT_GENERATOR = 204, - REDUCE_WINDOW = 205 (deprecated), - STABLEHLO_COMPOSITE = 206, // WARNING: No runtime support - STABLEHLO_SHIFT_LEFT = 207, - STABLEHLO_CBRT = 208, // WARNING: No runtime support - STABLEHLO_CASE = 209, -} -// LINT.ThenChange(internal-1) - -// Options for the builtin operators. -union BuiltinOptions { - Conv2DOptions, - DepthwiseConv2DOptions, - ConcatEmbeddingsOptions, - LSHProjectionOptions, - Pool2DOptions, - SVDFOptions, - RNNOptions, - FullyConnectedOptions, - SoftmaxOptions, - ConcatenationOptions, - AddOptions, - L2NormOptions, - LocalResponseNormalizationOptions, - LSTMOptions, - ResizeBilinearOptions, - CallOptions, - ReshapeOptions, - SkipGramOptions, - SpaceToDepthOptions, - EmbeddingLookupSparseOptions, - MulOptions, - PadOptions, - GatherOptions, - BatchToSpaceNDOptions, - SpaceToBatchNDOptions, - TransposeOptions, - ReducerOptions, - SubOptions, - DivOptions, - SqueezeOptions, - SequenceRNNOptions, - StridedSliceOptions, - ExpOptions, - TopKV2Options, - SplitOptions, - LogSoftmaxOptions, - CastOptions, - DequantizeOptions, - MaximumMinimumOptions, - ArgMaxOptions, - LessOptions, - NegOptions, - PadV2Options, - GreaterOptions, - GreaterEqualOptions, - LessEqualOptions, - SelectOptions, - SliceOptions, - TransposeConvOptions, - SparseToDenseOptions, - TileOptions, - ExpandDimsOptions, - EqualOptions, - NotEqualOptions, - ShapeOptions, - PowOptions, - ArgMinOptions, - FakeQuantOptions, - PackOptions, - LogicalOrOptions, - OneHotOptions, - LogicalAndOptions, - LogicalNotOptions, - UnpackOptions, - FloorDivOptions, - SquareOptions, - ZerosLikeOptions, - FillOptions, - BidirectionalSequenceLSTMOptions, - BidirectionalSequenceRNNOptions, - UnidirectionalSequenceLSTMOptions, - FloorModOptions, - RangeOptions, - ResizeNearestNeighborOptions, - LeakyReluOptions, - SquaredDifferenceOptions, - MirrorPadOptions, - AbsOptions, - SplitVOptions, - UniqueOptions, - ReverseV2Options, - AddNOptions, - GatherNdOptions, - CosOptions, - WhereOptions, - RankOptions, - ReverseSequenceOptions, - MatrixDiagOptions, - QuantizeOptions, - MatrixSetDiagOptions, - HardSwishOptions, - IfOptions, - WhileOptions, - DepthToSpaceOptions, - NonMaxSuppressionV4Options, - NonMaxSuppressionV5Options, - ScatterNdOptions, - SelectV2Options, - DensifyOptions, - SegmentSumOptions, - BatchMatMulOptions, - CumsumOptions, - CallOnceOptions, - BroadcastToOptions, - Rfft2dOptions, - Conv3DOptions, - HashtableOptions, - HashtableFindOptions, - HashtableImportOptions, - HashtableSizeOptions, - VarHandleOptions, - ReadVariableOptions, - AssignVariableOptions, - RandomOptions, - BucketizeOptions, - GeluOptions, - DynamicUpdateSliceOptions, - UnsortedSegmentProdOptions, - UnsortedSegmentMaxOptions, - UnsortedSegmentMinOptions, - UnsortedSegmentSumOptions, - ATan2Options, - SignOptions, - BitcastOptions, - BitwiseXorOptions, - RightShiftOptions, - // DO NOT add new options this union, will cause failure in Java api - // generation otherwise - // Add new builtin options into builtin options 2 instead -} - -union BuiltinOptions2{ - StablehloConcatenateOptions, - StablehloBroadcastInDimOptions, - StablehloSliceOptions, - StablehloConvolutionOptions, - StablehloCustomCallOptions, - StablehloReduceOptions, - StablehloScatterOptions, - StablehloCompareOptions, - StablehloDynamicSliceOptions, - StablehloPadOptions, - StablehloIotaOptions, - StablehloDotGeneralOptions, - StablehloReduceWindowOptions, - StablehloSortOptions, - StablehloWhileOptions, - StablehloGatherOptions, - StablehloTransposeOptions, - DilateOptions, - StablehloRngBitGeneratorOptions, - ReduceWindowOptions (deprecated), - StableHLOCompositeOptions, - StablehloShiftLeftOptions, - StablehloCaseOptions, -} - -table StablehloGatherOptions{ - offset_dims : [long]; - collapsed_slice_dims : [long]; - start_index_map : [long]; - index_vector_dim : long; - slice_sizes : [long]; - indices_are_sorted : bool; -} - -table StablehloTransposeOptions{ - permutation : [long]; -} - -enum StablehloPrecisionConfig : uint { - DEFAULT, - HIGH, - HIGHEST, -} - -table StablehloDotGeneralOptions{ - lhs_batching_dimensions : [long]; - rhs_batching_dimensions : [long]; - lhs_contracting_dimensions : [long]; - rhs_contracting_dimensions : [long]; - precision_config : [StablehloPrecisionConfig]; -} - -table StablehloReduceWindowOptions{ - window_dimensions : [long]; - window_strides : [long]; - base_dilations : [long]; - window_dilations : [long]; - padding : [long]; - body_subgraph_index : int; -} - -table StablehloWhileOptions{ - cond_subgraph_index : int; - body_subgraph_index : int; -} - -table StablehloSortOptions{ - dimension : long; - is_stable : bool; - comparator_subgraph_index : int; -} - -table StablehloConcatenateOptions { - dimension : long; -} - -table StablehloBroadcastInDimOptions{ - broadcast_dimensions : [long]; -} - -enum StablehloComparisonDirection : uint { - STABLEHLO_COMPARISON_DIRECTION_EQ, - STABLEHLO_COMPARISON_DIRECTION_NE, - STABLEHLO_COMPARISON_DIRECTION_GE, - STABLEHLO_COMPARISON_DIRECTION_GT, - STABLEHLO_COMPARISON_DIRECTION_LE, - STABLEHLO_COMPARISON_DIRECTION_LT, - -} - -enum StablehloComparisonType : uint { - STABLEHLO_COMPARISON_TYPE_NOTYPE, - STABLEHLO_COMPARISON_TYPE_FLOAT, - STABLEHLO_COMPARISON_TYPE_FLOAT_TOTAL_ORDER, - STABLEHLO_COMPARISON_TYPE_SIGNED, - STABLEHLO_COMPARISON_TYPE_UNSIGNED, -} - -table StablehloCompareOptions{ - comparison_direction : StablehloComparisonDirection; - compare_type : StablehloComparisonType; -} - -table StablehloDynamicSliceOptions{ - slice_sizes : [long]; -} - -table StablehloPadOptions{ - edge_padding_low : [long]; - edge_padding_high : [long]; - interior_padding : [long]; -} - -table StablehloIotaOptions{ - iota_dimension : long; -} - -table StablehloCustomCallOptions { - call_target_name : string; - has_side_effect : bool; - backend_config: string; - api_version : int; // will be decprecated - called_computations: [int]; // should point to subgraphs of the computations - custom_attributes : [ubyte]; -} - -table StablehloReduceOptions { - dimensions : [long]; - body_subgraph_index : int; -} - -table StablehloSliceOptions{ - start_indices : [long]; - limit_indices : [long]; - strides : [long]; -} - -table StablehloConvolutionOptions{ - window_strides : [long]; - padding : [long]; - lhs_dilation : [long]; - rhs_dilation : [long]; - window_reversal : [bool]; - input_batch_dimension : long; - input_feature_dimension : long; - input_spatial_dimensions : [long]; - kernel_input_feature_dimension : long; - kernel_output_feature_dimension : long; - kernel_spatial_dimensions : [long]; - output_batch_dimension : long; - output_feature_dimension : long; - output_spatial_dimensions : [long]; - feature_group_count : long; - batch_group_count : long; - precision_config : [StablehloPrecisionConfig]; -} - -table StablehloScatterOptions { - indices_are_sorted: bool; - update_window_dims: [long]; - inserted_window_dims: [long]; - scatter_dims_to_operand_dims: [long]; - index_vector_dim: long; - unique_indices: bool; - update_computation_subgraph_index: int; -} - -table StablehloCaseOptions{ - branch_subgraph_indices : [int]; -} - -enum RngAlgorithm : byte { - // An algorithm auto-selected by the system according to device type. - DEFAULT = 0, - // The Philox algorithm, as described in paper - // ['Parallel Random Numbers: As Easy as 1, 2, 3'] - // (https://www.thesalmons.org/john/random123/papers/random123sc11.pdf) - PHILOX = 1, - // The ThreeFry algorithm, as described in paper - // ['Parallel Random Numbers: As Easy as 1, 2, 3'] - // (https://www.thesalmons.org/john/random123/papers/random123sc11.pdf) - THREEFRY = 2, -} - -table StablehloRngBitGeneratorOptions { - algorithm:RngAlgorithm; -} - -// LINT.IfChange -enum Padding : byte { SAME, VALID } -// LINT.ThenChange(//tflite/converter/ir/tfl_op_enums.td) - -// LINT.IfChange -enum ActivationFunctionType : byte { - NONE = 0, - RELU = 1, - RELU_N1_TO_1 = 2, - RELU6 = 3, - TANH = 4, - SIGN_BIT = 5, -} -// LINT.ThenChange(//tflite/converter/ir/tfl_op_enums.td) - -table Conv2DOptions { - padding:Padding; - stride_w:int; - stride_h:int; - fused_activation_function:ActivationFunctionType; - dilation_w_factor:int = 1; - dilation_h_factor:int = 1; - // Parameters for Conv2D version 8 or above. - // When set, quantized_bias_type defines the dtype for both bias and accumulator. - quantized_bias_type: TensorType; -} - -// Options for both Conv3D and Conv3DTranspose. -table Conv3DOptions { - padding:Padding; - stride_d:int; - stride_w:int; - stride_h:int; - fused_activation_function:ActivationFunctionType; - dilation_d_factor:int = 1; - dilation_w_factor:int = 1; - dilation_h_factor:int = 1; -} - -table Pool2DOptions { - padding:Padding; - stride_w:int; - stride_h:int; - filter_width:int; - filter_height:int; - fused_activation_function:ActivationFunctionType; -} - -table DepthwiseConv2DOptions { - // Parameters for DepthwiseConv version 1 or above. - padding:Padding; - stride_w:int; - stride_h:int; - // `depth_multiplier` is redundant. It's used by CPU kernels in - // TensorFlow 2.0 or below, but ignored in versions above. - // See comments in lite/c/builtin_op_data.h for more details. - depth_multiplier:int; - fused_activation_function:ActivationFunctionType; - // Parameters for DepthwiseConv version 2 or above. - dilation_w_factor:int = 1; - dilation_h_factor:int = 1; -} - -table ConcatEmbeddingsOptions { - num_channels:int; - num_columns_per_channel:[int]; - embedding_dim_per_channel:[int]; // This could be inferred from parameters. -} - -enum LSHProjectionType: byte { - UNKNOWN = 0, - SPARSE = 1, - DENSE = 2, -} - -table LSHProjectionOptions { - type: LSHProjectionType; -} - -table SVDFOptions { - rank:int; - fused_activation_function:ActivationFunctionType; - // For weights-only quantization, use asymmetric quantization for non - // constant inputs at evaluation time. - asymmetric_quantize_inputs:bool; -} - -// An implementation of TensorFlow RNNCell. -table RNNOptions { - fused_activation_function:ActivationFunctionType; - asymmetric_quantize_inputs:bool; -} - -// An implementation of TensorFlow dynamic_rnn with RNNCell. -table SequenceRNNOptions { - time_major:bool; - fused_activation_function:ActivationFunctionType; - asymmetric_quantize_inputs:bool; -} - -// An implementation of TensorFlow bidrectional_dynamic_rnn with RNNCell. -table BidirectionalSequenceRNNOptions { - time_major:bool; - fused_activation_function:ActivationFunctionType; - merge_outputs: bool; - asymmetric_quantize_inputs:bool; -} - -// LINT.IfChange -enum FullyConnectedOptionsWeightsFormat: byte { - DEFAULT = 0, - SHUFFLED4x16INT8 = 1, -} -// LINT.ThenChange(//tflite/converter/ir/tfl_op_enums.td) - -// An implementation of TensorFlow fully_connected (a.k.a Dense) layer. -table FullyConnectedOptions { - // Parameters for FullyConnected version 1 or above. - fused_activation_function:ActivationFunctionType; - - // Parameters for FullyConnected version 2 or above. - weights_format:FullyConnectedOptionsWeightsFormat = DEFAULT; - - // Parameters for FullyConnected version 5 or above. - // If set to true, then the number of dimension is preserved. Furthermore, - // all but the last dimension of the input and output shapes will be equal. - keep_num_dims: bool; - - // Parameters for FullyConnected version 7 or above. - // If set to true, then weights-only op will use asymmetric quantization for - // inputs. - asymmetric_quantize_inputs: bool; - - // Parameters for FullyConnected version 11 or above. - // When set, quantized_bias_type defines the dtype for both bias and accumulator. - quantized_bias_type: TensorType; -} - -table SoftmaxOptions { - beta: float; -} - -// An implementation of TensorFlow concat. -table ConcatenationOptions { - axis:int; - fused_activation_function:ActivationFunctionType; -} - -table AddOptions { - fused_activation_function:ActivationFunctionType; - // Parameters supported by version 3. - pot_scale_int16:bool = true; -} - -table MulOptions { - fused_activation_function:ActivationFunctionType; -} - -table L2NormOptions { - // This field is currently ignored in the L2 Norm Op. - fused_activation_function:ActivationFunctionType; -} - -table LocalResponseNormalizationOptions { - radius:int; - bias:float; - alpha:float; - beta:float; -} - -// LINT.IfChange -enum LSTMKernelType : byte { - // Full LSTM kernel which supports peephole and projection. - FULL = 0, - // Basic LSTM kernels. Equivalent to TensorFlow BasicLSTMCell. - BASIC = 1, -} -// LINT.ThenChange(//tflite/converter/ir/tfl_op_enums.td) - -// An implementation of TensorFlow LSTMCell and CoupledInputForgetGateLSTMCell -table LSTMOptions { - // Parameters for LSTM version 1 or above. - fused_activation_function:ActivationFunctionType; - cell_clip: float; // Optional, 0.0 means no clipping - proj_clip: float; // Optional, 0.0 means no clipping - - // Parameters for LSTM version 2 or above. - // Basic kernel is only supported in version 2 or above. - kernel_type: LSTMKernelType = FULL; - - // Parameters for LSTM version 4 or above. - asymmetric_quantize_inputs: bool; -} - -// An implementation of TensorFlow dynamic_rnn with LSTMCell. -table UnidirectionalSequenceLSTMOptions { - fused_activation_function:ActivationFunctionType; - cell_clip: float; // Optional, 0.0 means no clipping - proj_clip: float; // Optional, 0.0 means no clipping - - // If true then first dimension is sequence, otherwise batch. - time_major:bool; - - // Parameter for Unidirectional Sequence LSTM version 3. - asymmetric_quantize_inputs:bool; - - // Parameter for unidirectional sequence RNN version 4. - diagonal_recurrent_tensors:bool; -} - -table BidirectionalSequenceLSTMOptions { - // Parameters supported by version 1: - fused_activation_function:ActivationFunctionType; - cell_clip: float; // Optional, 0.0 means no clipping - proj_clip: float; // Optional, 0.0 means no clipping - - // If true, store the outputs of both directions into the first output. - merge_outputs: bool; - - // Parameters supported by version 2: - // If true then first dimension is sequence, otherwise batch. - // Version 1 implementations assumed time_major to be true, so this default - // value should never change. - time_major: bool = true; - - // Parameters for version 3 or above. - asymmetric_quantize_inputs:bool; -} - -table ResizeBilinearOptions { - new_height: int (deprecated); - new_width: int (deprecated); - align_corners: bool; - half_pixel_centers: bool; -} - -table ResizeNearestNeighborOptions { - align_corners: bool; - half_pixel_centers: bool; -} - -// A call operation options -table CallOptions { - // The subgraph index that needs to be called. - subgraph:uint; -} - -table PadOptions { -} - -table PadV2Options { -} - -table ReshapeOptions { - new_shape:[int]; -} - -table SpaceToBatchNDOptions { -} - -table BatchToSpaceNDOptions { -} - -table SkipGramOptions { - ngram_size: int; - max_skip_size: int; - include_all_ngrams: bool; -} - -table SpaceToDepthOptions { - block_size: int; -} - -table DepthToSpaceOptions { - block_size: int; -} - -table SubOptions { - fused_activation_function:ActivationFunctionType; - // Parameters supported by version 5 - pot_scale_int16:bool = true; -} - -table DivOptions { - fused_activation_function:ActivationFunctionType; -} - -table TopKV2Options { -} - -enum CombinerType : byte { - SUM = 0, - MEAN = 1, - SQRTN = 2, -} - -table EmbeddingLookupSparseOptions { - combiner:CombinerType; -} - -table GatherOptions { - axis: int; - // Parameters for Gather version 5 or above. - batch_dims: int = 0; -} - -table TransposeOptions { -} - -table ExpOptions { -} - -table CosOptions { -} - -table ReducerOptions { - keep_dims: bool; -} - -table SqueezeOptions { - squeeze_dims:[int]; -} - -table SplitOptions { - num_splits: int; -} - -table SplitVOptions { - num_splits: int; -} - -table StridedSliceOptions { - begin_mask: int; - end_mask: int; - ellipsis_mask: int; - new_axis_mask: int; - shrink_axis_mask: int; - // If true, then the end tensor is an offset of the begin tensor. - offset: bool; -} - -table LogSoftmaxOptions { -} - -table CastOptions { - in_data_type: TensorType; - out_data_type: TensorType; -} - -table DequantizeOptions { -} - -table MaximumMinimumOptions { -} - -table TileOptions { -} - -table ArgMaxOptions { - output_type : TensorType; -} - -table ArgMinOptions { - output_type : TensorType; -} - -table GreaterOptions { -} - -table GreaterEqualOptions { -} - -table LessOptions { -} - -table LessEqualOptions { -} - -table NegOptions { -} - -table SelectOptions { -} - -table SliceOptions { -} - -table TransposeConvOptions { - // Parameters supported by version 1, 2, 3: - padding:Padding; - stride_w:int; - stride_h:int; - - // Parameters supported by version 4: - fused_activation_function:ActivationFunctionType = NONE; - - // Parameters for TransposeConv version 5 or above. - // If set, use this for bias and accumulator. - // When set, quantized_bias_type defines the dtype for both bias and accumulator. - quantized_bias_type: TensorType; -} - -table ExpandDimsOptions { -} - -table SparseToDenseOptions { - validate_indices:bool; -} - -table EqualOptions { -} - -table NotEqualOptions { -} - -table ShapeOptions { - // Optional output type of the operation (int32 or int64). Defaults to int32. - out_type : TensorType; -} - -table RankOptions { -} - -table PowOptions { -} - -table FakeQuantOptions { - // Parameters supported by version 1: - min:float; - max:float; - num_bits:int; - - // Parameters supported by version 2: - narrow_range:bool; -} - -table PackOptions { - values_count:int; - axis:int; -} - -table LogicalOrOptions { -} - -table OneHotOptions { - axis:int; -} - -table AbsOptions { -} - - -table HardSwishOptions { -} - -table LogicalAndOptions { -} - -table LogicalNotOptions { -} - -table UnpackOptions { - num:int; - axis:int; -} - -table FloorDivOptions { -} - -table SquareOptions { -} - -table ZerosLikeOptions { -} - -table FillOptions { -} - -table FloorModOptions { -} - -table RangeOptions { -} - -table LeakyReluOptions { - alpha:float; -} - -table SquaredDifferenceOptions { -} - -// LINT.IfChange -enum MirrorPadMode : byte { - // Doesn't include borders. - REFLECT = 0, - // Includes borders. - SYMMETRIC = 1, -} -// LINT.ThenChange(//tflite/converter/ir/tfl_op_enums.td) - -table MirrorPadOptions { - mode:MirrorPadMode; -} - -table UniqueOptions { - idx_out_type:TensorType = INT32; -} - -table ReverseV2Options { -} - -table AddNOptions { -} - -table GatherNdOptions { -} - -table WhereOptions { -} - -table ReverseSequenceOptions { - seq_dim:int; - batch_dim:int = 0; -} - -table MatrixDiagOptions { -} - -table QuantizeOptions { -} - -table MatrixSetDiagOptions { -} - -table IfOptions { - then_subgraph_index:int; - else_subgraph_index:int; -} - -table CallOnceOptions { - init_subgraph_index:int; -} - -table WhileOptions { - cond_subgraph_index:int; - body_subgraph_index:int; -} - -table NonMaxSuppressionV4Options { -} - -table NonMaxSuppressionV5Options { -} - -table ScatterNdOptions { -} - -table SelectV2Options { -} - -table DensifyOptions { -} - -table SegmentSumOptions { -} - -table BatchMatMulOptions { - adj_x:bool; - adj_y:bool; - // Parameters for BatchMatMul version 4 or above. - // If set to true, then weights-only op will use asymmetric quantization for - // inputs. - asymmetric_quantize_inputs: bool; -} - -table CumsumOptions { - exclusive:bool; - reverse:bool; -} - -table BroadcastToOptions { -} - -table Rfft2dOptions { -} - -table HashtableOptions { - // The identity of hash tables. This identity will be used across different - // subgraphs in the same interpreter instance. - table_id:int; - key_dtype:TensorType; - value_dtype:TensorType; -} - -table HashtableFindOptions { -} - -table HashtableImportOptions { -} - -table HashtableSizeOptions { -} - -table VarHandleOptions { - container:string; - shared_name:string; -} - -table ReadVariableOptions { -} - -table AssignVariableOptions { -} - -table RandomOptions { - seed: long; - seed2: long; -} - -table BucketizeOptions { - boundaries: [float]; // The bucket boundaries. -} - -table GeluOptions { - approximate: bool; -} - -table DynamicUpdateSliceOptions { -} - -table UnsortedSegmentProdOptions { -} - -table UnsortedSegmentMaxOptions { -} - -table UnsortedSegmentSumOptions { -} - -table ATan2Options { -} - -table UnsortedSegmentMinOptions{ -} - -table SignOptions { -} - -table BitcastOptions { -} - -table BitwiseXorOptions { -} - -table RightShiftOptions { -} - -table DilateOptions { -} - -enum ReduceWindowFunction : int { - UNSUPPORTED, - ADD, - MUL, - MINIMUM, - MAXIMUM, - ALL, - ANY, -} - -table ReduceWindowOptions (deprecated) { - reduce_function: ReduceWindowFunction; -} - -// An OperatorCode can be an enum value (BuiltinOperator) if the operator is a -// builtin, or a string if the operator is custom. -table OperatorCode { - // This field is for backward compatibility. This field will be used when - // the value of the extended builtin_code field has less than - // BulitinOperator_PLACEHOLDER_FOR_GREATER_OP_CODES. - deprecated_builtin_code:byte; - custom_code:string; - - // The version of the operator. The version need to be bumped whenever new - // parameters are introduced into an op. - version:int = 1; - - // This field is introduced for resolving op builtin code shortage problem - // (the original BuiltinOperator enum field was represented as a byte). - // This field will be used when the value of the extended builtin_code field - // has greater than BulitinOperator_PLACEHOLDER_FOR_GREATER_OP_CODES. - builtin_code:BuiltinOperator; -} - -enum CustomOptionsFormat : byte { - FLEXBUFFERS = 0, -} - -table StableHLOCompositeOptions { - name:string; - decomposition_subgraph_index:int32; - composite_attributes:[ubyte]; - composite_attributes_format:CustomOptionsFormat; - version:int32; -} - -table StablehloShiftLeftOptions { -} - -// An operator takes tensors as inputs and outputs. The type of operation being -// performed is determined by an index into the list of valid OperatorCodes, -// while the specifics of each operations is configured using builtin_options -// or custom_options. -table Operator { - // Index into the operator_codes array. Using an integer here avoids - // complicate map lookups. - opcode_index:uint; - - // Optional input are indicated by -1. - inputs:[int]; - outputs:[int]; - - builtin_options:BuiltinOptions; - custom_options:[ubyte]; - custom_options_format:CustomOptionsFormat; - - // A list of booleans indicating the input tensors which are being mutated by - // this operator.(e.g. used by RNN and LSTM). - // For example, if the "inputs" array refers to 5 tensors and the second and - // fifth are mutable variables, then this list will contain - // [false, true, false, false, true]. - // - // If the list is empty, no variable is mutated in this operator. - // The list either has the same length as `inputs`, or is empty. - mutating_variable_inputs:[bool]; - - // A list of indices to the subgraph's "tensors" that are internal to an Op. - // Internal tensors are those that do not flow in or out of the operation, - // but instead are part of internal computation. As such, the operation's - // implementation may manage its memory more efficiently. They are needed - // however (i.e. not just an implementation detail) since they are part of the - // computation, which may require relevant metadata such as quantization - // parameters. - intermediates:[int]; - - // When an op is using custom_options in a model that is larger than 2GB, then - // we instead use the following attributes to find the buffer location which - // is stored outside of flatbuffers, the offset is calculated relative to the - // beginning of the file and is only valid if > 1 - large_custom_options_offset: ulong; - large_custom_options_size: ulong; - - // Flatbuffers union struct has a 128 elements limit in JAVA, so a second - // union is added, in the case of where BuitlinOptions2 runs out, a third - // one can be added - builtin_options_2 : BuiltinOptions2; - - // Index into operators_debug_metadata list. - debug_metadata_index: int = -1; -} - -// The root type, defining a subgraph, which typically represents an entire -// model. -table SubGraph { - // A list of all tensors used in this subgraph. - tensors:[Tensor]; - - // Indices of the tensors that are inputs into this subgraph. Note this is - // the list of non-static tensors that feed into the subgraph for inference. - inputs:[int]; - - // Indices of the tensors that are outputs out of this subgraph. Note this is - // the list of output tensors that are considered the product of the - // subgraph's inference. - outputs:[int]; - - // All operators, in execution order. - operators:[Operator]; - - // Name of this subgraph (used for debugging). - name:string; - - // Index into subgraphs_debug_metadata list. - debug_metadata_index: int = -1; -} - -// Table of raw data buffers (used for constant tensors). Referenced by tensors -// by index. The generous alignment accommodates mmap-friendly data structures. -table Buffer { - data:[ubyte] (force_align: 16); - - // In a model that is larger than 2GB, then buffers instead uses the following - // attributes to find stored data, which is outside of flatbuffers - // the offset is calculated relative to the beginning of the file and is only - // valid if > 1. - offset: ulong; - size: ulong; -} - -// Groups external buffers by file/URI. -table ExternalBufferGroup { - name:string; -} - -// Describes an immutable data slice stored in an external file. -table ExternalBuffer { - // Unique identifier for this external buffer. - id:uint; - // Index into the external_buffer_groups array. - group:uint; - offset:ulong; - length:ulong; - packing:string; -} - -table Metadata { - // A human readable string to uniquely identify a Metadata. - name:string; - // An index to the buffers table. - buffer:uint; -} - -// Map from an alias name of tensor to tensor index in the graph. -// This is used in Signature def. -table TensorMap { - // Represents the alias to use for this tensor. - name:string; - - // The actual tensor index in the primary graph, that 'name' corresponds to. - tensor_index:uint; -} - -// This corresponds to SignatureDef in Tensorflow SavedModel. -// The SignatureDef will be part of the SavedModel provided for conversion. -table SignatureDef { - // Named inputs for this signature. - inputs:[TensorMap]; - - // Named outputs for this signature. - outputs:[TensorMap]; - - // Key value which was in the Tensorflow SavedModel SignatureDef map. - signature_key:string; - - // Model tag, deprecated. - deprecated_tag:string (deprecated); - - // Index of subgraphs that corresponds to the exported method. - subgraph_index:uint; -} - -table Model { - // Version of the schema. - version:uint; - - // A list of all operator codes used in this model. This is - // kept in order because operators carry an index into this - // vector. - operator_codes:[OperatorCode]; - - // All the subgraphs of the model. The 0th is assumed to be the main - // model. - subgraphs:[SubGraph]; - - // A description of the model. - description:string; - - // Buffers of the model. - // Note the 0th entry of this array must be an empty buffer (sentinel). - // This is a convention so that tensors without a buffer can provide 0 as - // their buffer. - buffers:[Buffer]; - - // Metadata about the model. Indirects into the existings buffers list. - // Deprecated, prefer to use metadata field. - metadata_buffer:[int]; - - // Metadata about the model. - metadata:[Metadata]; - - // Optional SignatureDefs for the model. - signature_defs:[SignatureDef]; - - // Optional groups for external weight buffers. - external_buffer_groups:[ExternalBufferGroup]; - - // Optional list of external weight buffers referenced by tensors. - external_buffers:[ExternalBuffer]; -} - -root_type Model; diff --git a/app/src/main/assets/schema_generated.py b/app/src/main/assets/schema_generated.py deleted file mode 100644 index 083034d..0000000 --- a/app/src/main/assets/schema_generated.py +++ /dev/null @@ -1,19640 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: tflite - -import flatbuffers -from flatbuffers.compat import import_numpy -np = import_numpy() - -class TensorType(object): - FLOAT32 = 0 - FLOAT16 = 1 - INT32 = 2 - UINT8 = 3 - INT64 = 4 - STRING = 5 - BOOL = 6 - INT16 = 7 - COMPLEX64 = 8 - INT8 = 9 - FLOAT64 = 10 - COMPLEX128 = 11 - UINT64 = 12 - RESOURCE = 13 - VARIANT = 14 - UINT32 = 15 - UINT16 = 16 - INT4 = 17 - BFLOAT16 = 18 - INT2 = 19 - UINT4 = 20 - - -class QuantizationDetails(object): - NONE = 0 - CustomQuantization = 1 - BlockwiseQuantization = 2 - -def QuantizationDetailsCreator(unionType, table): - from flatbuffers.table import Table - if not isinstance(table, Table): - return None - if unionType == QuantizationDetails.CustomQuantization: - return CustomQuantizationT.InitFromBuf(table.Bytes, table.Pos) - if unionType == QuantizationDetails.BlockwiseQuantization: - return BlockwiseQuantizationT.InitFromBuf(table.Bytes, table.Pos) - return None - - -class DimensionType(object): - DENSE = 0 - SPARSE_CSR = 1 - - -class SparseIndexVector(object): - NONE = 0 - Int32Vector = 1 - Uint16Vector = 2 - Uint8Vector = 3 - -def SparseIndexVectorCreator(unionType, table): - from flatbuffers.table import Table - if not isinstance(table, Table): - return None - if unionType == SparseIndexVector.Int32Vector: - return Int32VectorT.InitFromBuf(table.Bytes, table.Pos) - if unionType == SparseIndexVector.Uint16Vector: - return Uint16VectorT.InitFromBuf(table.Bytes, table.Pos) - if unionType == SparseIndexVector.Uint8Vector: - return Uint8VectorT.InitFromBuf(table.Bytes, table.Pos) - return None - - -class BuiltinOperator(object): - ADD = 0 - AVERAGE_POOL_2D = 1 - CONCATENATION = 2 - CONV_2D = 3 - DEPTHWISE_CONV_2D = 4 - DEPTH_TO_SPACE = 5 - DEQUANTIZE = 6 - EMBEDDING_LOOKUP = 7 - FLOOR = 8 - FULLY_CONNECTED = 9 - HASHTABLE_LOOKUP = 10 - L2_NORMALIZATION = 11 - L2_POOL_2D = 12 - LOCAL_RESPONSE_NORMALIZATION = 13 - LOGISTIC = 14 - LSH_PROJECTION = 15 - LSTM = 16 - MAX_POOL_2D = 17 - MUL = 18 - RELU = 19 - RELU_N1_TO_1 = 20 - RELU6 = 21 - RESHAPE = 22 - RESIZE_BILINEAR = 23 - RNN = 24 - SOFTMAX = 25 - SPACE_TO_DEPTH = 26 - SVDF = 27 - TANH = 28 - CONCAT_EMBEDDINGS = 29 - SKIP_GRAM = 30 - CALL = 31 - CUSTOM = 32 - EMBEDDING_LOOKUP_SPARSE = 33 - PAD = 34 - UNIDIRECTIONAL_SEQUENCE_RNN = 35 - GATHER = 36 - BATCH_TO_SPACE_ND = 37 - SPACE_TO_BATCH_ND = 38 - TRANSPOSE = 39 - MEAN = 40 - SUB = 41 - DIV = 42 - SQUEEZE = 43 - UNIDIRECTIONAL_SEQUENCE_LSTM = 44 - STRIDED_SLICE = 45 - BIDIRECTIONAL_SEQUENCE_RNN = 46 - EXP = 47 - TOPK_V2 = 48 - SPLIT = 49 - LOG_SOFTMAX = 50 - DELEGATE = 51 - BIDIRECTIONAL_SEQUENCE_LSTM = 52 - CAST = 53 - PRELU = 54 - MAXIMUM = 55 - ARG_MAX = 56 - MINIMUM = 57 - LESS = 58 - NEG = 59 - PADV2 = 60 - GREATER = 61 - GREATER_EQUAL = 62 - LESS_EQUAL = 63 - SELECT = 64 - SLICE = 65 - SIN = 66 - TRANSPOSE_CONV = 67 - SPARSE_TO_DENSE = 68 - TILE = 69 - EXPAND_DIMS = 70 - EQUAL = 71 - NOT_EQUAL = 72 - LOG = 73 - SUM = 74 - SQRT = 75 - RSQRT = 76 - SHAPE = 77 - POW = 78 - ARG_MIN = 79 - FAKE_QUANT = 80 - REDUCE_PROD = 81 - REDUCE_MAX = 82 - PACK = 83 - LOGICAL_OR = 84 - ONE_HOT = 85 - LOGICAL_AND = 86 - LOGICAL_NOT = 87 - UNPACK = 88 - REDUCE_MIN = 89 - FLOOR_DIV = 90 - REDUCE_ANY = 91 - SQUARE = 92 - ZEROS_LIKE = 93 - FILL = 94 - FLOOR_MOD = 95 - RANGE = 96 - RESIZE_NEAREST_NEIGHBOR = 97 - LEAKY_RELU = 98 - SQUARED_DIFFERENCE = 99 - MIRROR_PAD = 100 - ABS = 101 - SPLIT_V = 102 - UNIQUE = 103 - CEIL = 104 - REVERSE_V2 = 105 - ADD_N = 106 - GATHER_ND = 107 - COS = 108 - WHERE = 109 - RANK = 110 - ELU = 111 - REVERSE_SEQUENCE = 112 - MATRIX_DIAG = 113 - QUANTIZE = 114 - MATRIX_SET_DIAG = 115 - ROUND = 116 - HARD_SWISH = 117 - IF = 118 - WHILE = 119 - NON_MAX_SUPPRESSION_V4 = 120 - NON_MAX_SUPPRESSION_V5 = 121 - SCATTER_ND = 122 - SELECT_V2 = 123 - DENSIFY = 124 - SEGMENT_SUM = 125 - BATCH_MATMUL = 126 - PLACEHOLDER_FOR_GREATER_OP_CODES = 127 - CUMSUM = 128 - CALL_ONCE = 129 - BROADCAST_TO = 130 - RFFT2D = 131 - CONV_3D = 132 - IMAG = 133 - REAL = 134 - COMPLEX_ABS = 135 - HASHTABLE = 136 - HASHTABLE_FIND = 137 - HASHTABLE_IMPORT = 138 - HASHTABLE_SIZE = 139 - REDUCE_ALL = 140 - CONV_3D_TRANSPOSE = 141 - VAR_HANDLE = 142 - READ_VARIABLE = 143 - ASSIGN_VARIABLE = 144 - BROADCAST_ARGS = 145 - RANDOM_STANDARD_NORMAL = 146 - BUCKETIZE = 147 - RANDOM_UNIFORM = 148 - MULTINOMIAL = 149 - GELU = 150 - DYNAMIC_UPDATE_SLICE = 151 - RELU_0_TO_1 = 152 - UNSORTED_SEGMENT_PROD = 153 - UNSORTED_SEGMENT_MAX = 154 - UNSORTED_SEGMENT_SUM = 155 - ATAN2 = 156 - UNSORTED_SEGMENT_MIN = 157 - SIGN = 158 - BITCAST = 159 - BITWISE_XOR = 160 - RIGHT_SHIFT = 161 - STABLEHLO_LOGISTIC = 162 - STABLEHLO_ADD = 163 - STABLEHLO_DIVIDE = 164 - STABLEHLO_MULTIPLY = 165 - STABLEHLO_MAXIMUM = 166 - STABLEHLO_RESHAPE = 167 - STABLEHLO_CLAMP = 168 - STABLEHLO_CONCATENATE = 169 - STABLEHLO_BROADCAST_IN_DIM = 170 - STABLEHLO_CONVOLUTION = 171 - STABLEHLO_SLICE = 172 - STABLEHLO_CUSTOM_CALL = 173 - STABLEHLO_REDUCE = 174 - STABLEHLO_ABS = 175 - STABLEHLO_AND = 176 - STABLEHLO_COSINE = 177 - STABLEHLO_EXPONENTIAL = 178 - STABLEHLO_FLOOR = 179 - STABLEHLO_LOG = 180 - STABLEHLO_MINIMUM = 181 - STABLEHLO_NEGATE = 182 - STABLEHLO_OR = 183 - STABLEHLO_POWER = 184 - STABLEHLO_REMAINDER = 185 - STABLEHLO_RSQRT = 186 - STABLEHLO_SELECT = 187 - STABLEHLO_SUBTRACT = 188 - STABLEHLO_TANH = 189 - STABLEHLO_SCATTER = 190 - STABLEHLO_COMPARE = 191 - STABLEHLO_CONVERT = 192 - STABLEHLO_DYNAMIC_SLICE = 193 - STABLEHLO_DYNAMIC_UPDATE_SLICE = 194 - STABLEHLO_PAD = 195 - STABLEHLO_IOTA = 196 - STABLEHLO_DOT_GENERAL = 197 - STABLEHLO_REDUCE_WINDOW = 198 - STABLEHLO_SORT = 199 - STABLEHLO_WHILE = 200 - STABLEHLO_GATHER = 201 - STABLEHLO_TRANSPOSE = 202 - DILATE = 203 - STABLEHLO_RNG_BIT_GENERATOR = 204 - REDUCE_WINDOW = 205 - STABLEHLO_COMPOSITE = 206 - STABLEHLO_SHIFT_LEFT = 207 - STABLEHLO_CBRT = 208 - STABLEHLO_CASE = 209 - - -class BuiltinOptions(object): - NONE = 0 - Conv2DOptions = 1 - DepthwiseConv2DOptions = 2 - ConcatEmbeddingsOptions = 3 - LSHProjectionOptions = 4 - Pool2DOptions = 5 - SVDFOptions = 6 - RNNOptions = 7 - FullyConnectedOptions = 8 - SoftmaxOptions = 9 - ConcatenationOptions = 10 - AddOptions = 11 - L2NormOptions = 12 - LocalResponseNormalizationOptions = 13 - LSTMOptions = 14 - ResizeBilinearOptions = 15 - CallOptions = 16 - ReshapeOptions = 17 - SkipGramOptions = 18 - SpaceToDepthOptions = 19 - EmbeddingLookupSparseOptions = 20 - MulOptions = 21 - PadOptions = 22 - GatherOptions = 23 - BatchToSpaceNDOptions = 24 - SpaceToBatchNDOptions = 25 - TransposeOptions = 26 - ReducerOptions = 27 - SubOptions = 28 - DivOptions = 29 - SqueezeOptions = 30 - SequenceRNNOptions = 31 - StridedSliceOptions = 32 - ExpOptions = 33 - TopKV2Options = 34 - SplitOptions = 35 - LogSoftmaxOptions = 36 - CastOptions = 37 - DequantizeOptions = 38 - MaximumMinimumOptions = 39 - ArgMaxOptions = 40 - LessOptions = 41 - NegOptions = 42 - PadV2Options = 43 - GreaterOptions = 44 - GreaterEqualOptions = 45 - LessEqualOptions = 46 - SelectOptions = 47 - SliceOptions = 48 - TransposeConvOptions = 49 - SparseToDenseOptions = 50 - TileOptions = 51 - ExpandDimsOptions = 52 - EqualOptions = 53 - NotEqualOptions = 54 - ShapeOptions = 55 - PowOptions = 56 - ArgMinOptions = 57 - FakeQuantOptions = 58 - PackOptions = 59 - LogicalOrOptions = 60 - OneHotOptions = 61 - LogicalAndOptions = 62 - LogicalNotOptions = 63 - UnpackOptions = 64 - FloorDivOptions = 65 - SquareOptions = 66 - ZerosLikeOptions = 67 - FillOptions = 68 - BidirectionalSequenceLSTMOptions = 69 - BidirectionalSequenceRNNOptions = 70 - UnidirectionalSequenceLSTMOptions = 71 - FloorModOptions = 72 - RangeOptions = 73 - ResizeNearestNeighborOptions = 74 - LeakyReluOptions = 75 - SquaredDifferenceOptions = 76 - MirrorPadOptions = 77 - AbsOptions = 78 - SplitVOptions = 79 - UniqueOptions = 80 - ReverseV2Options = 81 - AddNOptions = 82 - GatherNdOptions = 83 - CosOptions = 84 - WhereOptions = 85 - RankOptions = 86 - ReverseSequenceOptions = 87 - MatrixDiagOptions = 88 - QuantizeOptions = 89 - MatrixSetDiagOptions = 90 - HardSwishOptions = 91 - IfOptions = 92 - WhileOptions = 93 - DepthToSpaceOptions = 94 - NonMaxSuppressionV4Options = 95 - NonMaxSuppressionV5Options = 96 - ScatterNdOptions = 97 - SelectV2Options = 98 - DensifyOptions = 99 - SegmentSumOptions = 100 - BatchMatMulOptions = 101 - CumsumOptions = 102 - CallOnceOptions = 103 - BroadcastToOptions = 104 - Rfft2dOptions = 105 - Conv3DOptions = 106 - HashtableOptions = 107 - HashtableFindOptions = 108 - HashtableImportOptions = 109 - HashtableSizeOptions = 110 - VarHandleOptions = 111 - ReadVariableOptions = 112 - AssignVariableOptions = 113 - RandomOptions = 114 - BucketizeOptions = 115 - GeluOptions = 116 - DynamicUpdateSliceOptions = 117 - UnsortedSegmentProdOptions = 118 - UnsortedSegmentMaxOptions = 119 - UnsortedSegmentMinOptions = 120 - UnsortedSegmentSumOptions = 121 - ATan2Options = 122 - SignOptions = 123 - BitcastOptions = 124 - BitwiseXorOptions = 125 - RightShiftOptions = 126 - -def BuiltinOptionsCreator(unionType, table): - from flatbuffers.table import Table - if not isinstance(table, Table): - return None - if unionType == BuiltinOptions.Conv2DOptions: - return Conv2DOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.DepthwiseConv2DOptions: - return DepthwiseConv2DOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ConcatEmbeddingsOptions: - return ConcatEmbeddingsOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.LSHProjectionOptions: - return LSHProjectionOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.Pool2DOptions: - return Pool2DOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SVDFOptions: - return SVDFOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.RNNOptions: - return RNNOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.FullyConnectedOptions: - return FullyConnectedOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SoftmaxOptions: - return SoftmaxOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ConcatenationOptions: - return ConcatenationOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.AddOptions: - return AddOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.L2NormOptions: - return L2NormOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.LocalResponseNormalizationOptions: - return LocalResponseNormalizationOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.LSTMOptions: - return LSTMOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ResizeBilinearOptions: - return ResizeBilinearOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.CallOptions: - return CallOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ReshapeOptions: - return ReshapeOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SkipGramOptions: - return SkipGramOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SpaceToDepthOptions: - return SpaceToDepthOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.EmbeddingLookupSparseOptions: - return EmbeddingLookupSparseOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.MulOptions: - return MulOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.PadOptions: - return PadOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.GatherOptions: - return GatherOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.BatchToSpaceNDOptions: - return BatchToSpaceNDOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SpaceToBatchNDOptions: - return SpaceToBatchNDOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.TransposeOptions: - return TransposeOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ReducerOptions: - return ReducerOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SubOptions: - return SubOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.DivOptions: - return DivOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SqueezeOptions: - return SqueezeOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SequenceRNNOptions: - return SequenceRNNOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.StridedSliceOptions: - return StridedSliceOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ExpOptions: - return ExpOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.TopKV2Options: - return TopKV2OptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SplitOptions: - return SplitOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.LogSoftmaxOptions: - return LogSoftmaxOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.CastOptions: - return CastOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.DequantizeOptions: - return DequantizeOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.MaximumMinimumOptions: - return MaximumMinimumOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ArgMaxOptions: - return ArgMaxOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.LessOptions: - return LessOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.NegOptions: - return NegOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.PadV2Options: - return PadV2OptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.GreaterOptions: - return GreaterOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.GreaterEqualOptions: - return GreaterEqualOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.LessEqualOptions: - return LessEqualOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SelectOptions: - return SelectOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SliceOptions: - return SliceOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.TransposeConvOptions: - return TransposeConvOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SparseToDenseOptions: - return SparseToDenseOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.TileOptions: - return TileOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ExpandDimsOptions: - return ExpandDimsOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.EqualOptions: - return EqualOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.NotEqualOptions: - return NotEqualOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ShapeOptions: - return ShapeOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.PowOptions: - return PowOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ArgMinOptions: - return ArgMinOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.FakeQuantOptions: - return FakeQuantOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.PackOptions: - return PackOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.LogicalOrOptions: - return LogicalOrOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.OneHotOptions: - return OneHotOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.LogicalAndOptions: - return LogicalAndOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.LogicalNotOptions: - return LogicalNotOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.UnpackOptions: - return UnpackOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.FloorDivOptions: - return FloorDivOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SquareOptions: - return SquareOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ZerosLikeOptions: - return ZerosLikeOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.FillOptions: - return FillOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.BidirectionalSequenceLSTMOptions: - return BidirectionalSequenceLSTMOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.BidirectionalSequenceRNNOptions: - return BidirectionalSequenceRNNOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.UnidirectionalSequenceLSTMOptions: - return UnidirectionalSequenceLSTMOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.FloorModOptions: - return FloorModOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.RangeOptions: - return RangeOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ResizeNearestNeighborOptions: - return ResizeNearestNeighborOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.LeakyReluOptions: - return LeakyReluOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SquaredDifferenceOptions: - return SquaredDifferenceOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.MirrorPadOptions: - return MirrorPadOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.AbsOptions: - return AbsOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SplitVOptions: - return SplitVOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.UniqueOptions: - return UniqueOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ReverseV2Options: - return ReverseV2OptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.AddNOptions: - return AddNOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.GatherNdOptions: - return GatherNdOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.CosOptions: - return CosOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.WhereOptions: - return WhereOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.RankOptions: - return RankOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ReverseSequenceOptions: - return ReverseSequenceOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.MatrixDiagOptions: - return MatrixDiagOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.QuantizeOptions: - return QuantizeOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.MatrixSetDiagOptions: - return MatrixSetDiagOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.HardSwishOptions: - return HardSwishOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.IfOptions: - return IfOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.WhileOptions: - return WhileOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.DepthToSpaceOptions: - return DepthToSpaceOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.NonMaxSuppressionV4Options: - return NonMaxSuppressionV4OptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.NonMaxSuppressionV5Options: - return NonMaxSuppressionV5OptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ScatterNdOptions: - return ScatterNdOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SelectV2Options: - return SelectV2OptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.DensifyOptions: - return DensifyOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SegmentSumOptions: - return SegmentSumOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.BatchMatMulOptions: - return BatchMatMulOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.CumsumOptions: - return CumsumOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.CallOnceOptions: - return CallOnceOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.BroadcastToOptions: - return BroadcastToOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.Rfft2dOptions: - return Rfft2dOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.Conv3DOptions: - return Conv3DOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.HashtableOptions: - return HashtableOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.HashtableFindOptions: - return HashtableFindOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.HashtableImportOptions: - return HashtableImportOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.HashtableSizeOptions: - return HashtableSizeOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.VarHandleOptions: - return VarHandleOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ReadVariableOptions: - return ReadVariableOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.AssignVariableOptions: - return AssignVariableOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.RandomOptions: - return RandomOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.BucketizeOptions: - return BucketizeOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.GeluOptions: - return GeluOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.DynamicUpdateSliceOptions: - return DynamicUpdateSliceOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.UnsortedSegmentProdOptions: - return UnsortedSegmentProdOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.UnsortedSegmentMaxOptions: - return UnsortedSegmentMaxOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.UnsortedSegmentMinOptions: - return UnsortedSegmentMinOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.UnsortedSegmentSumOptions: - return UnsortedSegmentSumOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.ATan2Options: - return ATan2OptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.SignOptions: - return SignOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.BitcastOptions: - return BitcastOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.BitwiseXorOptions: - return BitwiseXorOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions.RightShiftOptions: - return RightShiftOptionsT.InitFromBuf(table.Bytes, table.Pos) - return None - - -class BuiltinOptions2(object): - NONE = 0 - StablehloConcatenateOptions = 1 - StablehloBroadcastInDimOptions = 2 - StablehloSliceOptions = 3 - StablehloConvolutionOptions = 4 - StablehloCustomCallOptions = 5 - StablehloReduceOptions = 6 - StablehloScatterOptions = 7 - StablehloCompareOptions = 8 - StablehloDynamicSliceOptions = 9 - StablehloPadOptions = 10 - StablehloIotaOptions = 11 - StablehloDotGeneralOptions = 12 - StablehloReduceWindowOptions = 13 - StablehloSortOptions = 14 - StablehloWhileOptions = 15 - StablehloGatherOptions = 16 - StablehloTransposeOptions = 17 - DilateOptions = 18 - StablehloRngBitGeneratorOptions = 19 - ReduceWindowOptions = 20 - StableHLOCompositeOptions = 21 - StablehloShiftLeftOptions = 22 - StablehloCaseOptions = 23 - -def BuiltinOptions2Creator(unionType, table): - from flatbuffers.table import Table - if not isinstance(table, Table): - return None - if unionType == BuiltinOptions2.StablehloConcatenateOptions: - return StablehloConcatenateOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloBroadcastInDimOptions: - return StablehloBroadcastInDimOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloSliceOptions: - return StablehloSliceOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloConvolutionOptions: - return StablehloConvolutionOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloCustomCallOptions: - return StablehloCustomCallOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloReduceOptions: - return StablehloReduceOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloScatterOptions: - return StablehloScatterOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloCompareOptions: - return StablehloCompareOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloDynamicSliceOptions: - return StablehloDynamicSliceOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloPadOptions: - return StablehloPadOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloIotaOptions: - return StablehloIotaOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloDotGeneralOptions: - return StablehloDotGeneralOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloReduceWindowOptions: - return StablehloReduceWindowOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloSortOptions: - return StablehloSortOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloWhileOptions: - return StablehloWhileOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloGatherOptions: - return StablehloGatherOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloTransposeOptions: - return StablehloTransposeOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.DilateOptions: - return DilateOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloRngBitGeneratorOptions: - return StablehloRngBitGeneratorOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.ReduceWindowOptions: - return ReduceWindowOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StableHLOCompositeOptions: - return StableHLOCompositeOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloShiftLeftOptions: - return StablehloShiftLeftOptionsT.InitFromBuf(table.Bytes, table.Pos) - if unionType == BuiltinOptions2.StablehloCaseOptions: - return StablehloCaseOptionsT.InitFromBuf(table.Bytes, table.Pos) - return None - - -class StablehloPrecisionConfig(object): - DEFAULT = 0 - HIGH = 1 - HIGHEST = 2 - - -class StablehloComparisonDirection(object): - STABLEHLO_COMPARISON_DIRECTION_EQ = 0 - STABLEHLO_COMPARISON_DIRECTION_NE = 1 - STABLEHLO_COMPARISON_DIRECTION_GE = 2 - STABLEHLO_COMPARISON_DIRECTION_GT = 3 - STABLEHLO_COMPARISON_DIRECTION_LE = 4 - STABLEHLO_COMPARISON_DIRECTION_LT = 5 - - -class StablehloComparisonType(object): - STABLEHLO_COMPARISON_TYPE_NOTYPE = 0 - STABLEHLO_COMPARISON_TYPE_FLOAT = 1 - STABLEHLO_COMPARISON_TYPE_FLOAT_TOTAL_ORDER = 2 - STABLEHLO_COMPARISON_TYPE_SIGNED = 3 - STABLEHLO_COMPARISON_TYPE_UNSIGNED = 4 - - -class RngAlgorithm(object): - DEFAULT = 0 - PHILOX = 1 - THREEFRY = 2 - - -class Padding(object): - SAME = 0 - VALID = 1 - - -class ActivationFunctionType(object): - NONE = 0 - RELU = 1 - RELU_N1_TO_1 = 2 - RELU6 = 3 - TANH = 4 - SIGN_BIT = 5 - - -class LSHProjectionType(object): - UNKNOWN = 0 - SPARSE = 1 - DENSE = 2 - - -class FullyConnectedOptionsWeightsFormat(object): - DEFAULT = 0 - SHUFFLED4x16INT8 = 1 - - -class LSTMKernelType(object): - FULL = 0 - BASIC = 1 - - -class CombinerType(object): - SUM = 0 - MEAN = 1 - SQRTN = 2 - - -class MirrorPadMode(object): - REFLECT = 0 - SYMMETRIC = 1 - - -class ReduceWindowFunction(object): - UNSUPPORTED = 0 - ADD = 1 - MUL = 2 - MINIMUM = 3 - MAXIMUM = 4 - ALL = 5 - ANY = 6 - - -class CustomOptionsFormat(object): - FLEXBUFFERS = 0 - - -class CustomQuantization(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = CustomQuantization() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsCustomQuantization(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def CustomQuantizationBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # CustomQuantization - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # CustomQuantization - def Custom(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) - return 0 - - # CustomQuantization - def CustomAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o) - return 0 - - # CustomQuantization - def CustomLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # CustomQuantization - def CustomIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - -def CustomQuantizationStart(builder): - builder.StartObject(1) - -def CustomQuantizationAddCustom(builder, custom): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(custom), 0) - -def CustomQuantizationStartCustomVector(builder, numElems): - return builder.StartVector(1, numElems, 1) - -def CustomQuantizationEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class CustomQuantizationT(object): - - # CustomQuantizationT - def __init__( - self, - custom = None, - ): - self.custom = custom # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - customQuantization = CustomQuantization() - customQuantization.Init(buf, pos) - return cls.InitFromObj(customQuantization) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, customQuantization): - x = CustomQuantizationT() - x._UnPack(customQuantization) - return x - - # CustomQuantizationT - def _UnPack(self, customQuantization): - if customQuantization is None: - return - if not customQuantization.CustomIsNone(): - if np is None: - self.custom = [] - for i in range(customQuantization.CustomLength()): - self.custom.append(customQuantization.Custom(i)) - else: - self.custom = customQuantization.CustomAsNumpy() - - # CustomQuantizationT - def Pack(self, builder): - if self.custom is not None: - if np is not None and type(self.custom) is np.ndarray: - custom = builder.CreateNumpyVector(self.custom) - else: - CustomQuantizationStartCustomVector(builder, len(self.custom)) - for i in reversed(range(len(self.custom))): - builder.PrependUint8(self.custom[i]) - custom = builder.EndVector() - CustomQuantizationStart(builder) - if self.custom is not None: - CustomQuantizationAddCustom(builder, custom) - customQuantization = CustomQuantizationEnd(builder) - return customQuantization - - -class BlockwiseQuantization(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = BlockwiseQuantization() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsBlockwiseQuantization(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def BlockwiseQuantizationBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # BlockwiseQuantization - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # BlockwiseQuantization - def Scales(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # BlockwiseQuantization - def ZeroPoints(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # BlockwiseQuantization - def BlockSize(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def BlockwiseQuantizationStart(builder): - builder.StartObject(3) - -def BlockwiseQuantizationAddScales(builder, scales): - builder.PrependInt32Slot(0, scales, 0) - -def BlockwiseQuantizationAddZeroPoints(builder, zeroPoints): - builder.PrependInt32Slot(1, zeroPoints, 0) - -def BlockwiseQuantizationAddBlockSize(builder, blockSize): - builder.PrependInt32Slot(2, blockSize, 0) - -def BlockwiseQuantizationEnd(builder): - return builder.EndObject() - - - -class BlockwiseQuantizationT(object): - - # BlockwiseQuantizationT - def __init__( - self, - scales = 0, - zeroPoints = 0, - blockSize = 0, - ): - self.scales = scales # type: int - self.zeroPoints = zeroPoints # type: int - self.blockSize = blockSize # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - blockwiseQuantization = BlockwiseQuantization() - blockwiseQuantization.Init(buf, pos) - return cls.InitFromObj(blockwiseQuantization) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, blockwiseQuantization): - x = BlockwiseQuantizationT() - x._UnPack(blockwiseQuantization) - return x - - # BlockwiseQuantizationT - def _UnPack(self, blockwiseQuantization): - if blockwiseQuantization is None: - return - self.scales = blockwiseQuantization.Scales() - self.zeroPoints = blockwiseQuantization.ZeroPoints() - self.blockSize = blockwiseQuantization.BlockSize() - - # BlockwiseQuantizationT - def Pack(self, builder): - BlockwiseQuantizationStart(builder) - BlockwiseQuantizationAddScales(builder, self.scales) - BlockwiseQuantizationAddZeroPoints(builder, self.zeroPoints) - BlockwiseQuantizationAddBlockSize(builder, self.blockSize) - blockwiseQuantization = BlockwiseQuantizationEnd(builder) - return blockwiseQuantization - - -class QuantizationParameters(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = QuantizationParameters() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsQuantizationParameters(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def QuantizationParametersBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # QuantizationParameters - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # QuantizationParameters - def Min(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Float32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # QuantizationParameters - def MinAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float32Flags, o) - return 0 - - # QuantizationParameters - def MinLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # QuantizationParameters - def MinIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # QuantizationParameters - def Max(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Float32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # QuantizationParameters - def MaxAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float32Flags, o) - return 0 - - # QuantizationParameters - def MaxLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # QuantizationParameters - def MaxIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # QuantizationParameters - def Scale(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Float32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # QuantizationParameters - def ScaleAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float32Flags, o) - return 0 - - # QuantizationParameters - def ScaleLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # QuantizationParameters - def ScaleIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - - # QuantizationParameters - def ZeroPoint(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # QuantizationParameters - def ZeroPointAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # QuantizationParameters - def ZeroPointLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # QuantizationParameters - def ZeroPointIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - return o == 0 - - # QuantizationParameters - def DetailsType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos) - return 0 - - # QuantizationParameters - def Details(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - from flatbuffers.table import Table - obj = Table(bytearray(), 0) - self._tab.Union(obj, o) - return obj - return None - - # QuantizationParameters - def QuantizedDimension(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def QuantizationParametersStart(builder): - builder.StartObject(7) - -def QuantizationParametersAddMin(builder, min): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(min), 0) - -def QuantizationParametersStartMinVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def QuantizationParametersAddMax(builder, max): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(max), 0) - -def QuantizationParametersStartMaxVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def QuantizationParametersAddScale(builder, scale): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(scale), 0) - -def QuantizationParametersStartScaleVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def QuantizationParametersAddZeroPoint(builder, zeroPoint): - builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(zeroPoint), 0) - -def QuantizationParametersStartZeroPointVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def QuantizationParametersAddDetailsType(builder, detailsType): - builder.PrependUint8Slot(4, detailsType, 0) - -def QuantizationParametersAddDetails(builder, details): - builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(details), 0) - -def QuantizationParametersAddQuantizedDimension(builder, quantizedDimension): - builder.PrependInt32Slot(6, quantizedDimension, 0) - -def QuantizationParametersEnd(builder): - return builder.EndObject() - - -try: - from typing import List, Union -except: - pass - -class QuantizationParametersT(object): - - # QuantizationParametersT - def __init__( - self, - min = None, - max = None, - scale = None, - zeroPoint = None, - detailsType = 0, - details = None, - quantizedDimension = 0, - ): - self.min = min # type: Optional[List[float]] - self.max = max # type: Optional[List[float]] - self.scale = scale # type: Optional[List[float]] - self.zeroPoint = zeroPoint # type: Optional[List[int]] - self.detailsType = detailsType # type: int - self.details = details # type: Union[None, 'CustomQuantizationT', 'BlockwiseQuantizationT'] - self.quantizedDimension = quantizedDimension # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - quantizationParameters = QuantizationParameters() - quantizationParameters.Init(buf, pos) - return cls.InitFromObj(quantizationParameters) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, quantizationParameters): - x = QuantizationParametersT() - x._UnPack(quantizationParameters) - return x - - # QuantizationParametersT - def _UnPack(self, quantizationParameters): - if quantizationParameters is None: - return - if not quantizationParameters.MinIsNone(): - if np is None: - self.min = [] - for i in range(quantizationParameters.MinLength()): - self.min.append(quantizationParameters.Min(i)) - else: - self.min = quantizationParameters.MinAsNumpy() - if not quantizationParameters.MaxIsNone(): - if np is None: - self.max = [] - for i in range(quantizationParameters.MaxLength()): - self.max.append(quantizationParameters.Max(i)) - else: - self.max = quantizationParameters.MaxAsNumpy() - if not quantizationParameters.ScaleIsNone(): - if np is None: - self.scale = [] - for i in range(quantizationParameters.ScaleLength()): - self.scale.append(quantizationParameters.Scale(i)) - else: - self.scale = quantizationParameters.ScaleAsNumpy() - if not quantizationParameters.ZeroPointIsNone(): - if np is None: - self.zeroPoint = [] - for i in range(quantizationParameters.ZeroPointLength()): - self.zeroPoint.append(quantizationParameters.ZeroPoint(i)) - else: - self.zeroPoint = quantizationParameters.ZeroPointAsNumpy() - self.detailsType = quantizationParameters.DetailsType() - self.details = QuantizationDetailsCreator(self.detailsType, quantizationParameters.Details()) - self.quantizedDimension = quantizationParameters.QuantizedDimension() - - # QuantizationParametersT - def Pack(self, builder): - if self.min is not None: - if np is not None and type(self.min) is np.ndarray: - min = builder.CreateNumpyVector(self.min) - else: - QuantizationParametersStartMinVector(builder, len(self.min)) - for i in reversed(range(len(self.min))): - builder.PrependFloat32(self.min[i]) - min = builder.EndVector() - if self.max is not None: - if np is not None and type(self.max) is np.ndarray: - max = builder.CreateNumpyVector(self.max) - else: - QuantizationParametersStartMaxVector(builder, len(self.max)) - for i in reversed(range(len(self.max))): - builder.PrependFloat32(self.max[i]) - max = builder.EndVector() - if self.scale is not None: - if np is not None and type(self.scale) is np.ndarray: - scale = builder.CreateNumpyVector(self.scale) - else: - QuantizationParametersStartScaleVector(builder, len(self.scale)) - for i in reversed(range(len(self.scale))): - builder.PrependFloat32(self.scale[i]) - scale = builder.EndVector() - if self.zeroPoint is not None: - if np is not None and type(self.zeroPoint) is np.ndarray: - zeroPoint = builder.CreateNumpyVector(self.zeroPoint) - else: - QuantizationParametersStartZeroPointVector(builder, len(self.zeroPoint)) - for i in reversed(range(len(self.zeroPoint))): - builder.PrependInt64(self.zeroPoint[i]) - zeroPoint = builder.EndVector() - if self.details is not None: - details = self.details.Pack(builder) - QuantizationParametersStart(builder) - if self.min is not None: - QuantizationParametersAddMin(builder, min) - if self.max is not None: - QuantizationParametersAddMax(builder, max) - if self.scale is not None: - QuantizationParametersAddScale(builder, scale) - if self.zeroPoint is not None: - QuantizationParametersAddZeroPoint(builder, zeroPoint) - QuantizationParametersAddDetailsType(builder, self.detailsType) - if self.details is not None: - QuantizationParametersAddDetails(builder, details) - QuantizationParametersAddQuantizedDimension(builder, self.quantizedDimension) - quantizationParameters = QuantizationParametersEnd(builder) - return quantizationParameters - - -class Int32Vector(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Int32Vector() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsInt32Vector(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def Int32VectorBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # Int32Vector - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Int32Vector - def Values(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # Int32Vector - def ValuesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # Int32Vector - def ValuesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Int32Vector - def ValuesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - -def Int32VectorStart(builder): - builder.StartObject(1) - -def Int32VectorAddValues(builder, values): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(values), 0) - -def Int32VectorStartValuesVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def Int32VectorEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class Int32VectorT(object): - - # Int32VectorT - def __init__( - self, - values = None, - ): - self.values = values # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - int32Vector = Int32Vector() - int32Vector.Init(buf, pos) - return cls.InitFromObj(int32Vector) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, int32Vector): - x = Int32VectorT() - x._UnPack(int32Vector) - return x - - # Int32VectorT - def _UnPack(self, int32Vector): - if int32Vector is None: - return - if not int32Vector.ValuesIsNone(): - if np is None: - self.values = [] - for i in range(int32Vector.ValuesLength()): - self.values.append(int32Vector.Values(i)) - else: - self.values = int32Vector.ValuesAsNumpy() - - # Int32VectorT - def Pack(self, builder): - if self.values is not None: - if np is not None and type(self.values) is np.ndarray: - values = builder.CreateNumpyVector(self.values) - else: - Int32VectorStartValuesVector(builder, len(self.values)) - for i in reversed(range(len(self.values))): - builder.PrependInt32(self.values[i]) - values = builder.EndVector() - Int32VectorStart(builder) - if self.values is not None: - Int32VectorAddValues(builder, values) - int32Vector = Int32VectorEnd(builder) - return int32Vector - - -class Uint16Vector(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Uint16Vector() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsUint16Vector(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def Uint16VectorBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # Uint16Vector - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Uint16Vector - def Values(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Uint16Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 2)) - return 0 - - # Uint16Vector - def ValuesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint16Flags, o) - return 0 - - # Uint16Vector - def ValuesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Uint16Vector - def ValuesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - -def Uint16VectorStart(builder): - builder.StartObject(1) - -def Uint16VectorAddValues(builder, values): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(values), 0) - -def Uint16VectorStartValuesVector(builder, numElems): - return builder.StartVector(2, numElems, 2) - -def Uint16VectorEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class Uint16VectorT(object): - - # Uint16VectorT - def __init__( - self, - values = None, - ): - self.values = values # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - uint16Vector = Uint16Vector() - uint16Vector.Init(buf, pos) - return cls.InitFromObj(uint16Vector) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, uint16Vector): - x = Uint16VectorT() - x._UnPack(uint16Vector) - return x - - # Uint16VectorT - def _UnPack(self, uint16Vector): - if uint16Vector is None: - return - if not uint16Vector.ValuesIsNone(): - if np is None: - self.values = [] - for i in range(uint16Vector.ValuesLength()): - self.values.append(uint16Vector.Values(i)) - else: - self.values = uint16Vector.ValuesAsNumpy() - - # Uint16VectorT - def Pack(self, builder): - if self.values is not None: - if np is not None and type(self.values) is np.ndarray: - values = builder.CreateNumpyVector(self.values) - else: - Uint16VectorStartValuesVector(builder, len(self.values)) - for i in reversed(range(len(self.values))): - builder.PrependUint16(self.values[i]) - values = builder.EndVector() - Uint16VectorStart(builder) - if self.values is not None: - Uint16VectorAddValues(builder, values) - uint16Vector = Uint16VectorEnd(builder) - return uint16Vector - - -class Uint8Vector(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Uint8Vector() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsUint8Vector(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def Uint8VectorBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # Uint8Vector - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Uint8Vector - def Values(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) - return 0 - - # Uint8Vector - def ValuesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o) - return 0 - - # Uint8Vector - def ValuesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Uint8Vector - def ValuesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - -def Uint8VectorStart(builder): - builder.StartObject(1) - -def Uint8VectorAddValues(builder, values): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(values), 0) - -def Uint8VectorStartValuesVector(builder, numElems): - return builder.StartVector(1, numElems, 1) - -def Uint8VectorEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class Uint8VectorT(object): - - # Uint8VectorT - def __init__( - self, - values = None, - ): - self.values = values # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - uint8Vector = Uint8Vector() - uint8Vector.Init(buf, pos) - return cls.InitFromObj(uint8Vector) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, uint8Vector): - x = Uint8VectorT() - x._UnPack(uint8Vector) - return x - - # Uint8VectorT - def _UnPack(self, uint8Vector): - if uint8Vector is None: - return - if not uint8Vector.ValuesIsNone(): - if np is None: - self.values = [] - for i in range(uint8Vector.ValuesLength()): - self.values.append(uint8Vector.Values(i)) - else: - self.values = uint8Vector.ValuesAsNumpy() - - # Uint8VectorT - def Pack(self, builder): - if self.values is not None: - if np is not None and type(self.values) is np.ndarray: - values = builder.CreateNumpyVector(self.values) - else: - Uint8VectorStartValuesVector(builder, len(self.values)) - for i in reversed(range(len(self.values))): - builder.PrependUint8(self.values[i]) - values = builder.EndVector() - Uint8VectorStart(builder) - if self.values is not None: - Uint8VectorAddValues(builder, values) - uint8Vector = Uint8VectorEnd(builder) - return uint8Vector - - -class DimensionMetadata(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = DimensionMetadata() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsDimensionMetadata(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def DimensionMetadataBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # DimensionMetadata - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # DimensionMetadata - def Format(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # DimensionMetadata - def DenseSize(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # DimensionMetadata - def ArraySegmentsType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos) - return 0 - - # DimensionMetadata - def ArraySegments(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - from flatbuffers.table import Table - obj = Table(bytearray(), 0) - self._tab.Union(obj, o) - return obj - return None - - # DimensionMetadata - def ArrayIndicesType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos) - return 0 - - # DimensionMetadata - def ArrayIndices(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - from flatbuffers.table import Table - obj = Table(bytearray(), 0) - self._tab.Union(obj, o) - return obj - return None - -def DimensionMetadataStart(builder): - builder.StartObject(6) - -def DimensionMetadataAddFormat(builder, format): - builder.PrependInt8Slot(0, format, 0) - -def DimensionMetadataAddDenseSize(builder, denseSize): - builder.PrependInt32Slot(1, denseSize, 0) - -def DimensionMetadataAddArraySegmentsType(builder, arraySegmentsType): - builder.PrependUint8Slot(2, arraySegmentsType, 0) - -def DimensionMetadataAddArraySegments(builder, arraySegments): - builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(arraySegments), 0) - -def DimensionMetadataAddArrayIndicesType(builder, arrayIndicesType): - builder.PrependUint8Slot(4, arrayIndicesType, 0) - -def DimensionMetadataAddArrayIndices(builder, arrayIndices): - builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(arrayIndices), 0) - -def DimensionMetadataEnd(builder): - return builder.EndObject() - - -try: - from typing import Union -except: - pass - -class DimensionMetadataT(object): - - # DimensionMetadataT - def __init__( - self, - format = 0, - denseSize = 0, - arraySegmentsType = 0, - arraySegments = None, - arrayIndicesType = 0, - arrayIndices = None, - ): - self.format = format # type: int - self.denseSize = denseSize # type: int - self.arraySegmentsType = arraySegmentsType # type: int - self.arraySegments = arraySegments # type: Union[None, 'Int32VectorT', 'Uint16VectorT', 'Uint8VectorT'] - self.arrayIndicesType = arrayIndicesType # type: int - self.arrayIndices = arrayIndices # type: Union[None, 'Int32VectorT', 'Uint16VectorT', 'Uint8VectorT'] - - @classmethod - def InitFromBuf(cls, buf, pos): - dimensionMetadata = DimensionMetadata() - dimensionMetadata.Init(buf, pos) - return cls.InitFromObj(dimensionMetadata) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, dimensionMetadata): - x = DimensionMetadataT() - x._UnPack(dimensionMetadata) - return x - - # DimensionMetadataT - def _UnPack(self, dimensionMetadata): - if dimensionMetadata is None: - return - self.format = dimensionMetadata.Format() - self.denseSize = dimensionMetadata.DenseSize() - self.arraySegmentsType = dimensionMetadata.ArraySegmentsType() - self.arraySegments = SparseIndexVectorCreator(self.arraySegmentsType, dimensionMetadata.ArraySegments()) - self.arrayIndicesType = dimensionMetadata.ArrayIndicesType() - self.arrayIndices = SparseIndexVectorCreator(self.arrayIndicesType, dimensionMetadata.ArrayIndices()) - - # DimensionMetadataT - def Pack(self, builder): - if self.arraySegments is not None: - arraySegments = self.arraySegments.Pack(builder) - if self.arrayIndices is not None: - arrayIndices = self.arrayIndices.Pack(builder) - DimensionMetadataStart(builder) - DimensionMetadataAddFormat(builder, self.format) - DimensionMetadataAddDenseSize(builder, self.denseSize) - DimensionMetadataAddArraySegmentsType(builder, self.arraySegmentsType) - if self.arraySegments is not None: - DimensionMetadataAddArraySegments(builder, arraySegments) - DimensionMetadataAddArrayIndicesType(builder, self.arrayIndicesType) - if self.arrayIndices is not None: - DimensionMetadataAddArrayIndices(builder, arrayIndices) - dimensionMetadata = DimensionMetadataEnd(builder) - return dimensionMetadata - - -class SparsityParameters(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SparsityParameters() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSparsityParameters(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SparsityParametersBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SparsityParameters - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SparsityParameters - def TraversalOrder(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # SparsityParameters - def TraversalOrderAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # SparsityParameters - def TraversalOrderLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # SparsityParameters - def TraversalOrderIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # SparsityParameters - def BlockMap(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # SparsityParameters - def BlockMapAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # SparsityParameters - def BlockMapLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # SparsityParameters - def BlockMapIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # SparsityParameters - def DimMetadata(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - obj = DimensionMetadata() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # SparsityParameters - def DimMetadataLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # SparsityParameters - def DimMetadataIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - -def SparsityParametersStart(builder): - builder.StartObject(3) - -def SparsityParametersAddTraversalOrder(builder, traversalOrder): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(traversalOrder), 0) - -def SparsityParametersStartTraversalOrderVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def SparsityParametersAddBlockMap(builder, blockMap): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(blockMap), 0) - -def SparsityParametersStartBlockMapVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def SparsityParametersAddDimMetadata(builder, dimMetadata): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(dimMetadata), 0) - -def SparsityParametersStartDimMetadataVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def SparsityParametersEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class SparsityParametersT(object): - - # SparsityParametersT - def __init__( - self, - traversalOrder = None, - blockMap = None, - dimMetadata = None, - ): - self.traversalOrder = traversalOrder # type: Optional[List[int]] - self.blockMap = blockMap # type: Optional[List[int]] - self.dimMetadata = dimMetadata # type: Optional[List[DimensionMetadataT]] - - @classmethod - def InitFromBuf(cls, buf, pos): - sparsityParameters = SparsityParameters() - sparsityParameters.Init(buf, pos) - return cls.InitFromObj(sparsityParameters) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, sparsityParameters): - x = SparsityParametersT() - x._UnPack(sparsityParameters) - return x - - # SparsityParametersT - def _UnPack(self, sparsityParameters): - if sparsityParameters is None: - return - if not sparsityParameters.TraversalOrderIsNone(): - if np is None: - self.traversalOrder = [] - for i in range(sparsityParameters.TraversalOrderLength()): - self.traversalOrder.append(sparsityParameters.TraversalOrder(i)) - else: - self.traversalOrder = sparsityParameters.TraversalOrderAsNumpy() - if not sparsityParameters.BlockMapIsNone(): - if np is None: - self.blockMap = [] - for i in range(sparsityParameters.BlockMapLength()): - self.blockMap.append(sparsityParameters.BlockMap(i)) - else: - self.blockMap = sparsityParameters.BlockMapAsNumpy() - if not sparsityParameters.DimMetadataIsNone(): - self.dimMetadata = [] - for i in range(sparsityParameters.DimMetadataLength()): - if sparsityParameters.DimMetadata(i) is None: - self.dimMetadata.append(None) - else: - dimensionMetadata_ = DimensionMetadataT.InitFromObj(sparsityParameters.DimMetadata(i)) - self.dimMetadata.append(dimensionMetadata_) - - # SparsityParametersT - def Pack(self, builder): - if self.traversalOrder is not None: - if np is not None and type(self.traversalOrder) is np.ndarray: - traversalOrder = builder.CreateNumpyVector(self.traversalOrder) - else: - SparsityParametersStartTraversalOrderVector(builder, len(self.traversalOrder)) - for i in reversed(range(len(self.traversalOrder))): - builder.PrependInt32(self.traversalOrder[i]) - traversalOrder = builder.EndVector() - if self.blockMap is not None: - if np is not None and type(self.blockMap) is np.ndarray: - blockMap = builder.CreateNumpyVector(self.blockMap) - else: - SparsityParametersStartBlockMapVector(builder, len(self.blockMap)) - for i in reversed(range(len(self.blockMap))): - builder.PrependInt32(self.blockMap[i]) - blockMap = builder.EndVector() - if self.dimMetadata is not None: - dimMetadatalist = [] - for i in range(len(self.dimMetadata)): - dimMetadatalist.append(self.dimMetadata[i].Pack(builder)) - SparsityParametersStartDimMetadataVector(builder, len(self.dimMetadata)) - for i in reversed(range(len(self.dimMetadata))): - builder.PrependUOffsetTRelative(dimMetadatalist[i]) - dimMetadata = builder.EndVector() - SparsityParametersStart(builder) - if self.traversalOrder is not None: - SparsityParametersAddTraversalOrder(builder, traversalOrder) - if self.blockMap is not None: - SparsityParametersAddBlockMap(builder, blockMap) - if self.dimMetadata is not None: - SparsityParametersAddDimMetadata(builder, dimMetadata) - sparsityParameters = SparsityParametersEnd(builder) - return sparsityParameters - - -class VariantSubType(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = VariantSubType() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsVariantSubType(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def VariantSubTypeBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # VariantSubType - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # VariantSubType - def Shape(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # VariantSubType - def ShapeAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # VariantSubType - def ShapeLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # VariantSubType - def ShapeIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # VariantSubType - def Type(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # VariantSubType - def HasRank(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def VariantSubTypeStart(builder): - builder.StartObject(3) - -def VariantSubTypeAddShape(builder, shape): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(shape), 0) - -def VariantSubTypeStartShapeVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def VariantSubTypeAddType(builder, type): - builder.PrependInt8Slot(1, type, 0) - -def VariantSubTypeAddHasRank(builder, hasRank): - builder.PrependBoolSlot(2, hasRank, 0) - -def VariantSubTypeEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class VariantSubTypeT(object): - - # VariantSubTypeT - def __init__( - self, - shape = None, - type = 0, - hasRank = False, - ): - self.shape = shape # type: Optional[List[int]] - self.type = type # type: int - self.hasRank = hasRank # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - variantSubType = VariantSubType() - variantSubType.Init(buf, pos) - return cls.InitFromObj(variantSubType) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, variantSubType): - x = VariantSubTypeT() - x._UnPack(variantSubType) - return x - - # VariantSubTypeT - def _UnPack(self, variantSubType): - if variantSubType is None: - return - if not variantSubType.ShapeIsNone(): - if np is None: - self.shape = [] - for i in range(variantSubType.ShapeLength()): - self.shape.append(variantSubType.Shape(i)) - else: - self.shape = variantSubType.ShapeAsNumpy() - self.type = variantSubType.Type() - self.hasRank = variantSubType.HasRank() - - # VariantSubTypeT - def Pack(self, builder): - if self.shape is not None: - if np is not None and type(self.shape) is np.ndarray: - shape = builder.CreateNumpyVector(self.shape) - else: - VariantSubTypeStartShapeVector(builder, len(self.shape)) - for i in reversed(range(len(self.shape))): - builder.PrependInt32(self.shape[i]) - shape = builder.EndVector() - VariantSubTypeStart(builder) - if self.shape is not None: - VariantSubTypeAddShape(builder, shape) - VariantSubTypeAddType(builder, self.type) - VariantSubTypeAddHasRank(builder, self.hasRank) - variantSubType = VariantSubTypeEnd(builder) - return variantSubType - - -class Tensor(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Tensor() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsTensor(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def TensorBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # Tensor - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Tensor - def Shape(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # Tensor - def ShapeAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # Tensor - def ShapeLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Tensor - def ShapeIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # Tensor - def Type(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # Tensor - def Buffer(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - - # Tensor - def Name(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - - # Tensor - def Quantization(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - x = self._tab.Indirect(o + self._tab.Pos) - obj = QuantizationParameters() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Tensor - def IsVariable(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # Tensor - def Sparsity(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) - if o != 0: - x = self._tab.Indirect(o + self._tab.Pos) - obj = SparsityParameters() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Tensor - def ShapeSignature(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # Tensor - def ShapeSignatureAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # Tensor - def ShapeSignatureLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Tensor - def ShapeSignatureIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - return o == 0 - - # Tensor - def HasRank(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # Tensor - def VariantTensors(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - obj = VariantSubType() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Tensor - def VariantTensorsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Tensor - def VariantTensorsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22)) - return o == 0 - - # Tensor - def ExternalBuffer(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - -def TensorStart(builder): - builder.StartObject(11) - -def TensorAddShape(builder, shape): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(shape), 0) - -def TensorStartShapeVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def TensorAddType(builder, type): - builder.PrependInt8Slot(1, type, 0) - -def TensorAddBuffer(builder, buffer): - builder.PrependUint32Slot(2, buffer, 0) - -def TensorAddName(builder, name): - builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0) - -def TensorAddQuantization(builder, quantization): - builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(quantization), 0) - -def TensorAddIsVariable(builder, isVariable): - builder.PrependBoolSlot(5, isVariable, 0) - -def TensorAddSparsity(builder, sparsity): - builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(sparsity), 0) - -def TensorAddShapeSignature(builder, shapeSignature): - builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(shapeSignature), 0) - -def TensorStartShapeSignatureVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def TensorAddHasRank(builder, hasRank): - builder.PrependBoolSlot(8, hasRank, 0) - -def TensorAddVariantTensors(builder, variantTensors): - builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(variantTensors), 0) - -def TensorStartVariantTensorsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def TensorAddExternalBuffer(builder, externalBuffer): - builder.PrependUint32Slot(10, externalBuffer, 0) - -def TensorEnd(builder): - return builder.EndObject() - - -try: - from typing import List, Optional -except: - pass - -class TensorT(object): - - # TensorT - def __init__( - self, - shape = None, - type = 0, - buffer = 0, - name = None, - quantization = None, - isVariable = False, - sparsity = None, - shapeSignature = None, - hasRank = False, - variantTensors = None, - externalBuffer = 0, - ): - self.shape = shape # type: Optional[List[int]] - self.type = type # type: int - self.buffer = buffer # type: int - self.name = name # type: Optional[str] - self.quantization = quantization # type: Optional[QuantizationParametersT] - self.isVariable = isVariable # type: bool - self.sparsity = sparsity # type: Optional[SparsityParametersT] - self.shapeSignature = shapeSignature # type: Optional[List[int]] - self.hasRank = hasRank # type: bool - self.variantTensors = variantTensors # type: Optional[List[VariantSubTypeT]] - self.externalBuffer = externalBuffer # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - tensor = Tensor() - tensor.Init(buf, pos) - return cls.InitFromObj(tensor) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, tensor): - x = TensorT() - x._UnPack(tensor) - return x - - # TensorT - def _UnPack(self, tensor): - if tensor is None: - return - if not tensor.ShapeIsNone(): - if np is None: - self.shape = [] - for i in range(tensor.ShapeLength()): - self.shape.append(tensor.Shape(i)) - else: - self.shape = tensor.ShapeAsNumpy() - self.type = tensor.Type() - self.buffer = tensor.Buffer() - self.name = tensor.Name() - if tensor.Quantization() is not None: - self.quantization = QuantizationParametersT.InitFromObj(tensor.Quantization()) - self.isVariable = tensor.IsVariable() - if tensor.Sparsity() is not None: - self.sparsity = SparsityParametersT.InitFromObj(tensor.Sparsity()) - if not tensor.ShapeSignatureIsNone(): - if np is None: - self.shapeSignature = [] - for i in range(tensor.ShapeSignatureLength()): - self.shapeSignature.append(tensor.ShapeSignature(i)) - else: - self.shapeSignature = tensor.ShapeSignatureAsNumpy() - self.hasRank = tensor.HasRank() - if not tensor.VariantTensorsIsNone(): - self.variantTensors = [] - for i in range(tensor.VariantTensorsLength()): - if tensor.VariantTensors(i) is None: - self.variantTensors.append(None) - else: - variantSubType_ = VariantSubTypeT.InitFromObj(tensor.VariantTensors(i)) - self.variantTensors.append(variantSubType_) - self.externalBuffer = tensor.ExternalBuffer() - - # TensorT - def Pack(self, builder): - if self.shape is not None: - if np is not None and type(self.shape) is np.ndarray: - shape = builder.CreateNumpyVector(self.shape) - else: - TensorStartShapeVector(builder, len(self.shape)) - for i in reversed(range(len(self.shape))): - builder.PrependInt32(self.shape[i]) - shape = builder.EndVector() - if self.name is not None: - name = builder.CreateString(self.name) - if self.quantization is not None: - quantization = self.quantization.Pack(builder) - if self.sparsity is not None: - sparsity = self.sparsity.Pack(builder) - if self.shapeSignature is not None: - if np is not None and type(self.shapeSignature) is np.ndarray: - shapeSignature = builder.CreateNumpyVector(self.shapeSignature) - else: - TensorStartShapeSignatureVector(builder, len(self.shapeSignature)) - for i in reversed(range(len(self.shapeSignature))): - builder.PrependInt32(self.shapeSignature[i]) - shapeSignature = builder.EndVector() - if self.variantTensors is not None: - variantTensorslist = [] - for i in range(len(self.variantTensors)): - variantTensorslist.append(self.variantTensors[i].Pack(builder)) - TensorStartVariantTensorsVector(builder, len(self.variantTensors)) - for i in reversed(range(len(self.variantTensors))): - builder.PrependUOffsetTRelative(variantTensorslist[i]) - variantTensors = builder.EndVector() - TensorStart(builder) - if self.shape is not None: - TensorAddShape(builder, shape) - TensorAddType(builder, self.type) - TensorAddBuffer(builder, self.buffer) - if self.name is not None: - TensorAddName(builder, name) - if self.quantization is not None: - TensorAddQuantization(builder, quantization) - TensorAddIsVariable(builder, self.isVariable) - if self.sparsity is not None: - TensorAddSparsity(builder, sparsity) - if self.shapeSignature is not None: - TensorAddShapeSignature(builder, shapeSignature) - TensorAddHasRank(builder, self.hasRank) - if self.variantTensors is not None: - TensorAddVariantTensors(builder, variantTensors) - TensorAddExternalBuffer(builder, self.externalBuffer) - tensor = TensorEnd(builder) - return tensor - - -class StablehloGatherOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloGatherOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloGatherOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloGatherOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloGatherOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloGatherOptions - def OffsetDims(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloGatherOptions - def OffsetDimsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloGatherOptions - def OffsetDimsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloGatherOptions - def OffsetDimsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # StablehloGatherOptions - def CollapsedSliceDims(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloGatherOptions - def CollapsedSliceDimsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloGatherOptions - def CollapsedSliceDimsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloGatherOptions - def CollapsedSliceDimsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # StablehloGatherOptions - def StartIndexMap(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloGatherOptions - def StartIndexMapAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloGatherOptions - def StartIndexMapLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloGatherOptions - def StartIndexMapIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - - # StablehloGatherOptions - def IndexVectorDim(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # StablehloGatherOptions - def SliceSizes(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloGatherOptions - def SliceSizesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloGatherOptions - def SliceSizesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloGatherOptions - def SliceSizesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - return o == 0 - - # StablehloGatherOptions - def IndicesAreSorted(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def StablehloGatherOptionsStart(builder): - builder.StartObject(6) - -def StablehloGatherOptionsAddOffsetDims(builder, offsetDims): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(offsetDims), 0) - -def StablehloGatherOptionsStartOffsetDimsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloGatherOptionsAddCollapsedSliceDims(builder, collapsedSliceDims): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(collapsedSliceDims), 0) - -def StablehloGatherOptionsStartCollapsedSliceDimsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloGatherOptionsAddStartIndexMap(builder, startIndexMap): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(startIndexMap), 0) - -def StablehloGatherOptionsStartStartIndexMapVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloGatherOptionsAddIndexVectorDim(builder, indexVectorDim): - builder.PrependInt64Slot(3, indexVectorDim, 0) - -def StablehloGatherOptionsAddSliceSizes(builder, sliceSizes): - builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(sliceSizes), 0) - -def StablehloGatherOptionsStartSliceSizesVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloGatherOptionsAddIndicesAreSorted(builder, indicesAreSorted): - builder.PrependBoolSlot(5, indicesAreSorted, 0) - -def StablehloGatherOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StablehloGatherOptionsT(object): - - # StablehloGatherOptionsT - def __init__( - self, - offsetDims = None, - collapsedSliceDims = None, - startIndexMap = None, - indexVectorDim = 0, - sliceSizes = None, - indicesAreSorted = False, - ): - self.offsetDims = offsetDims # type: Optional[List[int]] - self.collapsedSliceDims = collapsedSliceDims # type: Optional[List[int]] - self.startIndexMap = startIndexMap # type: Optional[List[int]] - self.indexVectorDim = indexVectorDim # type: int - self.sliceSizes = sliceSizes # type: Optional[List[int]] - self.indicesAreSorted = indicesAreSorted # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloGatherOptions = StablehloGatherOptions() - stablehloGatherOptions.Init(buf, pos) - return cls.InitFromObj(stablehloGatherOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloGatherOptions): - x = StablehloGatherOptionsT() - x._UnPack(stablehloGatherOptions) - return x - - # StablehloGatherOptionsT - def _UnPack(self, stablehloGatherOptions): - if stablehloGatherOptions is None: - return - if not stablehloGatherOptions.OffsetDimsIsNone(): - if np is None: - self.offsetDims = [] - for i in range(stablehloGatherOptions.OffsetDimsLength()): - self.offsetDims.append(stablehloGatherOptions.OffsetDims(i)) - else: - self.offsetDims = stablehloGatherOptions.OffsetDimsAsNumpy() - if not stablehloGatherOptions.CollapsedSliceDimsIsNone(): - if np is None: - self.collapsedSliceDims = [] - for i in range(stablehloGatherOptions.CollapsedSliceDimsLength()): - self.collapsedSliceDims.append(stablehloGatherOptions.CollapsedSliceDims(i)) - else: - self.collapsedSliceDims = stablehloGatherOptions.CollapsedSliceDimsAsNumpy() - if not stablehloGatherOptions.StartIndexMapIsNone(): - if np is None: - self.startIndexMap = [] - for i in range(stablehloGatherOptions.StartIndexMapLength()): - self.startIndexMap.append(stablehloGatherOptions.StartIndexMap(i)) - else: - self.startIndexMap = stablehloGatherOptions.StartIndexMapAsNumpy() - self.indexVectorDim = stablehloGatherOptions.IndexVectorDim() - if not stablehloGatherOptions.SliceSizesIsNone(): - if np is None: - self.sliceSizes = [] - for i in range(stablehloGatherOptions.SliceSizesLength()): - self.sliceSizes.append(stablehloGatherOptions.SliceSizes(i)) - else: - self.sliceSizes = stablehloGatherOptions.SliceSizesAsNumpy() - self.indicesAreSorted = stablehloGatherOptions.IndicesAreSorted() - - # StablehloGatherOptionsT - def Pack(self, builder): - if self.offsetDims is not None: - if np is not None and type(self.offsetDims) is np.ndarray: - offsetDims = builder.CreateNumpyVector(self.offsetDims) - else: - StablehloGatherOptionsStartOffsetDimsVector(builder, len(self.offsetDims)) - for i in reversed(range(len(self.offsetDims))): - builder.PrependInt64(self.offsetDims[i]) - offsetDims = builder.EndVector() - if self.collapsedSliceDims is not None: - if np is not None and type(self.collapsedSliceDims) is np.ndarray: - collapsedSliceDims = builder.CreateNumpyVector(self.collapsedSliceDims) - else: - StablehloGatherOptionsStartCollapsedSliceDimsVector(builder, len(self.collapsedSliceDims)) - for i in reversed(range(len(self.collapsedSliceDims))): - builder.PrependInt64(self.collapsedSliceDims[i]) - collapsedSliceDims = builder.EndVector() - if self.startIndexMap is not None: - if np is not None and type(self.startIndexMap) is np.ndarray: - startIndexMap = builder.CreateNumpyVector(self.startIndexMap) - else: - StablehloGatherOptionsStartStartIndexMapVector(builder, len(self.startIndexMap)) - for i in reversed(range(len(self.startIndexMap))): - builder.PrependInt64(self.startIndexMap[i]) - startIndexMap = builder.EndVector() - if self.sliceSizes is not None: - if np is not None and type(self.sliceSizes) is np.ndarray: - sliceSizes = builder.CreateNumpyVector(self.sliceSizes) - else: - StablehloGatherOptionsStartSliceSizesVector(builder, len(self.sliceSizes)) - for i in reversed(range(len(self.sliceSizes))): - builder.PrependInt64(self.sliceSizes[i]) - sliceSizes = builder.EndVector() - StablehloGatherOptionsStart(builder) - if self.offsetDims is not None: - StablehloGatherOptionsAddOffsetDims(builder, offsetDims) - if self.collapsedSliceDims is not None: - StablehloGatherOptionsAddCollapsedSliceDims(builder, collapsedSliceDims) - if self.startIndexMap is not None: - StablehloGatherOptionsAddStartIndexMap(builder, startIndexMap) - StablehloGatherOptionsAddIndexVectorDim(builder, self.indexVectorDim) - if self.sliceSizes is not None: - StablehloGatherOptionsAddSliceSizes(builder, sliceSizes) - StablehloGatherOptionsAddIndicesAreSorted(builder, self.indicesAreSorted) - stablehloGatherOptions = StablehloGatherOptionsEnd(builder) - return stablehloGatherOptions - - -class StablehloTransposeOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloTransposeOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloTransposeOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloTransposeOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloTransposeOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloTransposeOptions - def Permutation(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloTransposeOptions - def PermutationAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloTransposeOptions - def PermutationLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloTransposeOptions - def PermutationIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - -def StablehloTransposeOptionsStart(builder): - builder.StartObject(1) - -def StablehloTransposeOptionsAddPermutation(builder, permutation): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(permutation), 0) - -def StablehloTransposeOptionsStartPermutationVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloTransposeOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StablehloTransposeOptionsT(object): - - # StablehloTransposeOptionsT - def __init__( - self, - permutation = None, - ): - self.permutation = permutation # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloTransposeOptions = StablehloTransposeOptions() - stablehloTransposeOptions.Init(buf, pos) - return cls.InitFromObj(stablehloTransposeOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloTransposeOptions): - x = StablehloTransposeOptionsT() - x._UnPack(stablehloTransposeOptions) - return x - - # StablehloTransposeOptionsT - def _UnPack(self, stablehloTransposeOptions): - if stablehloTransposeOptions is None: - return - if not stablehloTransposeOptions.PermutationIsNone(): - if np is None: - self.permutation = [] - for i in range(stablehloTransposeOptions.PermutationLength()): - self.permutation.append(stablehloTransposeOptions.Permutation(i)) - else: - self.permutation = stablehloTransposeOptions.PermutationAsNumpy() - - # StablehloTransposeOptionsT - def Pack(self, builder): - if self.permutation is not None: - if np is not None and type(self.permutation) is np.ndarray: - permutation = builder.CreateNumpyVector(self.permutation) - else: - StablehloTransposeOptionsStartPermutationVector(builder, len(self.permutation)) - for i in reversed(range(len(self.permutation))): - builder.PrependInt64(self.permutation[i]) - permutation = builder.EndVector() - StablehloTransposeOptionsStart(builder) - if self.permutation is not None: - StablehloTransposeOptionsAddPermutation(builder, permutation) - stablehloTransposeOptions = StablehloTransposeOptionsEnd(builder) - return stablehloTransposeOptions - - -class StablehloDotGeneralOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloDotGeneralOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloDotGeneralOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloDotGeneralOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloDotGeneralOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloDotGeneralOptions - def LhsBatchingDimensions(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloDotGeneralOptions - def LhsBatchingDimensionsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloDotGeneralOptions - def LhsBatchingDimensionsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloDotGeneralOptions - def LhsBatchingDimensionsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # StablehloDotGeneralOptions - def RhsBatchingDimensions(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloDotGeneralOptions - def RhsBatchingDimensionsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloDotGeneralOptions - def RhsBatchingDimensionsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloDotGeneralOptions - def RhsBatchingDimensionsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # StablehloDotGeneralOptions - def LhsContractingDimensions(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloDotGeneralOptions - def LhsContractingDimensionsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloDotGeneralOptions - def LhsContractingDimensionsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloDotGeneralOptions - def LhsContractingDimensionsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - - # StablehloDotGeneralOptions - def RhsContractingDimensions(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloDotGeneralOptions - def RhsContractingDimensionsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloDotGeneralOptions - def RhsContractingDimensionsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloDotGeneralOptions - def RhsContractingDimensionsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - return o == 0 - - # StablehloDotGeneralOptions - def PrecisionConfig(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Uint32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # StablehloDotGeneralOptions - def PrecisionConfigAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint32Flags, o) - return 0 - - # StablehloDotGeneralOptions - def PrecisionConfigLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloDotGeneralOptions - def PrecisionConfigIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - return o == 0 - -def StablehloDotGeneralOptionsStart(builder): - builder.StartObject(5) - -def StablehloDotGeneralOptionsAddLhsBatchingDimensions(builder, lhsBatchingDimensions): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(lhsBatchingDimensions), 0) - -def StablehloDotGeneralOptionsStartLhsBatchingDimensionsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloDotGeneralOptionsAddRhsBatchingDimensions(builder, rhsBatchingDimensions): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(rhsBatchingDimensions), 0) - -def StablehloDotGeneralOptionsStartRhsBatchingDimensionsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloDotGeneralOptionsAddLhsContractingDimensions(builder, lhsContractingDimensions): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(lhsContractingDimensions), 0) - -def StablehloDotGeneralOptionsStartLhsContractingDimensionsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloDotGeneralOptionsAddRhsContractingDimensions(builder, rhsContractingDimensions): - builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(rhsContractingDimensions), 0) - -def StablehloDotGeneralOptionsStartRhsContractingDimensionsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloDotGeneralOptionsAddPrecisionConfig(builder, precisionConfig): - builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(precisionConfig), 0) - -def StablehloDotGeneralOptionsStartPrecisionConfigVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def StablehloDotGeneralOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StablehloDotGeneralOptionsT(object): - - # StablehloDotGeneralOptionsT - def __init__( - self, - lhsBatchingDimensions = None, - rhsBatchingDimensions = None, - lhsContractingDimensions = None, - rhsContractingDimensions = None, - precisionConfig = None, - ): - self.lhsBatchingDimensions = lhsBatchingDimensions # type: Optional[List[int]] - self.rhsBatchingDimensions = rhsBatchingDimensions # type: Optional[List[int]] - self.lhsContractingDimensions = lhsContractingDimensions # type: Optional[List[int]] - self.rhsContractingDimensions = rhsContractingDimensions # type: Optional[List[int]] - self.precisionConfig = precisionConfig # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloDotGeneralOptions = StablehloDotGeneralOptions() - stablehloDotGeneralOptions.Init(buf, pos) - return cls.InitFromObj(stablehloDotGeneralOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloDotGeneralOptions): - x = StablehloDotGeneralOptionsT() - x._UnPack(stablehloDotGeneralOptions) - return x - - # StablehloDotGeneralOptionsT - def _UnPack(self, stablehloDotGeneralOptions): - if stablehloDotGeneralOptions is None: - return - if not stablehloDotGeneralOptions.LhsBatchingDimensionsIsNone(): - if np is None: - self.lhsBatchingDimensions = [] - for i in range(stablehloDotGeneralOptions.LhsBatchingDimensionsLength()): - self.lhsBatchingDimensions.append(stablehloDotGeneralOptions.LhsBatchingDimensions(i)) - else: - self.lhsBatchingDimensions = stablehloDotGeneralOptions.LhsBatchingDimensionsAsNumpy() - if not stablehloDotGeneralOptions.RhsBatchingDimensionsIsNone(): - if np is None: - self.rhsBatchingDimensions = [] - for i in range(stablehloDotGeneralOptions.RhsBatchingDimensionsLength()): - self.rhsBatchingDimensions.append(stablehloDotGeneralOptions.RhsBatchingDimensions(i)) - else: - self.rhsBatchingDimensions = stablehloDotGeneralOptions.RhsBatchingDimensionsAsNumpy() - if not stablehloDotGeneralOptions.LhsContractingDimensionsIsNone(): - if np is None: - self.lhsContractingDimensions = [] - for i in range(stablehloDotGeneralOptions.LhsContractingDimensionsLength()): - self.lhsContractingDimensions.append(stablehloDotGeneralOptions.LhsContractingDimensions(i)) - else: - self.lhsContractingDimensions = stablehloDotGeneralOptions.LhsContractingDimensionsAsNumpy() - if not stablehloDotGeneralOptions.RhsContractingDimensionsIsNone(): - if np is None: - self.rhsContractingDimensions = [] - for i in range(stablehloDotGeneralOptions.RhsContractingDimensionsLength()): - self.rhsContractingDimensions.append(stablehloDotGeneralOptions.RhsContractingDimensions(i)) - else: - self.rhsContractingDimensions = stablehloDotGeneralOptions.RhsContractingDimensionsAsNumpy() - if not stablehloDotGeneralOptions.PrecisionConfigIsNone(): - if np is None: - self.precisionConfig = [] - for i in range(stablehloDotGeneralOptions.PrecisionConfigLength()): - self.precisionConfig.append(stablehloDotGeneralOptions.PrecisionConfig(i)) - else: - self.precisionConfig = stablehloDotGeneralOptions.PrecisionConfigAsNumpy() - - # StablehloDotGeneralOptionsT - def Pack(self, builder): - if self.lhsBatchingDimensions is not None: - if np is not None and type(self.lhsBatchingDimensions) is np.ndarray: - lhsBatchingDimensions = builder.CreateNumpyVector(self.lhsBatchingDimensions) - else: - StablehloDotGeneralOptionsStartLhsBatchingDimensionsVector(builder, len(self.lhsBatchingDimensions)) - for i in reversed(range(len(self.lhsBatchingDimensions))): - builder.PrependInt64(self.lhsBatchingDimensions[i]) - lhsBatchingDimensions = builder.EndVector() - if self.rhsBatchingDimensions is not None: - if np is not None and type(self.rhsBatchingDimensions) is np.ndarray: - rhsBatchingDimensions = builder.CreateNumpyVector(self.rhsBatchingDimensions) - else: - StablehloDotGeneralOptionsStartRhsBatchingDimensionsVector(builder, len(self.rhsBatchingDimensions)) - for i in reversed(range(len(self.rhsBatchingDimensions))): - builder.PrependInt64(self.rhsBatchingDimensions[i]) - rhsBatchingDimensions = builder.EndVector() - if self.lhsContractingDimensions is not None: - if np is not None and type(self.lhsContractingDimensions) is np.ndarray: - lhsContractingDimensions = builder.CreateNumpyVector(self.lhsContractingDimensions) - else: - StablehloDotGeneralOptionsStartLhsContractingDimensionsVector(builder, len(self.lhsContractingDimensions)) - for i in reversed(range(len(self.lhsContractingDimensions))): - builder.PrependInt64(self.lhsContractingDimensions[i]) - lhsContractingDimensions = builder.EndVector() - if self.rhsContractingDimensions is not None: - if np is not None and type(self.rhsContractingDimensions) is np.ndarray: - rhsContractingDimensions = builder.CreateNumpyVector(self.rhsContractingDimensions) - else: - StablehloDotGeneralOptionsStartRhsContractingDimensionsVector(builder, len(self.rhsContractingDimensions)) - for i in reversed(range(len(self.rhsContractingDimensions))): - builder.PrependInt64(self.rhsContractingDimensions[i]) - rhsContractingDimensions = builder.EndVector() - if self.precisionConfig is not None: - if np is not None and type(self.precisionConfig) is np.ndarray: - precisionConfig = builder.CreateNumpyVector(self.precisionConfig) - else: - StablehloDotGeneralOptionsStartPrecisionConfigVector(builder, len(self.precisionConfig)) - for i in reversed(range(len(self.precisionConfig))): - builder.PrependUint32(self.precisionConfig[i]) - precisionConfig = builder.EndVector() - StablehloDotGeneralOptionsStart(builder) - if self.lhsBatchingDimensions is not None: - StablehloDotGeneralOptionsAddLhsBatchingDimensions(builder, lhsBatchingDimensions) - if self.rhsBatchingDimensions is not None: - StablehloDotGeneralOptionsAddRhsBatchingDimensions(builder, rhsBatchingDimensions) - if self.lhsContractingDimensions is not None: - StablehloDotGeneralOptionsAddLhsContractingDimensions(builder, lhsContractingDimensions) - if self.rhsContractingDimensions is not None: - StablehloDotGeneralOptionsAddRhsContractingDimensions(builder, rhsContractingDimensions) - if self.precisionConfig is not None: - StablehloDotGeneralOptionsAddPrecisionConfig(builder, precisionConfig) - stablehloDotGeneralOptions = StablehloDotGeneralOptionsEnd(builder) - return stablehloDotGeneralOptions - - -class StablehloReduceWindowOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloReduceWindowOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloReduceWindowOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloReduceWindowOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloReduceWindowOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloReduceWindowOptions - def WindowDimensions(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloReduceWindowOptions - def WindowDimensionsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloReduceWindowOptions - def WindowDimensionsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloReduceWindowOptions - def WindowDimensionsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # StablehloReduceWindowOptions - def WindowStrides(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloReduceWindowOptions - def WindowStridesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloReduceWindowOptions - def WindowStridesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloReduceWindowOptions - def WindowStridesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # StablehloReduceWindowOptions - def BaseDilations(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloReduceWindowOptions - def BaseDilationsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloReduceWindowOptions - def BaseDilationsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloReduceWindowOptions - def BaseDilationsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - - # StablehloReduceWindowOptions - def WindowDilations(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloReduceWindowOptions - def WindowDilationsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloReduceWindowOptions - def WindowDilationsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloReduceWindowOptions - def WindowDilationsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - return o == 0 - - # StablehloReduceWindowOptions - def Padding(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloReduceWindowOptions - def PaddingAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloReduceWindowOptions - def PaddingLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloReduceWindowOptions - def PaddingIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - return o == 0 - - # StablehloReduceWindowOptions - def BodySubgraphIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def StablehloReduceWindowOptionsStart(builder): - builder.StartObject(6) - -def StablehloReduceWindowOptionsAddWindowDimensions(builder, windowDimensions): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(windowDimensions), 0) - -def StablehloReduceWindowOptionsStartWindowDimensionsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloReduceWindowOptionsAddWindowStrides(builder, windowStrides): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(windowStrides), 0) - -def StablehloReduceWindowOptionsStartWindowStridesVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloReduceWindowOptionsAddBaseDilations(builder, baseDilations): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(baseDilations), 0) - -def StablehloReduceWindowOptionsStartBaseDilationsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloReduceWindowOptionsAddWindowDilations(builder, windowDilations): - builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(windowDilations), 0) - -def StablehloReduceWindowOptionsStartWindowDilationsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloReduceWindowOptionsAddPadding(builder, padding): - builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(padding), 0) - -def StablehloReduceWindowOptionsStartPaddingVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloReduceWindowOptionsAddBodySubgraphIndex(builder, bodySubgraphIndex): - builder.PrependInt32Slot(5, bodySubgraphIndex, 0) - -def StablehloReduceWindowOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StablehloReduceWindowOptionsT(object): - - # StablehloReduceWindowOptionsT - def __init__( - self, - windowDimensions = None, - windowStrides = None, - baseDilations = None, - windowDilations = None, - padding = None, - bodySubgraphIndex = 0, - ): - self.windowDimensions = windowDimensions # type: Optional[List[int]] - self.windowStrides = windowStrides # type: Optional[List[int]] - self.baseDilations = baseDilations # type: Optional[List[int]] - self.windowDilations = windowDilations # type: Optional[List[int]] - self.padding = padding # type: Optional[List[int]] - self.bodySubgraphIndex = bodySubgraphIndex # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloReduceWindowOptions = StablehloReduceWindowOptions() - stablehloReduceWindowOptions.Init(buf, pos) - return cls.InitFromObj(stablehloReduceWindowOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloReduceWindowOptions): - x = StablehloReduceWindowOptionsT() - x._UnPack(stablehloReduceWindowOptions) - return x - - # StablehloReduceWindowOptionsT - def _UnPack(self, stablehloReduceWindowOptions): - if stablehloReduceWindowOptions is None: - return - if not stablehloReduceWindowOptions.WindowDimensionsIsNone(): - if np is None: - self.windowDimensions = [] - for i in range(stablehloReduceWindowOptions.WindowDimensionsLength()): - self.windowDimensions.append(stablehloReduceWindowOptions.WindowDimensions(i)) - else: - self.windowDimensions = stablehloReduceWindowOptions.WindowDimensionsAsNumpy() - if not stablehloReduceWindowOptions.WindowStridesIsNone(): - if np is None: - self.windowStrides = [] - for i in range(stablehloReduceWindowOptions.WindowStridesLength()): - self.windowStrides.append(stablehloReduceWindowOptions.WindowStrides(i)) - else: - self.windowStrides = stablehloReduceWindowOptions.WindowStridesAsNumpy() - if not stablehloReduceWindowOptions.BaseDilationsIsNone(): - if np is None: - self.baseDilations = [] - for i in range(stablehloReduceWindowOptions.BaseDilationsLength()): - self.baseDilations.append(stablehloReduceWindowOptions.BaseDilations(i)) - else: - self.baseDilations = stablehloReduceWindowOptions.BaseDilationsAsNumpy() - if not stablehloReduceWindowOptions.WindowDilationsIsNone(): - if np is None: - self.windowDilations = [] - for i in range(stablehloReduceWindowOptions.WindowDilationsLength()): - self.windowDilations.append(stablehloReduceWindowOptions.WindowDilations(i)) - else: - self.windowDilations = stablehloReduceWindowOptions.WindowDilationsAsNumpy() - if not stablehloReduceWindowOptions.PaddingIsNone(): - if np is None: - self.padding = [] - for i in range(stablehloReduceWindowOptions.PaddingLength()): - self.padding.append(stablehloReduceWindowOptions.Padding(i)) - else: - self.padding = stablehloReduceWindowOptions.PaddingAsNumpy() - self.bodySubgraphIndex = stablehloReduceWindowOptions.BodySubgraphIndex() - - # StablehloReduceWindowOptionsT - def Pack(self, builder): - if self.windowDimensions is not None: - if np is not None and type(self.windowDimensions) is np.ndarray: - windowDimensions = builder.CreateNumpyVector(self.windowDimensions) - else: - StablehloReduceWindowOptionsStartWindowDimensionsVector(builder, len(self.windowDimensions)) - for i in reversed(range(len(self.windowDimensions))): - builder.PrependInt64(self.windowDimensions[i]) - windowDimensions = builder.EndVector() - if self.windowStrides is not None: - if np is not None and type(self.windowStrides) is np.ndarray: - windowStrides = builder.CreateNumpyVector(self.windowStrides) - else: - StablehloReduceWindowOptionsStartWindowStridesVector(builder, len(self.windowStrides)) - for i in reversed(range(len(self.windowStrides))): - builder.PrependInt64(self.windowStrides[i]) - windowStrides = builder.EndVector() - if self.baseDilations is not None: - if np is not None and type(self.baseDilations) is np.ndarray: - baseDilations = builder.CreateNumpyVector(self.baseDilations) - else: - StablehloReduceWindowOptionsStartBaseDilationsVector(builder, len(self.baseDilations)) - for i in reversed(range(len(self.baseDilations))): - builder.PrependInt64(self.baseDilations[i]) - baseDilations = builder.EndVector() - if self.windowDilations is not None: - if np is not None and type(self.windowDilations) is np.ndarray: - windowDilations = builder.CreateNumpyVector(self.windowDilations) - else: - StablehloReduceWindowOptionsStartWindowDilationsVector(builder, len(self.windowDilations)) - for i in reversed(range(len(self.windowDilations))): - builder.PrependInt64(self.windowDilations[i]) - windowDilations = builder.EndVector() - if self.padding is not None: - if np is not None and type(self.padding) is np.ndarray: - padding = builder.CreateNumpyVector(self.padding) - else: - StablehloReduceWindowOptionsStartPaddingVector(builder, len(self.padding)) - for i in reversed(range(len(self.padding))): - builder.PrependInt64(self.padding[i]) - padding = builder.EndVector() - StablehloReduceWindowOptionsStart(builder) - if self.windowDimensions is not None: - StablehloReduceWindowOptionsAddWindowDimensions(builder, windowDimensions) - if self.windowStrides is not None: - StablehloReduceWindowOptionsAddWindowStrides(builder, windowStrides) - if self.baseDilations is not None: - StablehloReduceWindowOptionsAddBaseDilations(builder, baseDilations) - if self.windowDilations is not None: - StablehloReduceWindowOptionsAddWindowDilations(builder, windowDilations) - if self.padding is not None: - StablehloReduceWindowOptionsAddPadding(builder, padding) - StablehloReduceWindowOptionsAddBodySubgraphIndex(builder, self.bodySubgraphIndex) - stablehloReduceWindowOptions = StablehloReduceWindowOptionsEnd(builder) - return stablehloReduceWindowOptions - - -class StablehloWhileOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloWhileOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloWhileOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloWhileOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloWhileOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloWhileOptions - def CondSubgraphIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # StablehloWhileOptions - def BodySubgraphIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def StablehloWhileOptionsStart(builder): - builder.StartObject(2) - -def StablehloWhileOptionsAddCondSubgraphIndex(builder, condSubgraphIndex): - builder.PrependInt32Slot(0, condSubgraphIndex, 0) - -def StablehloWhileOptionsAddBodySubgraphIndex(builder, bodySubgraphIndex): - builder.PrependInt32Slot(1, bodySubgraphIndex, 0) - -def StablehloWhileOptionsEnd(builder): - return builder.EndObject() - - - -class StablehloWhileOptionsT(object): - - # StablehloWhileOptionsT - def __init__( - self, - condSubgraphIndex = 0, - bodySubgraphIndex = 0, - ): - self.condSubgraphIndex = condSubgraphIndex # type: int - self.bodySubgraphIndex = bodySubgraphIndex # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloWhileOptions = StablehloWhileOptions() - stablehloWhileOptions.Init(buf, pos) - return cls.InitFromObj(stablehloWhileOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloWhileOptions): - x = StablehloWhileOptionsT() - x._UnPack(stablehloWhileOptions) - return x - - # StablehloWhileOptionsT - def _UnPack(self, stablehloWhileOptions): - if stablehloWhileOptions is None: - return - self.condSubgraphIndex = stablehloWhileOptions.CondSubgraphIndex() - self.bodySubgraphIndex = stablehloWhileOptions.BodySubgraphIndex() - - # StablehloWhileOptionsT - def Pack(self, builder): - StablehloWhileOptionsStart(builder) - StablehloWhileOptionsAddCondSubgraphIndex(builder, self.condSubgraphIndex) - StablehloWhileOptionsAddBodySubgraphIndex(builder, self.bodySubgraphIndex) - stablehloWhileOptions = StablehloWhileOptionsEnd(builder) - return stablehloWhileOptions - - -class StablehloSortOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloSortOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloSortOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloSortOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloSortOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloSortOptions - def Dimension(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # StablehloSortOptions - def IsStable(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # StablehloSortOptions - def ComparatorSubgraphIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def StablehloSortOptionsStart(builder): - builder.StartObject(3) - -def StablehloSortOptionsAddDimension(builder, dimension): - builder.PrependInt64Slot(0, dimension, 0) - -def StablehloSortOptionsAddIsStable(builder, isStable): - builder.PrependBoolSlot(1, isStable, 0) - -def StablehloSortOptionsAddComparatorSubgraphIndex(builder, comparatorSubgraphIndex): - builder.PrependInt32Slot(2, comparatorSubgraphIndex, 0) - -def StablehloSortOptionsEnd(builder): - return builder.EndObject() - - - -class StablehloSortOptionsT(object): - - # StablehloSortOptionsT - def __init__( - self, - dimension = 0, - isStable = False, - comparatorSubgraphIndex = 0, - ): - self.dimension = dimension # type: int - self.isStable = isStable # type: bool - self.comparatorSubgraphIndex = comparatorSubgraphIndex # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloSortOptions = StablehloSortOptions() - stablehloSortOptions.Init(buf, pos) - return cls.InitFromObj(stablehloSortOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloSortOptions): - x = StablehloSortOptionsT() - x._UnPack(stablehloSortOptions) - return x - - # StablehloSortOptionsT - def _UnPack(self, stablehloSortOptions): - if stablehloSortOptions is None: - return - self.dimension = stablehloSortOptions.Dimension() - self.isStable = stablehloSortOptions.IsStable() - self.comparatorSubgraphIndex = stablehloSortOptions.ComparatorSubgraphIndex() - - # StablehloSortOptionsT - def Pack(self, builder): - StablehloSortOptionsStart(builder) - StablehloSortOptionsAddDimension(builder, self.dimension) - StablehloSortOptionsAddIsStable(builder, self.isStable) - StablehloSortOptionsAddComparatorSubgraphIndex(builder, self.comparatorSubgraphIndex) - stablehloSortOptions = StablehloSortOptionsEnd(builder) - return stablehloSortOptions - - -class StablehloConcatenateOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloConcatenateOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloConcatenateOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloConcatenateOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloConcatenateOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloConcatenateOptions - def Dimension(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - -def StablehloConcatenateOptionsStart(builder): - builder.StartObject(1) - -def StablehloConcatenateOptionsAddDimension(builder, dimension): - builder.PrependInt64Slot(0, dimension, 0) - -def StablehloConcatenateOptionsEnd(builder): - return builder.EndObject() - - - -class StablehloConcatenateOptionsT(object): - - # StablehloConcatenateOptionsT - def __init__( - self, - dimension = 0, - ): - self.dimension = dimension # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloConcatenateOptions = StablehloConcatenateOptions() - stablehloConcatenateOptions.Init(buf, pos) - return cls.InitFromObj(stablehloConcatenateOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloConcatenateOptions): - x = StablehloConcatenateOptionsT() - x._UnPack(stablehloConcatenateOptions) - return x - - # StablehloConcatenateOptionsT - def _UnPack(self, stablehloConcatenateOptions): - if stablehloConcatenateOptions is None: - return - self.dimension = stablehloConcatenateOptions.Dimension() - - # StablehloConcatenateOptionsT - def Pack(self, builder): - StablehloConcatenateOptionsStart(builder) - StablehloConcatenateOptionsAddDimension(builder, self.dimension) - stablehloConcatenateOptions = StablehloConcatenateOptionsEnd(builder) - return stablehloConcatenateOptions - - -class StablehloBroadcastInDimOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloBroadcastInDimOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloBroadcastInDimOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloBroadcastInDimOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloBroadcastInDimOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloBroadcastInDimOptions - def BroadcastDimensions(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloBroadcastInDimOptions - def BroadcastDimensionsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloBroadcastInDimOptions - def BroadcastDimensionsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloBroadcastInDimOptions - def BroadcastDimensionsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - -def StablehloBroadcastInDimOptionsStart(builder): - builder.StartObject(1) - -def StablehloBroadcastInDimOptionsAddBroadcastDimensions(builder, broadcastDimensions): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(broadcastDimensions), 0) - -def StablehloBroadcastInDimOptionsStartBroadcastDimensionsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloBroadcastInDimOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StablehloBroadcastInDimOptionsT(object): - - # StablehloBroadcastInDimOptionsT - def __init__( - self, - broadcastDimensions = None, - ): - self.broadcastDimensions = broadcastDimensions # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloBroadcastInDimOptions = StablehloBroadcastInDimOptions() - stablehloBroadcastInDimOptions.Init(buf, pos) - return cls.InitFromObj(stablehloBroadcastInDimOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloBroadcastInDimOptions): - x = StablehloBroadcastInDimOptionsT() - x._UnPack(stablehloBroadcastInDimOptions) - return x - - # StablehloBroadcastInDimOptionsT - def _UnPack(self, stablehloBroadcastInDimOptions): - if stablehloBroadcastInDimOptions is None: - return - if not stablehloBroadcastInDimOptions.BroadcastDimensionsIsNone(): - if np is None: - self.broadcastDimensions = [] - for i in range(stablehloBroadcastInDimOptions.BroadcastDimensionsLength()): - self.broadcastDimensions.append(stablehloBroadcastInDimOptions.BroadcastDimensions(i)) - else: - self.broadcastDimensions = stablehloBroadcastInDimOptions.BroadcastDimensionsAsNumpy() - - # StablehloBroadcastInDimOptionsT - def Pack(self, builder): - if self.broadcastDimensions is not None: - if np is not None and type(self.broadcastDimensions) is np.ndarray: - broadcastDimensions = builder.CreateNumpyVector(self.broadcastDimensions) - else: - StablehloBroadcastInDimOptionsStartBroadcastDimensionsVector(builder, len(self.broadcastDimensions)) - for i in reversed(range(len(self.broadcastDimensions))): - builder.PrependInt64(self.broadcastDimensions[i]) - broadcastDimensions = builder.EndVector() - StablehloBroadcastInDimOptionsStart(builder) - if self.broadcastDimensions is not None: - StablehloBroadcastInDimOptionsAddBroadcastDimensions(builder, broadcastDimensions) - stablehloBroadcastInDimOptions = StablehloBroadcastInDimOptionsEnd(builder) - return stablehloBroadcastInDimOptions - - -class StablehloCompareOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloCompareOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloCompareOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloCompareOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloCompareOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloCompareOptions - def ComparisonDirection(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - - # StablehloCompareOptions - def CompareType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - -def StablehloCompareOptionsStart(builder): - builder.StartObject(2) - -def StablehloCompareOptionsAddComparisonDirection(builder, comparisonDirection): - builder.PrependUint32Slot(0, comparisonDirection, 0) - -def StablehloCompareOptionsAddCompareType(builder, compareType): - builder.PrependUint32Slot(1, compareType, 0) - -def StablehloCompareOptionsEnd(builder): - return builder.EndObject() - - - -class StablehloCompareOptionsT(object): - - # StablehloCompareOptionsT - def __init__( - self, - comparisonDirection = 0, - compareType = 0, - ): - self.comparisonDirection = comparisonDirection # type: int - self.compareType = compareType # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloCompareOptions = StablehloCompareOptions() - stablehloCompareOptions.Init(buf, pos) - return cls.InitFromObj(stablehloCompareOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloCompareOptions): - x = StablehloCompareOptionsT() - x._UnPack(stablehloCompareOptions) - return x - - # StablehloCompareOptionsT - def _UnPack(self, stablehloCompareOptions): - if stablehloCompareOptions is None: - return - self.comparisonDirection = stablehloCompareOptions.ComparisonDirection() - self.compareType = stablehloCompareOptions.CompareType() - - # StablehloCompareOptionsT - def Pack(self, builder): - StablehloCompareOptionsStart(builder) - StablehloCompareOptionsAddComparisonDirection(builder, self.comparisonDirection) - StablehloCompareOptionsAddCompareType(builder, self.compareType) - stablehloCompareOptions = StablehloCompareOptionsEnd(builder) - return stablehloCompareOptions - - -class StablehloDynamicSliceOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloDynamicSliceOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloDynamicSliceOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloDynamicSliceOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloDynamicSliceOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloDynamicSliceOptions - def SliceSizes(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloDynamicSliceOptions - def SliceSizesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloDynamicSliceOptions - def SliceSizesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloDynamicSliceOptions - def SliceSizesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - -def StablehloDynamicSliceOptionsStart(builder): - builder.StartObject(1) - -def StablehloDynamicSliceOptionsAddSliceSizes(builder, sliceSizes): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(sliceSizes), 0) - -def StablehloDynamicSliceOptionsStartSliceSizesVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloDynamicSliceOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StablehloDynamicSliceOptionsT(object): - - # StablehloDynamicSliceOptionsT - def __init__( - self, - sliceSizes = None, - ): - self.sliceSizes = sliceSizes # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloDynamicSliceOptions = StablehloDynamicSliceOptions() - stablehloDynamicSliceOptions.Init(buf, pos) - return cls.InitFromObj(stablehloDynamicSliceOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloDynamicSliceOptions): - x = StablehloDynamicSliceOptionsT() - x._UnPack(stablehloDynamicSliceOptions) - return x - - # StablehloDynamicSliceOptionsT - def _UnPack(self, stablehloDynamicSliceOptions): - if stablehloDynamicSliceOptions is None: - return - if not stablehloDynamicSliceOptions.SliceSizesIsNone(): - if np is None: - self.sliceSizes = [] - for i in range(stablehloDynamicSliceOptions.SliceSizesLength()): - self.sliceSizes.append(stablehloDynamicSliceOptions.SliceSizes(i)) - else: - self.sliceSizes = stablehloDynamicSliceOptions.SliceSizesAsNumpy() - - # StablehloDynamicSliceOptionsT - def Pack(self, builder): - if self.sliceSizes is not None: - if np is not None and type(self.sliceSizes) is np.ndarray: - sliceSizes = builder.CreateNumpyVector(self.sliceSizes) - else: - StablehloDynamicSliceOptionsStartSliceSizesVector(builder, len(self.sliceSizes)) - for i in reversed(range(len(self.sliceSizes))): - builder.PrependInt64(self.sliceSizes[i]) - sliceSizes = builder.EndVector() - StablehloDynamicSliceOptionsStart(builder) - if self.sliceSizes is not None: - StablehloDynamicSliceOptionsAddSliceSizes(builder, sliceSizes) - stablehloDynamicSliceOptions = StablehloDynamicSliceOptionsEnd(builder) - return stablehloDynamicSliceOptions - - -class StablehloPadOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloPadOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloPadOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloPadOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloPadOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloPadOptions - def EdgePaddingLow(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloPadOptions - def EdgePaddingLowAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloPadOptions - def EdgePaddingLowLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloPadOptions - def EdgePaddingLowIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # StablehloPadOptions - def EdgePaddingHigh(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloPadOptions - def EdgePaddingHighAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloPadOptions - def EdgePaddingHighLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloPadOptions - def EdgePaddingHighIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # StablehloPadOptions - def InteriorPadding(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloPadOptions - def InteriorPaddingAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloPadOptions - def InteriorPaddingLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloPadOptions - def InteriorPaddingIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - -def StablehloPadOptionsStart(builder): - builder.StartObject(3) - -def StablehloPadOptionsAddEdgePaddingLow(builder, edgePaddingLow): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(edgePaddingLow), 0) - -def StablehloPadOptionsStartEdgePaddingLowVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloPadOptionsAddEdgePaddingHigh(builder, edgePaddingHigh): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(edgePaddingHigh), 0) - -def StablehloPadOptionsStartEdgePaddingHighVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloPadOptionsAddInteriorPadding(builder, interiorPadding): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(interiorPadding), 0) - -def StablehloPadOptionsStartInteriorPaddingVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloPadOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StablehloPadOptionsT(object): - - # StablehloPadOptionsT - def __init__( - self, - edgePaddingLow = None, - edgePaddingHigh = None, - interiorPadding = None, - ): - self.edgePaddingLow = edgePaddingLow # type: Optional[List[int]] - self.edgePaddingHigh = edgePaddingHigh # type: Optional[List[int]] - self.interiorPadding = interiorPadding # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloPadOptions = StablehloPadOptions() - stablehloPadOptions.Init(buf, pos) - return cls.InitFromObj(stablehloPadOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloPadOptions): - x = StablehloPadOptionsT() - x._UnPack(stablehloPadOptions) - return x - - # StablehloPadOptionsT - def _UnPack(self, stablehloPadOptions): - if stablehloPadOptions is None: - return - if not stablehloPadOptions.EdgePaddingLowIsNone(): - if np is None: - self.edgePaddingLow = [] - for i in range(stablehloPadOptions.EdgePaddingLowLength()): - self.edgePaddingLow.append(stablehloPadOptions.EdgePaddingLow(i)) - else: - self.edgePaddingLow = stablehloPadOptions.EdgePaddingLowAsNumpy() - if not stablehloPadOptions.EdgePaddingHighIsNone(): - if np is None: - self.edgePaddingHigh = [] - for i in range(stablehloPadOptions.EdgePaddingHighLength()): - self.edgePaddingHigh.append(stablehloPadOptions.EdgePaddingHigh(i)) - else: - self.edgePaddingHigh = stablehloPadOptions.EdgePaddingHighAsNumpy() - if not stablehloPadOptions.InteriorPaddingIsNone(): - if np is None: - self.interiorPadding = [] - for i in range(stablehloPadOptions.InteriorPaddingLength()): - self.interiorPadding.append(stablehloPadOptions.InteriorPadding(i)) - else: - self.interiorPadding = stablehloPadOptions.InteriorPaddingAsNumpy() - - # StablehloPadOptionsT - def Pack(self, builder): - if self.edgePaddingLow is not None: - if np is not None and type(self.edgePaddingLow) is np.ndarray: - edgePaddingLow = builder.CreateNumpyVector(self.edgePaddingLow) - else: - StablehloPadOptionsStartEdgePaddingLowVector(builder, len(self.edgePaddingLow)) - for i in reversed(range(len(self.edgePaddingLow))): - builder.PrependInt64(self.edgePaddingLow[i]) - edgePaddingLow = builder.EndVector() - if self.edgePaddingHigh is not None: - if np is not None and type(self.edgePaddingHigh) is np.ndarray: - edgePaddingHigh = builder.CreateNumpyVector(self.edgePaddingHigh) - else: - StablehloPadOptionsStartEdgePaddingHighVector(builder, len(self.edgePaddingHigh)) - for i in reversed(range(len(self.edgePaddingHigh))): - builder.PrependInt64(self.edgePaddingHigh[i]) - edgePaddingHigh = builder.EndVector() - if self.interiorPadding is not None: - if np is not None and type(self.interiorPadding) is np.ndarray: - interiorPadding = builder.CreateNumpyVector(self.interiorPadding) - else: - StablehloPadOptionsStartInteriorPaddingVector(builder, len(self.interiorPadding)) - for i in reversed(range(len(self.interiorPadding))): - builder.PrependInt64(self.interiorPadding[i]) - interiorPadding = builder.EndVector() - StablehloPadOptionsStart(builder) - if self.edgePaddingLow is not None: - StablehloPadOptionsAddEdgePaddingLow(builder, edgePaddingLow) - if self.edgePaddingHigh is not None: - StablehloPadOptionsAddEdgePaddingHigh(builder, edgePaddingHigh) - if self.interiorPadding is not None: - StablehloPadOptionsAddInteriorPadding(builder, interiorPadding) - stablehloPadOptions = StablehloPadOptionsEnd(builder) - return stablehloPadOptions - - -class StablehloIotaOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloIotaOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloIotaOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloIotaOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloIotaOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloIotaOptions - def IotaDimension(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - -def StablehloIotaOptionsStart(builder): - builder.StartObject(1) - -def StablehloIotaOptionsAddIotaDimension(builder, iotaDimension): - builder.PrependInt64Slot(0, iotaDimension, 0) - -def StablehloIotaOptionsEnd(builder): - return builder.EndObject() - - - -class StablehloIotaOptionsT(object): - - # StablehloIotaOptionsT - def __init__( - self, - iotaDimension = 0, - ): - self.iotaDimension = iotaDimension # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloIotaOptions = StablehloIotaOptions() - stablehloIotaOptions.Init(buf, pos) - return cls.InitFromObj(stablehloIotaOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloIotaOptions): - x = StablehloIotaOptionsT() - x._UnPack(stablehloIotaOptions) - return x - - # StablehloIotaOptionsT - def _UnPack(self, stablehloIotaOptions): - if stablehloIotaOptions is None: - return - self.iotaDimension = stablehloIotaOptions.IotaDimension() - - # StablehloIotaOptionsT - def Pack(self, builder): - StablehloIotaOptionsStart(builder) - StablehloIotaOptionsAddIotaDimension(builder, self.iotaDimension) - stablehloIotaOptions = StablehloIotaOptionsEnd(builder) - return stablehloIotaOptions - - -class StablehloCustomCallOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloCustomCallOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloCustomCallOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloCustomCallOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloCustomCallOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloCustomCallOptions - def CallTargetName(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - - # StablehloCustomCallOptions - def HasSideEffect(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # StablehloCustomCallOptions - def BackendConfig(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - - # StablehloCustomCallOptions - def ApiVersion(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # StablehloCustomCallOptions - def CalledComputations(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # StablehloCustomCallOptions - def CalledComputationsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # StablehloCustomCallOptions - def CalledComputationsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloCustomCallOptions - def CalledComputationsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - return o == 0 - - # StablehloCustomCallOptions - def CustomAttributes(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) - return 0 - - # StablehloCustomCallOptions - def CustomAttributesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o) - return 0 - - # StablehloCustomCallOptions - def CustomAttributesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloCustomCallOptions - def CustomAttributesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - return o == 0 - -def StablehloCustomCallOptionsStart(builder): - builder.StartObject(6) - -def StablehloCustomCallOptionsAddCallTargetName(builder, callTargetName): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(callTargetName), 0) - -def StablehloCustomCallOptionsAddHasSideEffect(builder, hasSideEffect): - builder.PrependBoolSlot(1, hasSideEffect, 0) - -def StablehloCustomCallOptionsAddBackendConfig(builder, backendConfig): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(backendConfig), 0) - -def StablehloCustomCallOptionsAddApiVersion(builder, apiVersion): - builder.PrependInt32Slot(3, apiVersion, 0) - -def StablehloCustomCallOptionsAddCalledComputations(builder, calledComputations): - builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(calledComputations), 0) - -def StablehloCustomCallOptionsStartCalledComputationsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def StablehloCustomCallOptionsAddCustomAttributes(builder, customAttributes): - builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(customAttributes), 0) - -def StablehloCustomCallOptionsStartCustomAttributesVector(builder, numElems): - return builder.StartVector(1, numElems, 1) - -def StablehloCustomCallOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StablehloCustomCallOptionsT(object): - - # StablehloCustomCallOptionsT - def __init__( - self, - callTargetName = None, - hasSideEffect = False, - backendConfig = None, - apiVersion = 0, - calledComputations = None, - customAttributes = None, - ): - self.callTargetName = callTargetName # type: Optional[str] - self.hasSideEffect = hasSideEffect # type: bool - self.backendConfig = backendConfig # type: Optional[str] - self.apiVersion = apiVersion # type: int - self.calledComputations = calledComputations # type: Optional[List[int]] - self.customAttributes = customAttributes # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloCustomCallOptions = StablehloCustomCallOptions() - stablehloCustomCallOptions.Init(buf, pos) - return cls.InitFromObj(stablehloCustomCallOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloCustomCallOptions): - x = StablehloCustomCallOptionsT() - x._UnPack(stablehloCustomCallOptions) - return x - - # StablehloCustomCallOptionsT - def _UnPack(self, stablehloCustomCallOptions): - if stablehloCustomCallOptions is None: - return - self.callTargetName = stablehloCustomCallOptions.CallTargetName() - self.hasSideEffect = stablehloCustomCallOptions.HasSideEffect() - self.backendConfig = stablehloCustomCallOptions.BackendConfig() - self.apiVersion = stablehloCustomCallOptions.ApiVersion() - if not stablehloCustomCallOptions.CalledComputationsIsNone(): - if np is None: - self.calledComputations = [] - for i in range(stablehloCustomCallOptions.CalledComputationsLength()): - self.calledComputations.append(stablehloCustomCallOptions.CalledComputations(i)) - else: - self.calledComputations = stablehloCustomCallOptions.CalledComputationsAsNumpy() - if not stablehloCustomCallOptions.CustomAttributesIsNone(): - if np is None: - self.customAttributes = [] - for i in range(stablehloCustomCallOptions.CustomAttributesLength()): - self.customAttributes.append(stablehloCustomCallOptions.CustomAttributes(i)) - else: - self.customAttributes = stablehloCustomCallOptions.CustomAttributesAsNumpy() - - # StablehloCustomCallOptionsT - def Pack(self, builder): - if self.callTargetName is not None: - callTargetName = builder.CreateString(self.callTargetName) - if self.backendConfig is not None: - backendConfig = builder.CreateString(self.backendConfig) - if self.calledComputations is not None: - if np is not None and type(self.calledComputations) is np.ndarray: - calledComputations = builder.CreateNumpyVector(self.calledComputations) - else: - StablehloCustomCallOptionsStartCalledComputationsVector(builder, len(self.calledComputations)) - for i in reversed(range(len(self.calledComputations))): - builder.PrependInt32(self.calledComputations[i]) - calledComputations = builder.EndVector() - if self.customAttributes is not None: - if np is not None and type(self.customAttributes) is np.ndarray: - customAttributes = builder.CreateNumpyVector(self.customAttributes) - else: - StablehloCustomCallOptionsStartCustomAttributesVector(builder, len(self.customAttributes)) - for i in reversed(range(len(self.customAttributes))): - builder.PrependUint8(self.customAttributes[i]) - customAttributes = builder.EndVector() - StablehloCustomCallOptionsStart(builder) - if self.callTargetName is not None: - StablehloCustomCallOptionsAddCallTargetName(builder, callTargetName) - StablehloCustomCallOptionsAddHasSideEffect(builder, self.hasSideEffect) - if self.backendConfig is not None: - StablehloCustomCallOptionsAddBackendConfig(builder, backendConfig) - StablehloCustomCallOptionsAddApiVersion(builder, self.apiVersion) - if self.calledComputations is not None: - StablehloCustomCallOptionsAddCalledComputations(builder, calledComputations) - if self.customAttributes is not None: - StablehloCustomCallOptionsAddCustomAttributes(builder, customAttributes) - stablehloCustomCallOptions = StablehloCustomCallOptionsEnd(builder) - return stablehloCustomCallOptions - - -class StablehloReduceOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloReduceOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloReduceOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloReduceOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloReduceOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloReduceOptions - def Dimensions(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloReduceOptions - def DimensionsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloReduceOptions - def DimensionsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloReduceOptions - def DimensionsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # StablehloReduceOptions - def BodySubgraphIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def StablehloReduceOptionsStart(builder): - builder.StartObject(2) - -def StablehloReduceOptionsAddDimensions(builder, dimensions): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(dimensions), 0) - -def StablehloReduceOptionsStartDimensionsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloReduceOptionsAddBodySubgraphIndex(builder, bodySubgraphIndex): - builder.PrependInt32Slot(1, bodySubgraphIndex, 0) - -def StablehloReduceOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StablehloReduceOptionsT(object): - - # StablehloReduceOptionsT - def __init__( - self, - dimensions = None, - bodySubgraphIndex = 0, - ): - self.dimensions = dimensions # type: Optional[List[int]] - self.bodySubgraphIndex = bodySubgraphIndex # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloReduceOptions = StablehloReduceOptions() - stablehloReduceOptions.Init(buf, pos) - return cls.InitFromObj(stablehloReduceOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloReduceOptions): - x = StablehloReduceOptionsT() - x._UnPack(stablehloReduceOptions) - return x - - # StablehloReduceOptionsT - def _UnPack(self, stablehloReduceOptions): - if stablehloReduceOptions is None: - return - if not stablehloReduceOptions.DimensionsIsNone(): - if np is None: - self.dimensions = [] - for i in range(stablehloReduceOptions.DimensionsLength()): - self.dimensions.append(stablehloReduceOptions.Dimensions(i)) - else: - self.dimensions = stablehloReduceOptions.DimensionsAsNumpy() - self.bodySubgraphIndex = stablehloReduceOptions.BodySubgraphIndex() - - # StablehloReduceOptionsT - def Pack(self, builder): - if self.dimensions is not None: - if np is not None and type(self.dimensions) is np.ndarray: - dimensions = builder.CreateNumpyVector(self.dimensions) - else: - StablehloReduceOptionsStartDimensionsVector(builder, len(self.dimensions)) - for i in reversed(range(len(self.dimensions))): - builder.PrependInt64(self.dimensions[i]) - dimensions = builder.EndVector() - StablehloReduceOptionsStart(builder) - if self.dimensions is not None: - StablehloReduceOptionsAddDimensions(builder, dimensions) - StablehloReduceOptionsAddBodySubgraphIndex(builder, self.bodySubgraphIndex) - stablehloReduceOptions = StablehloReduceOptionsEnd(builder) - return stablehloReduceOptions - - -class StablehloSliceOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloSliceOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloSliceOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloSliceOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloSliceOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloSliceOptions - def StartIndices(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloSliceOptions - def StartIndicesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloSliceOptions - def StartIndicesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloSliceOptions - def StartIndicesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # StablehloSliceOptions - def LimitIndices(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloSliceOptions - def LimitIndicesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloSliceOptions - def LimitIndicesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloSliceOptions - def LimitIndicesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # StablehloSliceOptions - def Strides(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloSliceOptions - def StridesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloSliceOptions - def StridesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloSliceOptions - def StridesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - -def StablehloSliceOptionsStart(builder): - builder.StartObject(3) - -def StablehloSliceOptionsAddStartIndices(builder, startIndices): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(startIndices), 0) - -def StablehloSliceOptionsStartStartIndicesVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloSliceOptionsAddLimitIndices(builder, limitIndices): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(limitIndices), 0) - -def StablehloSliceOptionsStartLimitIndicesVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloSliceOptionsAddStrides(builder, strides): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(strides), 0) - -def StablehloSliceOptionsStartStridesVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloSliceOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StablehloSliceOptionsT(object): - - # StablehloSliceOptionsT - def __init__( - self, - startIndices = None, - limitIndices = None, - strides = None, - ): - self.startIndices = startIndices # type: Optional[List[int]] - self.limitIndices = limitIndices # type: Optional[List[int]] - self.strides = strides # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloSliceOptions = StablehloSliceOptions() - stablehloSliceOptions.Init(buf, pos) - return cls.InitFromObj(stablehloSliceOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloSliceOptions): - x = StablehloSliceOptionsT() - x._UnPack(stablehloSliceOptions) - return x - - # StablehloSliceOptionsT - def _UnPack(self, stablehloSliceOptions): - if stablehloSliceOptions is None: - return - if not stablehloSliceOptions.StartIndicesIsNone(): - if np is None: - self.startIndices = [] - for i in range(stablehloSliceOptions.StartIndicesLength()): - self.startIndices.append(stablehloSliceOptions.StartIndices(i)) - else: - self.startIndices = stablehloSliceOptions.StartIndicesAsNumpy() - if not stablehloSliceOptions.LimitIndicesIsNone(): - if np is None: - self.limitIndices = [] - for i in range(stablehloSliceOptions.LimitIndicesLength()): - self.limitIndices.append(stablehloSliceOptions.LimitIndices(i)) - else: - self.limitIndices = stablehloSliceOptions.LimitIndicesAsNumpy() - if not stablehloSliceOptions.StridesIsNone(): - if np is None: - self.strides = [] - for i in range(stablehloSliceOptions.StridesLength()): - self.strides.append(stablehloSliceOptions.Strides(i)) - else: - self.strides = stablehloSliceOptions.StridesAsNumpy() - - # StablehloSliceOptionsT - def Pack(self, builder): - if self.startIndices is not None: - if np is not None and type(self.startIndices) is np.ndarray: - startIndices = builder.CreateNumpyVector(self.startIndices) - else: - StablehloSliceOptionsStartStartIndicesVector(builder, len(self.startIndices)) - for i in reversed(range(len(self.startIndices))): - builder.PrependInt64(self.startIndices[i]) - startIndices = builder.EndVector() - if self.limitIndices is not None: - if np is not None and type(self.limitIndices) is np.ndarray: - limitIndices = builder.CreateNumpyVector(self.limitIndices) - else: - StablehloSliceOptionsStartLimitIndicesVector(builder, len(self.limitIndices)) - for i in reversed(range(len(self.limitIndices))): - builder.PrependInt64(self.limitIndices[i]) - limitIndices = builder.EndVector() - if self.strides is not None: - if np is not None and type(self.strides) is np.ndarray: - strides = builder.CreateNumpyVector(self.strides) - else: - StablehloSliceOptionsStartStridesVector(builder, len(self.strides)) - for i in reversed(range(len(self.strides))): - builder.PrependInt64(self.strides[i]) - strides = builder.EndVector() - StablehloSliceOptionsStart(builder) - if self.startIndices is not None: - StablehloSliceOptionsAddStartIndices(builder, startIndices) - if self.limitIndices is not None: - StablehloSliceOptionsAddLimitIndices(builder, limitIndices) - if self.strides is not None: - StablehloSliceOptionsAddStrides(builder, strides) - stablehloSliceOptions = StablehloSliceOptionsEnd(builder) - return stablehloSliceOptions - - -class StablehloConvolutionOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloConvolutionOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloConvolutionOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloConvolutionOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloConvolutionOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloConvolutionOptions - def WindowStrides(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloConvolutionOptions - def WindowStridesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloConvolutionOptions - def WindowStridesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloConvolutionOptions - def WindowStridesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # StablehloConvolutionOptions - def Padding(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloConvolutionOptions - def PaddingAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloConvolutionOptions - def PaddingLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloConvolutionOptions - def PaddingIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # StablehloConvolutionOptions - def LhsDilation(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloConvolutionOptions - def LhsDilationAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloConvolutionOptions - def LhsDilationLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloConvolutionOptions - def LhsDilationIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - - # StablehloConvolutionOptions - def RhsDilation(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloConvolutionOptions - def RhsDilationAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloConvolutionOptions - def RhsDilationLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloConvolutionOptions - def RhsDilationIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - return o == 0 - - # StablehloConvolutionOptions - def WindowReversal(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.BoolFlags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) - return 0 - - # StablehloConvolutionOptions - def WindowReversalAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.BoolFlags, o) - return 0 - - # StablehloConvolutionOptions - def WindowReversalLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloConvolutionOptions - def WindowReversalIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - return o == 0 - - # StablehloConvolutionOptions - def InputBatchDimension(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # StablehloConvolutionOptions - def InputFeatureDimension(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # StablehloConvolutionOptions - def InputSpatialDimensions(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloConvolutionOptions - def InputSpatialDimensionsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloConvolutionOptions - def InputSpatialDimensionsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloConvolutionOptions - def InputSpatialDimensionsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - return o == 0 - - # StablehloConvolutionOptions - def KernelInputFeatureDimension(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # StablehloConvolutionOptions - def KernelOutputFeatureDimension(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # StablehloConvolutionOptions - def KernelSpatialDimensions(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloConvolutionOptions - def KernelSpatialDimensionsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloConvolutionOptions - def KernelSpatialDimensionsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloConvolutionOptions - def KernelSpatialDimensionsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24)) - return o == 0 - - # StablehloConvolutionOptions - def OutputBatchDimension(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # StablehloConvolutionOptions - def OutputFeatureDimension(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # StablehloConvolutionOptions - def OutputSpatialDimensions(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloConvolutionOptions - def OutputSpatialDimensionsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloConvolutionOptions - def OutputSpatialDimensionsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloConvolutionOptions - def OutputSpatialDimensionsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30)) - return o == 0 - - # StablehloConvolutionOptions - def FeatureGroupCount(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(32)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # StablehloConvolutionOptions - def BatchGroupCount(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(34)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # StablehloConvolutionOptions - def PrecisionConfig(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(36)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Uint32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # StablehloConvolutionOptions - def PrecisionConfigAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(36)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint32Flags, o) - return 0 - - # StablehloConvolutionOptions - def PrecisionConfigLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(36)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloConvolutionOptions - def PrecisionConfigIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(36)) - return o == 0 - -def StablehloConvolutionOptionsStart(builder): - builder.StartObject(17) - -def StablehloConvolutionOptionsAddWindowStrides(builder, windowStrides): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(windowStrides), 0) - -def StablehloConvolutionOptionsStartWindowStridesVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloConvolutionOptionsAddPadding(builder, padding): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(padding), 0) - -def StablehloConvolutionOptionsStartPaddingVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloConvolutionOptionsAddLhsDilation(builder, lhsDilation): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(lhsDilation), 0) - -def StablehloConvolutionOptionsStartLhsDilationVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloConvolutionOptionsAddRhsDilation(builder, rhsDilation): - builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(rhsDilation), 0) - -def StablehloConvolutionOptionsStartRhsDilationVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloConvolutionOptionsAddWindowReversal(builder, windowReversal): - builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(windowReversal), 0) - -def StablehloConvolutionOptionsStartWindowReversalVector(builder, numElems): - return builder.StartVector(1, numElems, 1) - -def StablehloConvolutionOptionsAddInputBatchDimension(builder, inputBatchDimension): - builder.PrependInt64Slot(5, inputBatchDimension, 0) - -def StablehloConvolutionOptionsAddInputFeatureDimension(builder, inputFeatureDimension): - builder.PrependInt64Slot(6, inputFeatureDimension, 0) - -def StablehloConvolutionOptionsAddInputSpatialDimensions(builder, inputSpatialDimensions): - builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(inputSpatialDimensions), 0) - -def StablehloConvolutionOptionsStartInputSpatialDimensionsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloConvolutionOptionsAddKernelInputFeatureDimension(builder, kernelInputFeatureDimension): - builder.PrependInt64Slot(8, kernelInputFeatureDimension, 0) - -def StablehloConvolutionOptionsAddKernelOutputFeatureDimension(builder, kernelOutputFeatureDimension): - builder.PrependInt64Slot(9, kernelOutputFeatureDimension, 0) - -def StablehloConvolutionOptionsAddKernelSpatialDimensions(builder, kernelSpatialDimensions): - builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(kernelSpatialDimensions), 0) - -def StablehloConvolutionOptionsStartKernelSpatialDimensionsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloConvolutionOptionsAddOutputBatchDimension(builder, outputBatchDimension): - builder.PrependInt64Slot(11, outputBatchDimension, 0) - -def StablehloConvolutionOptionsAddOutputFeatureDimension(builder, outputFeatureDimension): - builder.PrependInt64Slot(12, outputFeatureDimension, 0) - -def StablehloConvolutionOptionsAddOutputSpatialDimensions(builder, outputSpatialDimensions): - builder.PrependUOffsetTRelativeSlot(13, flatbuffers.number_types.UOffsetTFlags.py_type(outputSpatialDimensions), 0) - -def StablehloConvolutionOptionsStartOutputSpatialDimensionsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloConvolutionOptionsAddFeatureGroupCount(builder, featureGroupCount): - builder.PrependInt64Slot(14, featureGroupCount, 0) - -def StablehloConvolutionOptionsAddBatchGroupCount(builder, batchGroupCount): - builder.PrependInt64Slot(15, batchGroupCount, 0) - -def StablehloConvolutionOptionsAddPrecisionConfig(builder, precisionConfig): - builder.PrependUOffsetTRelativeSlot(16, flatbuffers.number_types.UOffsetTFlags.py_type(precisionConfig), 0) - -def StablehloConvolutionOptionsStartPrecisionConfigVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def StablehloConvolutionOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StablehloConvolutionOptionsT(object): - - # StablehloConvolutionOptionsT - def __init__( - self, - windowStrides = None, - padding = None, - lhsDilation = None, - rhsDilation = None, - windowReversal = None, - inputBatchDimension = 0, - inputFeatureDimension = 0, - inputSpatialDimensions = None, - kernelInputFeatureDimension = 0, - kernelOutputFeatureDimension = 0, - kernelSpatialDimensions = None, - outputBatchDimension = 0, - outputFeatureDimension = 0, - outputSpatialDimensions = None, - featureGroupCount = 0, - batchGroupCount = 0, - precisionConfig = None, - ): - self.windowStrides = windowStrides # type: Optional[List[int]] - self.padding = padding # type: Optional[List[int]] - self.lhsDilation = lhsDilation # type: Optional[List[int]] - self.rhsDilation = rhsDilation # type: Optional[List[int]] - self.windowReversal = windowReversal # type: Optional[List[bool]] - self.inputBatchDimension = inputBatchDimension # type: int - self.inputFeatureDimension = inputFeatureDimension # type: int - self.inputSpatialDimensions = inputSpatialDimensions # type: Optional[List[int]] - self.kernelInputFeatureDimension = kernelInputFeatureDimension # type: int - self.kernelOutputFeatureDimension = kernelOutputFeatureDimension # type: int - self.kernelSpatialDimensions = kernelSpatialDimensions # type: Optional[List[int]] - self.outputBatchDimension = outputBatchDimension # type: int - self.outputFeatureDimension = outputFeatureDimension # type: int - self.outputSpatialDimensions = outputSpatialDimensions # type: Optional[List[int]] - self.featureGroupCount = featureGroupCount # type: int - self.batchGroupCount = batchGroupCount # type: int - self.precisionConfig = precisionConfig # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloConvolutionOptions = StablehloConvolutionOptions() - stablehloConvolutionOptions.Init(buf, pos) - return cls.InitFromObj(stablehloConvolutionOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloConvolutionOptions): - x = StablehloConvolutionOptionsT() - x._UnPack(stablehloConvolutionOptions) - return x - - # StablehloConvolutionOptionsT - def _UnPack(self, stablehloConvolutionOptions): - if stablehloConvolutionOptions is None: - return - if not stablehloConvolutionOptions.WindowStridesIsNone(): - if np is None: - self.windowStrides = [] - for i in range(stablehloConvolutionOptions.WindowStridesLength()): - self.windowStrides.append(stablehloConvolutionOptions.WindowStrides(i)) - else: - self.windowStrides = stablehloConvolutionOptions.WindowStridesAsNumpy() - if not stablehloConvolutionOptions.PaddingIsNone(): - if np is None: - self.padding = [] - for i in range(stablehloConvolutionOptions.PaddingLength()): - self.padding.append(stablehloConvolutionOptions.Padding(i)) - else: - self.padding = stablehloConvolutionOptions.PaddingAsNumpy() - if not stablehloConvolutionOptions.LhsDilationIsNone(): - if np is None: - self.lhsDilation = [] - for i in range(stablehloConvolutionOptions.LhsDilationLength()): - self.lhsDilation.append(stablehloConvolutionOptions.LhsDilation(i)) - else: - self.lhsDilation = stablehloConvolutionOptions.LhsDilationAsNumpy() - if not stablehloConvolutionOptions.RhsDilationIsNone(): - if np is None: - self.rhsDilation = [] - for i in range(stablehloConvolutionOptions.RhsDilationLength()): - self.rhsDilation.append(stablehloConvolutionOptions.RhsDilation(i)) - else: - self.rhsDilation = stablehloConvolutionOptions.RhsDilationAsNumpy() - if not stablehloConvolutionOptions.WindowReversalIsNone(): - if np is None: - self.windowReversal = [] - for i in range(stablehloConvolutionOptions.WindowReversalLength()): - self.windowReversal.append(stablehloConvolutionOptions.WindowReversal(i)) - else: - self.windowReversal = stablehloConvolutionOptions.WindowReversalAsNumpy() - self.inputBatchDimension = stablehloConvolutionOptions.InputBatchDimension() - self.inputFeatureDimension = stablehloConvolutionOptions.InputFeatureDimension() - if not stablehloConvolutionOptions.InputSpatialDimensionsIsNone(): - if np is None: - self.inputSpatialDimensions = [] - for i in range(stablehloConvolutionOptions.InputSpatialDimensionsLength()): - self.inputSpatialDimensions.append(stablehloConvolutionOptions.InputSpatialDimensions(i)) - else: - self.inputSpatialDimensions = stablehloConvolutionOptions.InputSpatialDimensionsAsNumpy() - self.kernelInputFeatureDimension = stablehloConvolutionOptions.KernelInputFeatureDimension() - self.kernelOutputFeatureDimension = stablehloConvolutionOptions.KernelOutputFeatureDimension() - if not stablehloConvolutionOptions.KernelSpatialDimensionsIsNone(): - if np is None: - self.kernelSpatialDimensions = [] - for i in range(stablehloConvolutionOptions.KernelSpatialDimensionsLength()): - self.kernelSpatialDimensions.append(stablehloConvolutionOptions.KernelSpatialDimensions(i)) - else: - self.kernelSpatialDimensions = stablehloConvolutionOptions.KernelSpatialDimensionsAsNumpy() - self.outputBatchDimension = stablehloConvolutionOptions.OutputBatchDimension() - self.outputFeatureDimension = stablehloConvolutionOptions.OutputFeatureDimension() - if not stablehloConvolutionOptions.OutputSpatialDimensionsIsNone(): - if np is None: - self.outputSpatialDimensions = [] - for i in range(stablehloConvolutionOptions.OutputSpatialDimensionsLength()): - self.outputSpatialDimensions.append(stablehloConvolutionOptions.OutputSpatialDimensions(i)) - else: - self.outputSpatialDimensions = stablehloConvolutionOptions.OutputSpatialDimensionsAsNumpy() - self.featureGroupCount = stablehloConvolutionOptions.FeatureGroupCount() - self.batchGroupCount = stablehloConvolutionOptions.BatchGroupCount() - if not stablehloConvolutionOptions.PrecisionConfigIsNone(): - if np is None: - self.precisionConfig = [] - for i in range(stablehloConvolutionOptions.PrecisionConfigLength()): - self.precisionConfig.append(stablehloConvolutionOptions.PrecisionConfig(i)) - else: - self.precisionConfig = stablehloConvolutionOptions.PrecisionConfigAsNumpy() - - # StablehloConvolutionOptionsT - def Pack(self, builder): - if self.windowStrides is not None: - if np is not None and type(self.windowStrides) is np.ndarray: - windowStrides = builder.CreateNumpyVector(self.windowStrides) - else: - StablehloConvolutionOptionsStartWindowStridesVector(builder, len(self.windowStrides)) - for i in reversed(range(len(self.windowStrides))): - builder.PrependInt64(self.windowStrides[i]) - windowStrides = builder.EndVector() - if self.padding is not None: - if np is not None and type(self.padding) is np.ndarray: - padding = builder.CreateNumpyVector(self.padding) - else: - StablehloConvolutionOptionsStartPaddingVector(builder, len(self.padding)) - for i in reversed(range(len(self.padding))): - builder.PrependInt64(self.padding[i]) - padding = builder.EndVector() - if self.lhsDilation is not None: - if np is not None and type(self.lhsDilation) is np.ndarray: - lhsDilation = builder.CreateNumpyVector(self.lhsDilation) - else: - StablehloConvolutionOptionsStartLhsDilationVector(builder, len(self.lhsDilation)) - for i in reversed(range(len(self.lhsDilation))): - builder.PrependInt64(self.lhsDilation[i]) - lhsDilation = builder.EndVector() - if self.rhsDilation is not None: - if np is not None and type(self.rhsDilation) is np.ndarray: - rhsDilation = builder.CreateNumpyVector(self.rhsDilation) - else: - StablehloConvolutionOptionsStartRhsDilationVector(builder, len(self.rhsDilation)) - for i in reversed(range(len(self.rhsDilation))): - builder.PrependInt64(self.rhsDilation[i]) - rhsDilation = builder.EndVector() - if self.windowReversal is not None: - if np is not None and type(self.windowReversal) is np.ndarray: - windowReversal = builder.CreateNumpyVector(self.windowReversal) - else: - StablehloConvolutionOptionsStartWindowReversalVector(builder, len(self.windowReversal)) - for i in reversed(range(len(self.windowReversal))): - builder.PrependBool(self.windowReversal[i]) - windowReversal = builder.EndVector() - if self.inputSpatialDimensions is not None: - if np is not None and type(self.inputSpatialDimensions) is np.ndarray: - inputSpatialDimensions = builder.CreateNumpyVector(self.inputSpatialDimensions) - else: - StablehloConvolutionOptionsStartInputSpatialDimensionsVector(builder, len(self.inputSpatialDimensions)) - for i in reversed(range(len(self.inputSpatialDimensions))): - builder.PrependInt64(self.inputSpatialDimensions[i]) - inputSpatialDimensions = builder.EndVector() - if self.kernelSpatialDimensions is not None: - if np is not None and type(self.kernelSpatialDimensions) is np.ndarray: - kernelSpatialDimensions = builder.CreateNumpyVector(self.kernelSpatialDimensions) - else: - StablehloConvolutionOptionsStartKernelSpatialDimensionsVector(builder, len(self.kernelSpatialDimensions)) - for i in reversed(range(len(self.kernelSpatialDimensions))): - builder.PrependInt64(self.kernelSpatialDimensions[i]) - kernelSpatialDimensions = builder.EndVector() - if self.outputSpatialDimensions is not None: - if np is not None and type(self.outputSpatialDimensions) is np.ndarray: - outputSpatialDimensions = builder.CreateNumpyVector(self.outputSpatialDimensions) - else: - StablehloConvolutionOptionsStartOutputSpatialDimensionsVector(builder, len(self.outputSpatialDimensions)) - for i in reversed(range(len(self.outputSpatialDimensions))): - builder.PrependInt64(self.outputSpatialDimensions[i]) - outputSpatialDimensions = builder.EndVector() - if self.precisionConfig is not None: - if np is not None and type(self.precisionConfig) is np.ndarray: - precisionConfig = builder.CreateNumpyVector(self.precisionConfig) - else: - StablehloConvolutionOptionsStartPrecisionConfigVector(builder, len(self.precisionConfig)) - for i in reversed(range(len(self.precisionConfig))): - builder.PrependUint32(self.precisionConfig[i]) - precisionConfig = builder.EndVector() - StablehloConvolutionOptionsStart(builder) - if self.windowStrides is not None: - StablehloConvolutionOptionsAddWindowStrides(builder, windowStrides) - if self.padding is not None: - StablehloConvolutionOptionsAddPadding(builder, padding) - if self.lhsDilation is not None: - StablehloConvolutionOptionsAddLhsDilation(builder, lhsDilation) - if self.rhsDilation is not None: - StablehloConvolutionOptionsAddRhsDilation(builder, rhsDilation) - if self.windowReversal is not None: - StablehloConvolutionOptionsAddWindowReversal(builder, windowReversal) - StablehloConvolutionOptionsAddInputBatchDimension(builder, self.inputBatchDimension) - StablehloConvolutionOptionsAddInputFeatureDimension(builder, self.inputFeatureDimension) - if self.inputSpatialDimensions is not None: - StablehloConvolutionOptionsAddInputSpatialDimensions(builder, inputSpatialDimensions) - StablehloConvolutionOptionsAddKernelInputFeatureDimension(builder, self.kernelInputFeatureDimension) - StablehloConvolutionOptionsAddKernelOutputFeatureDimension(builder, self.kernelOutputFeatureDimension) - if self.kernelSpatialDimensions is not None: - StablehloConvolutionOptionsAddKernelSpatialDimensions(builder, kernelSpatialDimensions) - StablehloConvolutionOptionsAddOutputBatchDimension(builder, self.outputBatchDimension) - StablehloConvolutionOptionsAddOutputFeatureDimension(builder, self.outputFeatureDimension) - if self.outputSpatialDimensions is not None: - StablehloConvolutionOptionsAddOutputSpatialDimensions(builder, outputSpatialDimensions) - StablehloConvolutionOptionsAddFeatureGroupCount(builder, self.featureGroupCount) - StablehloConvolutionOptionsAddBatchGroupCount(builder, self.batchGroupCount) - if self.precisionConfig is not None: - StablehloConvolutionOptionsAddPrecisionConfig(builder, precisionConfig) - stablehloConvolutionOptions = StablehloConvolutionOptionsEnd(builder) - return stablehloConvolutionOptions - - -class StablehloScatterOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloScatterOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloScatterOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloScatterOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloScatterOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloScatterOptions - def IndicesAreSorted(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # StablehloScatterOptions - def UpdateWindowDims(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloScatterOptions - def UpdateWindowDimsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloScatterOptions - def UpdateWindowDimsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloScatterOptions - def UpdateWindowDimsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # StablehloScatterOptions - def InsertedWindowDims(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloScatterOptions - def InsertedWindowDimsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloScatterOptions - def InsertedWindowDimsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloScatterOptions - def InsertedWindowDimsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - - # StablehloScatterOptions - def ScatterDimsToOperandDims(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8)) - return 0 - - # StablehloScatterOptions - def ScatterDimsToOperandDimsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o) - return 0 - - # StablehloScatterOptions - def ScatterDimsToOperandDimsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloScatterOptions - def ScatterDimsToOperandDimsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - return o == 0 - - # StablehloScatterOptions - def IndexVectorDim(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # StablehloScatterOptions - def UniqueIndices(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # StablehloScatterOptions - def UpdateComputationSubgraphIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def StablehloScatterOptionsStart(builder): - builder.StartObject(7) - -def StablehloScatterOptionsAddIndicesAreSorted(builder, indicesAreSorted): - builder.PrependBoolSlot(0, indicesAreSorted, 0) - -def StablehloScatterOptionsAddUpdateWindowDims(builder, updateWindowDims): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(updateWindowDims), 0) - -def StablehloScatterOptionsStartUpdateWindowDimsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloScatterOptionsAddInsertedWindowDims(builder, insertedWindowDims): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(insertedWindowDims), 0) - -def StablehloScatterOptionsStartInsertedWindowDimsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloScatterOptionsAddScatterDimsToOperandDims(builder, scatterDimsToOperandDims): - builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(scatterDimsToOperandDims), 0) - -def StablehloScatterOptionsStartScatterDimsToOperandDimsVector(builder, numElems): - return builder.StartVector(8, numElems, 8) - -def StablehloScatterOptionsAddIndexVectorDim(builder, indexVectorDim): - builder.PrependInt64Slot(4, indexVectorDim, 0) - -def StablehloScatterOptionsAddUniqueIndices(builder, uniqueIndices): - builder.PrependBoolSlot(5, uniqueIndices, 0) - -def StablehloScatterOptionsAddUpdateComputationSubgraphIndex(builder, updateComputationSubgraphIndex): - builder.PrependInt32Slot(6, updateComputationSubgraphIndex, 0) - -def StablehloScatterOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StablehloScatterOptionsT(object): - - # StablehloScatterOptionsT - def __init__( - self, - indicesAreSorted = False, - updateWindowDims = None, - insertedWindowDims = None, - scatterDimsToOperandDims = None, - indexVectorDim = 0, - uniqueIndices = False, - updateComputationSubgraphIndex = 0, - ): - self.indicesAreSorted = indicesAreSorted # type: bool - self.updateWindowDims = updateWindowDims # type: Optional[List[int]] - self.insertedWindowDims = insertedWindowDims # type: Optional[List[int]] - self.scatterDimsToOperandDims = scatterDimsToOperandDims # type: Optional[List[int]] - self.indexVectorDim = indexVectorDim # type: int - self.uniqueIndices = uniqueIndices # type: bool - self.updateComputationSubgraphIndex = updateComputationSubgraphIndex # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloScatterOptions = StablehloScatterOptions() - stablehloScatterOptions.Init(buf, pos) - return cls.InitFromObj(stablehloScatterOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloScatterOptions): - x = StablehloScatterOptionsT() - x._UnPack(stablehloScatterOptions) - return x - - # StablehloScatterOptionsT - def _UnPack(self, stablehloScatterOptions): - if stablehloScatterOptions is None: - return - self.indicesAreSorted = stablehloScatterOptions.IndicesAreSorted() - if not stablehloScatterOptions.UpdateWindowDimsIsNone(): - if np is None: - self.updateWindowDims = [] - for i in range(stablehloScatterOptions.UpdateWindowDimsLength()): - self.updateWindowDims.append(stablehloScatterOptions.UpdateWindowDims(i)) - else: - self.updateWindowDims = stablehloScatterOptions.UpdateWindowDimsAsNumpy() - if not stablehloScatterOptions.InsertedWindowDimsIsNone(): - if np is None: - self.insertedWindowDims = [] - for i in range(stablehloScatterOptions.InsertedWindowDimsLength()): - self.insertedWindowDims.append(stablehloScatterOptions.InsertedWindowDims(i)) - else: - self.insertedWindowDims = stablehloScatterOptions.InsertedWindowDimsAsNumpy() - if not stablehloScatterOptions.ScatterDimsToOperandDimsIsNone(): - if np is None: - self.scatterDimsToOperandDims = [] - for i in range(stablehloScatterOptions.ScatterDimsToOperandDimsLength()): - self.scatterDimsToOperandDims.append(stablehloScatterOptions.ScatterDimsToOperandDims(i)) - else: - self.scatterDimsToOperandDims = stablehloScatterOptions.ScatterDimsToOperandDimsAsNumpy() - self.indexVectorDim = stablehloScatterOptions.IndexVectorDim() - self.uniqueIndices = stablehloScatterOptions.UniqueIndices() - self.updateComputationSubgraphIndex = stablehloScatterOptions.UpdateComputationSubgraphIndex() - - # StablehloScatterOptionsT - def Pack(self, builder): - if self.updateWindowDims is not None: - if np is not None and type(self.updateWindowDims) is np.ndarray: - updateWindowDims = builder.CreateNumpyVector(self.updateWindowDims) - else: - StablehloScatterOptionsStartUpdateWindowDimsVector(builder, len(self.updateWindowDims)) - for i in reversed(range(len(self.updateWindowDims))): - builder.PrependInt64(self.updateWindowDims[i]) - updateWindowDims = builder.EndVector() - if self.insertedWindowDims is not None: - if np is not None and type(self.insertedWindowDims) is np.ndarray: - insertedWindowDims = builder.CreateNumpyVector(self.insertedWindowDims) - else: - StablehloScatterOptionsStartInsertedWindowDimsVector(builder, len(self.insertedWindowDims)) - for i in reversed(range(len(self.insertedWindowDims))): - builder.PrependInt64(self.insertedWindowDims[i]) - insertedWindowDims = builder.EndVector() - if self.scatterDimsToOperandDims is not None: - if np is not None and type(self.scatterDimsToOperandDims) is np.ndarray: - scatterDimsToOperandDims = builder.CreateNumpyVector(self.scatterDimsToOperandDims) - else: - StablehloScatterOptionsStartScatterDimsToOperandDimsVector(builder, len(self.scatterDimsToOperandDims)) - for i in reversed(range(len(self.scatterDimsToOperandDims))): - builder.PrependInt64(self.scatterDimsToOperandDims[i]) - scatterDimsToOperandDims = builder.EndVector() - StablehloScatterOptionsStart(builder) - StablehloScatterOptionsAddIndicesAreSorted(builder, self.indicesAreSorted) - if self.updateWindowDims is not None: - StablehloScatterOptionsAddUpdateWindowDims(builder, updateWindowDims) - if self.insertedWindowDims is not None: - StablehloScatterOptionsAddInsertedWindowDims(builder, insertedWindowDims) - if self.scatterDimsToOperandDims is not None: - StablehloScatterOptionsAddScatterDimsToOperandDims(builder, scatterDimsToOperandDims) - StablehloScatterOptionsAddIndexVectorDim(builder, self.indexVectorDim) - StablehloScatterOptionsAddUniqueIndices(builder, self.uniqueIndices) - StablehloScatterOptionsAddUpdateComputationSubgraphIndex(builder, self.updateComputationSubgraphIndex) - stablehloScatterOptions = StablehloScatterOptionsEnd(builder) - return stablehloScatterOptions - - -class StablehloCaseOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloCaseOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloCaseOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloCaseOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloCaseOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloCaseOptions - def BranchSubgraphIndices(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # StablehloCaseOptions - def BranchSubgraphIndicesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # StablehloCaseOptions - def BranchSubgraphIndicesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StablehloCaseOptions - def BranchSubgraphIndicesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - -def StablehloCaseOptionsStart(builder): - builder.StartObject(1) - -def StablehloCaseOptionsAddBranchSubgraphIndices(builder, branchSubgraphIndices): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(branchSubgraphIndices), 0) - -def StablehloCaseOptionsStartBranchSubgraphIndicesVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def StablehloCaseOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StablehloCaseOptionsT(object): - - # StablehloCaseOptionsT - def __init__( - self, - branchSubgraphIndices = None, - ): - self.branchSubgraphIndices = branchSubgraphIndices # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloCaseOptions = StablehloCaseOptions() - stablehloCaseOptions.Init(buf, pos) - return cls.InitFromObj(stablehloCaseOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloCaseOptions): - x = StablehloCaseOptionsT() - x._UnPack(stablehloCaseOptions) - return x - - # StablehloCaseOptionsT - def _UnPack(self, stablehloCaseOptions): - if stablehloCaseOptions is None: - return - if not stablehloCaseOptions.BranchSubgraphIndicesIsNone(): - if np is None: - self.branchSubgraphIndices = [] - for i in range(stablehloCaseOptions.BranchSubgraphIndicesLength()): - self.branchSubgraphIndices.append(stablehloCaseOptions.BranchSubgraphIndices(i)) - else: - self.branchSubgraphIndices = stablehloCaseOptions.BranchSubgraphIndicesAsNumpy() - - # StablehloCaseOptionsT - def Pack(self, builder): - if self.branchSubgraphIndices is not None: - if np is not None and type(self.branchSubgraphIndices) is np.ndarray: - branchSubgraphIndices = builder.CreateNumpyVector(self.branchSubgraphIndices) - else: - StablehloCaseOptionsStartBranchSubgraphIndicesVector(builder, len(self.branchSubgraphIndices)) - for i in reversed(range(len(self.branchSubgraphIndices))): - builder.PrependInt32(self.branchSubgraphIndices[i]) - branchSubgraphIndices = builder.EndVector() - StablehloCaseOptionsStart(builder) - if self.branchSubgraphIndices is not None: - StablehloCaseOptionsAddBranchSubgraphIndices(builder, branchSubgraphIndices) - stablehloCaseOptions = StablehloCaseOptionsEnd(builder) - return stablehloCaseOptions - - -class StablehloRngBitGeneratorOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloRngBitGeneratorOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloRngBitGeneratorOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloRngBitGeneratorOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloRngBitGeneratorOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StablehloRngBitGeneratorOptions - def Algorithm(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def StablehloRngBitGeneratorOptionsStart(builder): - builder.StartObject(1) - -def StablehloRngBitGeneratorOptionsAddAlgorithm(builder, algorithm): - builder.PrependInt8Slot(0, algorithm, 0) - -def StablehloRngBitGeneratorOptionsEnd(builder): - return builder.EndObject() - - - -class StablehloRngBitGeneratorOptionsT(object): - - # StablehloRngBitGeneratorOptionsT - def __init__( - self, - algorithm = 0, - ): - self.algorithm = algorithm # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloRngBitGeneratorOptions = StablehloRngBitGeneratorOptions() - stablehloRngBitGeneratorOptions.Init(buf, pos) - return cls.InitFromObj(stablehloRngBitGeneratorOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloRngBitGeneratorOptions): - x = StablehloRngBitGeneratorOptionsT() - x._UnPack(stablehloRngBitGeneratorOptions) - return x - - # StablehloRngBitGeneratorOptionsT - def _UnPack(self, stablehloRngBitGeneratorOptions): - if stablehloRngBitGeneratorOptions is None: - return - self.algorithm = stablehloRngBitGeneratorOptions.Algorithm() - - # StablehloRngBitGeneratorOptionsT - def Pack(self, builder): - StablehloRngBitGeneratorOptionsStart(builder) - StablehloRngBitGeneratorOptionsAddAlgorithm(builder, self.algorithm) - stablehloRngBitGeneratorOptions = StablehloRngBitGeneratorOptionsEnd(builder) - return stablehloRngBitGeneratorOptions - - -class Conv2DOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Conv2DOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsConv2DOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def Conv2DOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # Conv2DOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Conv2DOptions - def Padding(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # Conv2DOptions - def StrideW(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # Conv2DOptions - def StrideH(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # Conv2DOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # Conv2DOptions - def DilationWFactor(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 1 - - # Conv2DOptions - def DilationHFactor(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 1 - - # Conv2DOptions - def QuantizedBiasType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def Conv2DOptionsStart(builder): - builder.StartObject(7) - -def Conv2DOptionsAddPadding(builder, padding): - builder.PrependInt8Slot(0, padding, 0) - -def Conv2DOptionsAddStrideW(builder, strideW): - builder.PrependInt32Slot(1, strideW, 0) - -def Conv2DOptionsAddStrideH(builder, strideH): - builder.PrependInt32Slot(2, strideH, 0) - -def Conv2DOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(3, fusedActivationFunction, 0) - -def Conv2DOptionsAddDilationWFactor(builder, dilationWFactor): - builder.PrependInt32Slot(4, dilationWFactor, 1) - -def Conv2DOptionsAddDilationHFactor(builder, dilationHFactor): - builder.PrependInt32Slot(5, dilationHFactor, 1) - -def Conv2DOptionsAddQuantizedBiasType(builder, quantizedBiasType): - builder.PrependInt8Slot(6, quantizedBiasType, 0) - -def Conv2DOptionsEnd(builder): - return builder.EndObject() - - - -class Conv2DOptionsT(object): - - # Conv2DOptionsT - def __init__( - self, - padding = 0, - strideW = 0, - strideH = 0, - fusedActivationFunction = 0, - dilationWFactor = 1, - dilationHFactor = 1, - quantizedBiasType = 0, - ): - self.padding = padding # type: int - self.strideW = strideW # type: int - self.strideH = strideH # type: int - self.fusedActivationFunction = fusedActivationFunction # type: int - self.dilationWFactor = dilationWFactor # type: int - self.dilationHFactor = dilationHFactor # type: int - self.quantizedBiasType = quantizedBiasType # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - conv2Doptions = Conv2DOptions() - conv2Doptions.Init(buf, pos) - return cls.InitFromObj(conv2Doptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, conv2Doptions): - x = Conv2DOptionsT() - x._UnPack(conv2Doptions) - return x - - # Conv2DOptionsT - def _UnPack(self, conv2Doptions): - if conv2Doptions is None: - return - self.padding = conv2Doptions.Padding() - self.strideW = conv2Doptions.StrideW() - self.strideH = conv2Doptions.StrideH() - self.fusedActivationFunction = conv2Doptions.FusedActivationFunction() - self.dilationWFactor = conv2Doptions.DilationWFactor() - self.dilationHFactor = conv2Doptions.DilationHFactor() - self.quantizedBiasType = conv2Doptions.QuantizedBiasType() - - # Conv2DOptionsT - def Pack(self, builder): - Conv2DOptionsStart(builder) - Conv2DOptionsAddPadding(builder, self.padding) - Conv2DOptionsAddStrideW(builder, self.strideW) - Conv2DOptionsAddStrideH(builder, self.strideH) - Conv2DOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - Conv2DOptionsAddDilationWFactor(builder, self.dilationWFactor) - Conv2DOptionsAddDilationHFactor(builder, self.dilationHFactor) - Conv2DOptionsAddQuantizedBiasType(builder, self.quantizedBiasType) - conv2Doptions = Conv2DOptionsEnd(builder) - return conv2Doptions - - -class Conv3DOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Conv3DOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsConv3DOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def Conv3DOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # Conv3DOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Conv3DOptions - def Padding(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # Conv3DOptions - def StrideD(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # Conv3DOptions - def StrideW(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # Conv3DOptions - def StrideH(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # Conv3DOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # Conv3DOptions - def DilationDFactor(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 1 - - # Conv3DOptions - def DilationWFactor(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 1 - - # Conv3DOptions - def DilationHFactor(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 1 - -def Conv3DOptionsStart(builder): - builder.StartObject(8) - -def Conv3DOptionsAddPadding(builder, padding): - builder.PrependInt8Slot(0, padding, 0) - -def Conv3DOptionsAddStrideD(builder, strideD): - builder.PrependInt32Slot(1, strideD, 0) - -def Conv3DOptionsAddStrideW(builder, strideW): - builder.PrependInt32Slot(2, strideW, 0) - -def Conv3DOptionsAddStrideH(builder, strideH): - builder.PrependInt32Slot(3, strideH, 0) - -def Conv3DOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(4, fusedActivationFunction, 0) - -def Conv3DOptionsAddDilationDFactor(builder, dilationDFactor): - builder.PrependInt32Slot(5, dilationDFactor, 1) - -def Conv3DOptionsAddDilationWFactor(builder, dilationWFactor): - builder.PrependInt32Slot(6, dilationWFactor, 1) - -def Conv3DOptionsAddDilationHFactor(builder, dilationHFactor): - builder.PrependInt32Slot(7, dilationHFactor, 1) - -def Conv3DOptionsEnd(builder): - return builder.EndObject() - - - -class Conv3DOptionsT(object): - - # Conv3DOptionsT - def __init__( - self, - padding = 0, - strideD = 0, - strideW = 0, - strideH = 0, - fusedActivationFunction = 0, - dilationDFactor = 1, - dilationWFactor = 1, - dilationHFactor = 1, - ): - self.padding = padding # type: int - self.strideD = strideD # type: int - self.strideW = strideW # type: int - self.strideH = strideH # type: int - self.fusedActivationFunction = fusedActivationFunction # type: int - self.dilationDFactor = dilationDFactor # type: int - self.dilationWFactor = dilationWFactor # type: int - self.dilationHFactor = dilationHFactor # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - conv3Doptions = Conv3DOptions() - conv3Doptions.Init(buf, pos) - return cls.InitFromObj(conv3Doptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, conv3Doptions): - x = Conv3DOptionsT() - x._UnPack(conv3Doptions) - return x - - # Conv3DOptionsT - def _UnPack(self, conv3Doptions): - if conv3Doptions is None: - return - self.padding = conv3Doptions.Padding() - self.strideD = conv3Doptions.StrideD() - self.strideW = conv3Doptions.StrideW() - self.strideH = conv3Doptions.StrideH() - self.fusedActivationFunction = conv3Doptions.FusedActivationFunction() - self.dilationDFactor = conv3Doptions.DilationDFactor() - self.dilationWFactor = conv3Doptions.DilationWFactor() - self.dilationHFactor = conv3Doptions.DilationHFactor() - - # Conv3DOptionsT - def Pack(self, builder): - Conv3DOptionsStart(builder) - Conv3DOptionsAddPadding(builder, self.padding) - Conv3DOptionsAddStrideD(builder, self.strideD) - Conv3DOptionsAddStrideW(builder, self.strideW) - Conv3DOptionsAddStrideH(builder, self.strideH) - Conv3DOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - Conv3DOptionsAddDilationDFactor(builder, self.dilationDFactor) - Conv3DOptionsAddDilationWFactor(builder, self.dilationWFactor) - Conv3DOptionsAddDilationHFactor(builder, self.dilationHFactor) - conv3Doptions = Conv3DOptionsEnd(builder) - return conv3Doptions - - -class Pool2DOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Pool2DOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsPool2DOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def Pool2DOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # Pool2DOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Pool2DOptions - def Padding(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # Pool2DOptions - def StrideW(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # Pool2DOptions - def StrideH(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # Pool2DOptions - def FilterWidth(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # Pool2DOptions - def FilterHeight(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # Pool2DOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def Pool2DOptionsStart(builder): - builder.StartObject(6) - -def Pool2DOptionsAddPadding(builder, padding): - builder.PrependInt8Slot(0, padding, 0) - -def Pool2DOptionsAddStrideW(builder, strideW): - builder.PrependInt32Slot(1, strideW, 0) - -def Pool2DOptionsAddStrideH(builder, strideH): - builder.PrependInt32Slot(2, strideH, 0) - -def Pool2DOptionsAddFilterWidth(builder, filterWidth): - builder.PrependInt32Slot(3, filterWidth, 0) - -def Pool2DOptionsAddFilterHeight(builder, filterHeight): - builder.PrependInt32Slot(4, filterHeight, 0) - -def Pool2DOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(5, fusedActivationFunction, 0) - -def Pool2DOptionsEnd(builder): - return builder.EndObject() - - - -class Pool2DOptionsT(object): - - # Pool2DOptionsT - def __init__( - self, - padding = 0, - strideW = 0, - strideH = 0, - filterWidth = 0, - filterHeight = 0, - fusedActivationFunction = 0, - ): - self.padding = padding # type: int - self.strideW = strideW # type: int - self.strideH = strideH # type: int - self.filterWidth = filterWidth # type: int - self.filterHeight = filterHeight # type: int - self.fusedActivationFunction = fusedActivationFunction # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - pool2Doptions = Pool2DOptions() - pool2Doptions.Init(buf, pos) - return cls.InitFromObj(pool2Doptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, pool2Doptions): - x = Pool2DOptionsT() - x._UnPack(pool2Doptions) - return x - - # Pool2DOptionsT - def _UnPack(self, pool2Doptions): - if pool2Doptions is None: - return - self.padding = pool2Doptions.Padding() - self.strideW = pool2Doptions.StrideW() - self.strideH = pool2Doptions.StrideH() - self.filterWidth = pool2Doptions.FilterWidth() - self.filterHeight = pool2Doptions.FilterHeight() - self.fusedActivationFunction = pool2Doptions.FusedActivationFunction() - - # Pool2DOptionsT - def Pack(self, builder): - Pool2DOptionsStart(builder) - Pool2DOptionsAddPadding(builder, self.padding) - Pool2DOptionsAddStrideW(builder, self.strideW) - Pool2DOptionsAddStrideH(builder, self.strideH) - Pool2DOptionsAddFilterWidth(builder, self.filterWidth) - Pool2DOptionsAddFilterHeight(builder, self.filterHeight) - Pool2DOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - pool2Doptions = Pool2DOptionsEnd(builder) - return pool2Doptions - - -class DepthwiseConv2DOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = DepthwiseConv2DOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsDepthwiseConv2DOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def DepthwiseConv2DOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # DepthwiseConv2DOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # DepthwiseConv2DOptions - def Padding(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # DepthwiseConv2DOptions - def StrideW(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # DepthwiseConv2DOptions - def StrideH(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # DepthwiseConv2DOptions - def DepthMultiplier(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # DepthwiseConv2DOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # DepthwiseConv2DOptions - def DilationWFactor(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 1 - - # DepthwiseConv2DOptions - def DilationHFactor(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 1 - -def DepthwiseConv2DOptionsStart(builder): - builder.StartObject(7) - -def DepthwiseConv2DOptionsAddPadding(builder, padding): - builder.PrependInt8Slot(0, padding, 0) - -def DepthwiseConv2DOptionsAddStrideW(builder, strideW): - builder.PrependInt32Slot(1, strideW, 0) - -def DepthwiseConv2DOptionsAddStrideH(builder, strideH): - builder.PrependInt32Slot(2, strideH, 0) - -def DepthwiseConv2DOptionsAddDepthMultiplier(builder, depthMultiplier): - builder.PrependInt32Slot(3, depthMultiplier, 0) - -def DepthwiseConv2DOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(4, fusedActivationFunction, 0) - -def DepthwiseConv2DOptionsAddDilationWFactor(builder, dilationWFactor): - builder.PrependInt32Slot(5, dilationWFactor, 1) - -def DepthwiseConv2DOptionsAddDilationHFactor(builder, dilationHFactor): - builder.PrependInt32Slot(6, dilationHFactor, 1) - -def DepthwiseConv2DOptionsEnd(builder): - return builder.EndObject() - - - -class DepthwiseConv2DOptionsT(object): - - # DepthwiseConv2DOptionsT - def __init__( - self, - padding = 0, - strideW = 0, - strideH = 0, - depthMultiplier = 0, - fusedActivationFunction = 0, - dilationWFactor = 1, - dilationHFactor = 1, - ): - self.padding = padding # type: int - self.strideW = strideW # type: int - self.strideH = strideH # type: int - self.depthMultiplier = depthMultiplier # type: int - self.fusedActivationFunction = fusedActivationFunction # type: int - self.dilationWFactor = dilationWFactor # type: int - self.dilationHFactor = dilationHFactor # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - depthwiseConv2Doptions = DepthwiseConv2DOptions() - depthwiseConv2Doptions.Init(buf, pos) - return cls.InitFromObj(depthwiseConv2Doptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, depthwiseConv2Doptions): - x = DepthwiseConv2DOptionsT() - x._UnPack(depthwiseConv2Doptions) - return x - - # DepthwiseConv2DOptionsT - def _UnPack(self, depthwiseConv2Doptions): - if depthwiseConv2Doptions is None: - return - self.padding = depthwiseConv2Doptions.Padding() - self.strideW = depthwiseConv2Doptions.StrideW() - self.strideH = depthwiseConv2Doptions.StrideH() - self.depthMultiplier = depthwiseConv2Doptions.DepthMultiplier() - self.fusedActivationFunction = depthwiseConv2Doptions.FusedActivationFunction() - self.dilationWFactor = depthwiseConv2Doptions.DilationWFactor() - self.dilationHFactor = depthwiseConv2Doptions.DilationHFactor() - - # DepthwiseConv2DOptionsT - def Pack(self, builder): - DepthwiseConv2DOptionsStart(builder) - DepthwiseConv2DOptionsAddPadding(builder, self.padding) - DepthwiseConv2DOptionsAddStrideW(builder, self.strideW) - DepthwiseConv2DOptionsAddStrideH(builder, self.strideH) - DepthwiseConv2DOptionsAddDepthMultiplier(builder, self.depthMultiplier) - DepthwiseConv2DOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - DepthwiseConv2DOptionsAddDilationWFactor(builder, self.dilationWFactor) - DepthwiseConv2DOptionsAddDilationHFactor(builder, self.dilationHFactor) - depthwiseConv2Doptions = DepthwiseConv2DOptionsEnd(builder) - return depthwiseConv2Doptions - - -class ConcatEmbeddingsOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ConcatEmbeddingsOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsConcatEmbeddingsOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ConcatEmbeddingsOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ConcatEmbeddingsOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ConcatEmbeddingsOptions - def NumChannels(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # ConcatEmbeddingsOptions - def NumColumnsPerChannel(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # ConcatEmbeddingsOptions - def NumColumnsPerChannelAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # ConcatEmbeddingsOptions - def NumColumnsPerChannelLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # ConcatEmbeddingsOptions - def NumColumnsPerChannelIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # ConcatEmbeddingsOptions - def EmbeddingDimPerChannel(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # ConcatEmbeddingsOptions - def EmbeddingDimPerChannelAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # ConcatEmbeddingsOptions - def EmbeddingDimPerChannelLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # ConcatEmbeddingsOptions - def EmbeddingDimPerChannelIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - -def ConcatEmbeddingsOptionsStart(builder): - builder.StartObject(3) - -def ConcatEmbeddingsOptionsAddNumChannels(builder, numChannels): - builder.PrependInt32Slot(0, numChannels, 0) - -def ConcatEmbeddingsOptionsAddNumColumnsPerChannel(builder, numColumnsPerChannel): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(numColumnsPerChannel), 0) - -def ConcatEmbeddingsOptionsStartNumColumnsPerChannelVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def ConcatEmbeddingsOptionsAddEmbeddingDimPerChannel(builder, embeddingDimPerChannel): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(embeddingDimPerChannel), 0) - -def ConcatEmbeddingsOptionsStartEmbeddingDimPerChannelVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def ConcatEmbeddingsOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class ConcatEmbeddingsOptionsT(object): - - # ConcatEmbeddingsOptionsT - def __init__( - self, - numChannels = 0, - numColumnsPerChannel = None, - embeddingDimPerChannel = None, - ): - self.numChannels = numChannels # type: int - self.numColumnsPerChannel = numColumnsPerChannel # type: Optional[List[int]] - self.embeddingDimPerChannel = embeddingDimPerChannel # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - concatEmbeddingsOptions = ConcatEmbeddingsOptions() - concatEmbeddingsOptions.Init(buf, pos) - return cls.InitFromObj(concatEmbeddingsOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, concatEmbeddingsOptions): - x = ConcatEmbeddingsOptionsT() - x._UnPack(concatEmbeddingsOptions) - return x - - # ConcatEmbeddingsOptionsT - def _UnPack(self, concatEmbeddingsOptions): - if concatEmbeddingsOptions is None: - return - self.numChannels = concatEmbeddingsOptions.NumChannels() - if not concatEmbeddingsOptions.NumColumnsPerChannelIsNone(): - if np is None: - self.numColumnsPerChannel = [] - for i in range(concatEmbeddingsOptions.NumColumnsPerChannelLength()): - self.numColumnsPerChannel.append(concatEmbeddingsOptions.NumColumnsPerChannel(i)) - else: - self.numColumnsPerChannel = concatEmbeddingsOptions.NumColumnsPerChannelAsNumpy() - if not concatEmbeddingsOptions.EmbeddingDimPerChannelIsNone(): - if np is None: - self.embeddingDimPerChannel = [] - for i in range(concatEmbeddingsOptions.EmbeddingDimPerChannelLength()): - self.embeddingDimPerChannel.append(concatEmbeddingsOptions.EmbeddingDimPerChannel(i)) - else: - self.embeddingDimPerChannel = concatEmbeddingsOptions.EmbeddingDimPerChannelAsNumpy() - - # ConcatEmbeddingsOptionsT - def Pack(self, builder): - if self.numColumnsPerChannel is not None: - if np is not None and type(self.numColumnsPerChannel) is np.ndarray: - numColumnsPerChannel = builder.CreateNumpyVector(self.numColumnsPerChannel) - else: - ConcatEmbeddingsOptionsStartNumColumnsPerChannelVector(builder, len(self.numColumnsPerChannel)) - for i in reversed(range(len(self.numColumnsPerChannel))): - builder.PrependInt32(self.numColumnsPerChannel[i]) - numColumnsPerChannel = builder.EndVector() - if self.embeddingDimPerChannel is not None: - if np is not None and type(self.embeddingDimPerChannel) is np.ndarray: - embeddingDimPerChannel = builder.CreateNumpyVector(self.embeddingDimPerChannel) - else: - ConcatEmbeddingsOptionsStartEmbeddingDimPerChannelVector(builder, len(self.embeddingDimPerChannel)) - for i in reversed(range(len(self.embeddingDimPerChannel))): - builder.PrependInt32(self.embeddingDimPerChannel[i]) - embeddingDimPerChannel = builder.EndVector() - ConcatEmbeddingsOptionsStart(builder) - ConcatEmbeddingsOptionsAddNumChannels(builder, self.numChannels) - if self.numColumnsPerChannel is not None: - ConcatEmbeddingsOptionsAddNumColumnsPerChannel(builder, numColumnsPerChannel) - if self.embeddingDimPerChannel is not None: - ConcatEmbeddingsOptionsAddEmbeddingDimPerChannel(builder, embeddingDimPerChannel) - concatEmbeddingsOptions = ConcatEmbeddingsOptionsEnd(builder) - return concatEmbeddingsOptions - - -class LSHProjectionOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = LSHProjectionOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsLSHProjectionOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def LSHProjectionOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # LSHProjectionOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # LSHProjectionOptions - def Type(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def LSHProjectionOptionsStart(builder): - builder.StartObject(1) - -def LSHProjectionOptionsAddType(builder, type): - builder.PrependInt8Slot(0, type, 0) - -def LSHProjectionOptionsEnd(builder): - return builder.EndObject() - - - -class LSHProjectionOptionsT(object): - - # LSHProjectionOptionsT - def __init__( - self, - type = 0, - ): - self.type = type # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - lshprojectionOptions = LSHProjectionOptions() - lshprojectionOptions.Init(buf, pos) - return cls.InitFromObj(lshprojectionOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, lshprojectionOptions): - x = LSHProjectionOptionsT() - x._UnPack(lshprojectionOptions) - return x - - # LSHProjectionOptionsT - def _UnPack(self, lshprojectionOptions): - if lshprojectionOptions is None: - return - self.type = lshprojectionOptions.Type() - - # LSHProjectionOptionsT - def Pack(self, builder): - LSHProjectionOptionsStart(builder) - LSHProjectionOptionsAddType(builder, self.type) - lshprojectionOptions = LSHProjectionOptionsEnd(builder) - return lshprojectionOptions - - -class SVDFOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SVDFOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSVDFOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SVDFOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SVDFOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SVDFOptions - def Rank(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # SVDFOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # SVDFOptions - def AsymmetricQuantizeInputs(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def SVDFOptionsStart(builder): - builder.StartObject(3) - -def SVDFOptionsAddRank(builder, rank): - builder.PrependInt32Slot(0, rank, 0) - -def SVDFOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(1, fusedActivationFunction, 0) - -def SVDFOptionsAddAsymmetricQuantizeInputs(builder, asymmetricQuantizeInputs): - builder.PrependBoolSlot(2, asymmetricQuantizeInputs, 0) - -def SVDFOptionsEnd(builder): - return builder.EndObject() - - - -class SVDFOptionsT(object): - - # SVDFOptionsT - def __init__( - self, - rank = 0, - fusedActivationFunction = 0, - asymmetricQuantizeInputs = False, - ): - self.rank = rank # type: int - self.fusedActivationFunction = fusedActivationFunction # type: int - self.asymmetricQuantizeInputs = asymmetricQuantizeInputs # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - svdfoptions = SVDFOptions() - svdfoptions.Init(buf, pos) - return cls.InitFromObj(svdfoptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, svdfoptions): - x = SVDFOptionsT() - x._UnPack(svdfoptions) - return x - - # SVDFOptionsT - def _UnPack(self, svdfoptions): - if svdfoptions is None: - return - self.rank = svdfoptions.Rank() - self.fusedActivationFunction = svdfoptions.FusedActivationFunction() - self.asymmetricQuantizeInputs = svdfoptions.AsymmetricQuantizeInputs() - - # SVDFOptionsT - def Pack(self, builder): - SVDFOptionsStart(builder) - SVDFOptionsAddRank(builder, self.rank) - SVDFOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - SVDFOptionsAddAsymmetricQuantizeInputs(builder, self.asymmetricQuantizeInputs) - svdfoptions = SVDFOptionsEnd(builder) - return svdfoptions - - -class RNNOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = RNNOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsRNNOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def RNNOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # RNNOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # RNNOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # RNNOptions - def AsymmetricQuantizeInputs(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def RNNOptionsStart(builder): - builder.StartObject(2) - -def RNNOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(0, fusedActivationFunction, 0) - -def RNNOptionsAddAsymmetricQuantizeInputs(builder, asymmetricQuantizeInputs): - builder.PrependBoolSlot(1, asymmetricQuantizeInputs, 0) - -def RNNOptionsEnd(builder): - return builder.EndObject() - - - -class RNNOptionsT(object): - - # RNNOptionsT - def __init__( - self, - fusedActivationFunction = 0, - asymmetricQuantizeInputs = False, - ): - self.fusedActivationFunction = fusedActivationFunction # type: int - self.asymmetricQuantizeInputs = asymmetricQuantizeInputs # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - rnnoptions = RNNOptions() - rnnoptions.Init(buf, pos) - return cls.InitFromObj(rnnoptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, rnnoptions): - x = RNNOptionsT() - x._UnPack(rnnoptions) - return x - - # RNNOptionsT - def _UnPack(self, rnnoptions): - if rnnoptions is None: - return - self.fusedActivationFunction = rnnoptions.FusedActivationFunction() - self.asymmetricQuantizeInputs = rnnoptions.AsymmetricQuantizeInputs() - - # RNNOptionsT - def Pack(self, builder): - RNNOptionsStart(builder) - RNNOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - RNNOptionsAddAsymmetricQuantizeInputs(builder, self.asymmetricQuantizeInputs) - rnnoptions = RNNOptionsEnd(builder) - return rnnoptions - - -class SequenceRNNOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SequenceRNNOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSequenceRNNOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SequenceRNNOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SequenceRNNOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SequenceRNNOptions - def TimeMajor(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # SequenceRNNOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # SequenceRNNOptions - def AsymmetricQuantizeInputs(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def SequenceRNNOptionsStart(builder): - builder.StartObject(3) - -def SequenceRNNOptionsAddTimeMajor(builder, timeMajor): - builder.PrependBoolSlot(0, timeMajor, 0) - -def SequenceRNNOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(1, fusedActivationFunction, 0) - -def SequenceRNNOptionsAddAsymmetricQuantizeInputs(builder, asymmetricQuantizeInputs): - builder.PrependBoolSlot(2, asymmetricQuantizeInputs, 0) - -def SequenceRNNOptionsEnd(builder): - return builder.EndObject() - - - -class SequenceRNNOptionsT(object): - - # SequenceRNNOptionsT - def __init__( - self, - timeMajor = False, - fusedActivationFunction = 0, - asymmetricQuantizeInputs = False, - ): - self.timeMajor = timeMajor # type: bool - self.fusedActivationFunction = fusedActivationFunction # type: int - self.asymmetricQuantizeInputs = asymmetricQuantizeInputs # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - sequenceRnnoptions = SequenceRNNOptions() - sequenceRnnoptions.Init(buf, pos) - return cls.InitFromObj(sequenceRnnoptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, sequenceRnnoptions): - x = SequenceRNNOptionsT() - x._UnPack(sequenceRnnoptions) - return x - - # SequenceRNNOptionsT - def _UnPack(self, sequenceRnnoptions): - if sequenceRnnoptions is None: - return - self.timeMajor = sequenceRnnoptions.TimeMajor() - self.fusedActivationFunction = sequenceRnnoptions.FusedActivationFunction() - self.asymmetricQuantizeInputs = sequenceRnnoptions.AsymmetricQuantizeInputs() - - # SequenceRNNOptionsT - def Pack(self, builder): - SequenceRNNOptionsStart(builder) - SequenceRNNOptionsAddTimeMajor(builder, self.timeMajor) - SequenceRNNOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - SequenceRNNOptionsAddAsymmetricQuantizeInputs(builder, self.asymmetricQuantizeInputs) - sequenceRnnoptions = SequenceRNNOptionsEnd(builder) - return sequenceRnnoptions - - -class BidirectionalSequenceRNNOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = BidirectionalSequenceRNNOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsBidirectionalSequenceRNNOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def BidirectionalSequenceRNNOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # BidirectionalSequenceRNNOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # BidirectionalSequenceRNNOptions - def TimeMajor(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # BidirectionalSequenceRNNOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # BidirectionalSequenceRNNOptions - def MergeOutputs(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # BidirectionalSequenceRNNOptions - def AsymmetricQuantizeInputs(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def BidirectionalSequenceRNNOptionsStart(builder): - builder.StartObject(4) - -def BidirectionalSequenceRNNOptionsAddTimeMajor(builder, timeMajor): - builder.PrependBoolSlot(0, timeMajor, 0) - -def BidirectionalSequenceRNNOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(1, fusedActivationFunction, 0) - -def BidirectionalSequenceRNNOptionsAddMergeOutputs(builder, mergeOutputs): - builder.PrependBoolSlot(2, mergeOutputs, 0) - -def BidirectionalSequenceRNNOptionsAddAsymmetricQuantizeInputs(builder, asymmetricQuantizeInputs): - builder.PrependBoolSlot(3, asymmetricQuantizeInputs, 0) - -def BidirectionalSequenceRNNOptionsEnd(builder): - return builder.EndObject() - - - -class BidirectionalSequenceRNNOptionsT(object): - - # BidirectionalSequenceRNNOptionsT - def __init__( - self, - timeMajor = False, - fusedActivationFunction = 0, - mergeOutputs = False, - asymmetricQuantizeInputs = False, - ): - self.timeMajor = timeMajor # type: bool - self.fusedActivationFunction = fusedActivationFunction # type: int - self.mergeOutputs = mergeOutputs # type: bool - self.asymmetricQuantizeInputs = asymmetricQuantizeInputs # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - bidirectionalSequenceRnnoptions = BidirectionalSequenceRNNOptions() - bidirectionalSequenceRnnoptions.Init(buf, pos) - return cls.InitFromObj(bidirectionalSequenceRnnoptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, bidirectionalSequenceRnnoptions): - x = BidirectionalSequenceRNNOptionsT() - x._UnPack(bidirectionalSequenceRnnoptions) - return x - - # BidirectionalSequenceRNNOptionsT - def _UnPack(self, bidirectionalSequenceRnnoptions): - if bidirectionalSequenceRnnoptions is None: - return - self.timeMajor = bidirectionalSequenceRnnoptions.TimeMajor() - self.fusedActivationFunction = bidirectionalSequenceRnnoptions.FusedActivationFunction() - self.mergeOutputs = bidirectionalSequenceRnnoptions.MergeOutputs() - self.asymmetricQuantizeInputs = bidirectionalSequenceRnnoptions.AsymmetricQuantizeInputs() - - # BidirectionalSequenceRNNOptionsT - def Pack(self, builder): - BidirectionalSequenceRNNOptionsStart(builder) - BidirectionalSequenceRNNOptionsAddTimeMajor(builder, self.timeMajor) - BidirectionalSequenceRNNOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - BidirectionalSequenceRNNOptionsAddMergeOutputs(builder, self.mergeOutputs) - BidirectionalSequenceRNNOptionsAddAsymmetricQuantizeInputs(builder, self.asymmetricQuantizeInputs) - bidirectionalSequenceRnnoptions = BidirectionalSequenceRNNOptionsEnd(builder) - return bidirectionalSequenceRnnoptions - - -class FullyConnectedOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = FullyConnectedOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsFullyConnectedOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def FullyConnectedOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # FullyConnectedOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # FullyConnectedOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # FullyConnectedOptions - def WeightsFormat(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # FullyConnectedOptions - def KeepNumDims(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # FullyConnectedOptions - def AsymmetricQuantizeInputs(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # FullyConnectedOptions - def QuantizedBiasType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def FullyConnectedOptionsStart(builder): - builder.StartObject(5) - -def FullyConnectedOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(0, fusedActivationFunction, 0) - -def FullyConnectedOptionsAddWeightsFormat(builder, weightsFormat): - builder.PrependInt8Slot(1, weightsFormat, 0) - -def FullyConnectedOptionsAddKeepNumDims(builder, keepNumDims): - builder.PrependBoolSlot(2, keepNumDims, 0) - -def FullyConnectedOptionsAddAsymmetricQuantizeInputs(builder, asymmetricQuantizeInputs): - builder.PrependBoolSlot(3, asymmetricQuantizeInputs, 0) - -def FullyConnectedOptionsAddQuantizedBiasType(builder, quantizedBiasType): - builder.PrependInt8Slot(4, quantizedBiasType, 0) - -def FullyConnectedOptionsEnd(builder): - return builder.EndObject() - - - -class FullyConnectedOptionsT(object): - - # FullyConnectedOptionsT - def __init__( - self, - fusedActivationFunction = 0, - weightsFormat = 0, - keepNumDims = False, - asymmetricQuantizeInputs = False, - quantizedBiasType = 0, - ): - self.fusedActivationFunction = fusedActivationFunction # type: int - self.weightsFormat = weightsFormat # type: int - self.keepNumDims = keepNumDims # type: bool - self.asymmetricQuantizeInputs = asymmetricQuantizeInputs # type: bool - self.quantizedBiasType = quantizedBiasType # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - fullyConnectedOptions = FullyConnectedOptions() - fullyConnectedOptions.Init(buf, pos) - return cls.InitFromObj(fullyConnectedOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, fullyConnectedOptions): - x = FullyConnectedOptionsT() - x._UnPack(fullyConnectedOptions) - return x - - # FullyConnectedOptionsT - def _UnPack(self, fullyConnectedOptions): - if fullyConnectedOptions is None: - return - self.fusedActivationFunction = fullyConnectedOptions.FusedActivationFunction() - self.weightsFormat = fullyConnectedOptions.WeightsFormat() - self.keepNumDims = fullyConnectedOptions.KeepNumDims() - self.asymmetricQuantizeInputs = fullyConnectedOptions.AsymmetricQuantizeInputs() - self.quantizedBiasType = fullyConnectedOptions.QuantizedBiasType() - - # FullyConnectedOptionsT - def Pack(self, builder): - FullyConnectedOptionsStart(builder) - FullyConnectedOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - FullyConnectedOptionsAddWeightsFormat(builder, self.weightsFormat) - FullyConnectedOptionsAddKeepNumDims(builder, self.keepNumDims) - FullyConnectedOptionsAddAsymmetricQuantizeInputs(builder, self.asymmetricQuantizeInputs) - FullyConnectedOptionsAddQuantizedBiasType(builder, self.quantizedBiasType) - fullyConnectedOptions = FullyConnectedOptionsEnd(builder) - return fullyConnectedOptions - - -class SoftmaxOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SoftmaxOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSoftmaxOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SoftmaxOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SoftmaxOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SoftmaxOptions - def Beta(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - -def SoftmaxOptionsStart(builder): - builder.StartObject(1) - -def SoftmaxOptionsAddBeta(builder, beta): - builder.PrependFloat32Slot(0, beta, 0.0) - -def SoftmaxOptionsEnd(builder): - return builder.EndObject() - - - -class SoftmaxOptionsT(object): - - # SoftmaxOptionsT - def __init__( - self, - beta = 0.0, - ): - self.beta = beta # type: float - - @classmethod - def InitFromBuf(cls, buf, pos): - softmaxOptions = SoftmaxOptions() - softmaxOptions.Init(buf, pos) - return cls.InitFromObj(softmaxOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, softmaxOptions): - x = SoftmaxOptionsT() - x._UnPack(softmaxOptions) - return x - - # SoftmaxOptionsT - def _UnPack(self, softmaxOptions): - if softmaxOptions is None: - return - self.beta = softmaxOptions.Beta() - - # SoftmaxOptionsT - def Pack(self, builder): - SoftmaxOptionsStart(builder) - SoftmaxOptionsAddBeta(builder, self.beta) - softmaxOptions = SoftmaxOptionsEnd(builder) - return softmaxOptions - - -class ConcatenationOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ConcatenationOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsConcatenationOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ConcatenationOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ConcatenationOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ConcatenationOptions - def Axis(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # ConcatenationOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def ConcatenationOptionsStart(builder): - builder.StartObject(2) - -def ConcatenationOptionsAddAxis(builder, axis): - builder.PrependInt32Slot(0, axis, 0) - -def ConcatenationOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(1, fusedActivationFunction, 0) - -def ConcatenationOptionsEnd(builder): - return builder.EndObject() - - - -class ConcatenationOptionsT(object): - - # ConcatenationOptionsT - def __init__( - self, - axis = 0, - fusedActivationFunction = 0, - ): - self.axis = axis # type: int - self.fusedActivationFunction = fusedActivationFunction # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - concatenationOptions = ConcatenationOptions() - concatenationOptions.Init(buf, pos) - return cls.InitFromObj(concatenationOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, concatenationOptions): - x = ConcatenationOptionsT() - x._UnPack(concatenationOptions) - return x - - # ConcatenationOptionsT - def _UnPack(self, concatenationOptions): - if concatenationOptions is None: - return - self.axis = concatenationOptions.Axis() - self.fusedActivationFunction = concatenationOptions.FusedActivationFunction() - - # ConcatenationOptionsT - def Pack(self, builder): - ConcatenationOptionsStart(builder) - ConcatenationOptionsAddAxis(builder, self.axis) - ConcatenationOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - concatenationOptions = ConcatenationOptionsEnd(builder) - return concatenationOptions - - -class AddOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = AddOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsAddOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def AddOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # AddOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # AddOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # AddOptions - def PotScaleInt16(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return True - -def AddOptionsStart(builder): - builder.StartObject(2) - -def AddOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(0, fusedActivationFunction, 0) - -def AddOptionsAddPotScaleInt16(builder, potScaleInt16): - builder.PrependBoolSlot(1, potScaleInt16, 1) - -def AddOptionsEnd(builder): - return builder.EndObject() - - - -class AddOptionsT(object): - - # AddOptionsT - def __init__( - self, - fusedActivationFunction = 0, - potScaleInt16 = True, - ): - self.fusedActivationFunction = fusedActivationFunction # type: int - self.potScaleInt16 = potScaleInt16 # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - addOptions = AddOptions() - addOptions.Init(buf, pos) - return cls.InitFromObj(addOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, addOptions): - x = AddOptionsT() - x._UnPack(addOptions) - return x - - # AddOptionsT - def _UnPack(self, addOptions): - if addOptions is None: - return - self.fusedActivationFunction = addOptions.FusedActivationFunction() - self.potScaleInt16 = addOptions.PotScaleInt16() - - # AddOptionsT - def Pack(self, builder): - AddOptionsStart(builder) - AddOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - AddOptionsAddPotScaleInt16(builder, self.potScaleInt16) - addOptions = AddOptionsEnd(builder) - return addOptions - - -class MulOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = MulOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsMulOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def MulOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # MulOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # MulOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def MulOptionsStart(builder): - builder.StartObject(1) - -def MulOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(0, fusedActivationFunction, 0) - -def MulOptionsEnd(builder): - return builder.EndObject() - - - -class MulOptionsT(object): - - # MulOptionsT - def __init__( - self, - fusedActivationFunction = 0, - ): - self.fusedActivationFunction = fusedActivationFunction # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - mulOptions = MulOptions() - mulOptions.Init(buf, pos) - return cls.InitFromObj(mulOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, mulOptions): - x = MulOptionsT() - x._UnPack(mulOptions) - return x - - # MulOptionsT - def _UnPack(self, mulOptions): - if mulOptions is None: - return - self.fusedActivationFunction = mulOptions.FusedActivationFunction() - - # MulOptionsT - def Pack(self, builder): - MulOptionsStart(builder) - MulOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - mulOptions = MulOptionsEnd(builder) - return mulOptions - - -class L2NormOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = L2NormOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsL2NormOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def L2NormOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # L2NormOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # L2NormOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def L2NormOptionsStart(builder): - builder.StartObject(1) - -def L2NormOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(0, fusedActivationFunction, 0) - -def L2NormOptionsEnd(builder): - return builder.EndObject() - - - -class L2NormOptionsT(object): - - # L2NormOptionsT - def __init__( - self, - fusedActivationFunction = 0, - ): - self.fusedActivationFunction = fusedActivationFunction # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - l2NormOptions = L2NormOptions() - l2NormOptions.Init(buf, pos) - return cls.InitFromObj(l2NormOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, l2NormOptions): - x = L2NormOptionsT() - x._UnPack(l2NormOptions) - return x - - # L2NormOptionsT - def _UnPack(self, l2NormOptions): - if l2NormOptions is None: - return - self.fusedActivationFunction = l2NormOptions.FusedActivationFunction() - - # L2NormOptionsT - def Pack(self, builder): - L2NormOptionsStart(builder) - L2NormOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - l2NormOptions = L2NormOptionsEnd(builder) - return l2NormOptions - - -class LocalResponseNormalizationOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = LocalResponseNormalizationOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsLocalResponseNormalizationOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def LocalResponseNormalizationOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # LocalResponseNormalizationOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # LocalResponseNormalizationOptions - def Radius(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # LocalResponseNormalizationOptions - def Bias(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - - # LocalResponseNormalizationOptions - def Alpha(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - - # LocalResponseNormalizationOptions - def Beta(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - -def LocalResponseNormalizationOptionsStart(builder): - builder.StartObject(4) - -def LocalResponseNormalizationOptionsAddRadius(builder, radius): - builder.PrependInt32Slot(0, radius, 0) - -def LocalResponseNormalizationOptionsAddBias(builder, bias): - builder.PrependFloat32Slot(1, bias, 0.0) - -def LocalResponseNormalizationOptionsAddAlpha(builder, alpha): - builder.PrependFloat32Slot(2, alpha, 0.0) - -def LocalResponseNormalizationOptionsAddBeta(builder, beta): - builder.PrependFloat32Slot(3, beta, 0.0) - -def LocalResponseNormalizationOptionsEnd(builder): - return builder.EndObject() - - - -class LocalResponseNormalizationOptionsT(object): - - # LocalResponseNormalizationOptionsT - def __init__( - self, - radius = 0, - bias = 0.0, - alpha = 0.0, - beta = 0.0, - ): - self.radius = radius # type: int - self.bias = bias # type: float - self.alpha = alpha # type: float - self.beta = beta # type: float - - @classmethod - def InitFromBuf(cls, buf, pos): - localResponseNormalizationOptions = LocalResponseNormalizationOptions() - localResponseNormalizationOptions.Init(buf, pos) - return cls.InitFromObj(localResponseNormalizationOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, localResponseNormalizationOptions): - x = LocalResponseNormalizationOptionsT() - x._UnPack(localResponseNormalizationOptions) - return x - - # LocalResponseNormalizationOptionsT - def _UnPack(self, localResponseNormalizationOptions): - if localResponseNormalizationOptions is None: - return - self.radius = localResponseNormalizationOptions.Radius() - self.bias = localResponseNormalizationOptions.Bias() - self.alpha = localResponseNormalizationOptions.Alpha() - self.beta = localResponseNormalizationOptions.Beta() - - # LocalResponseNormalizationOptionsT - def Pack(self, builder): - LocalResponseNormalizationOptionsStart(builder) - LocalResponseNormalizationOptionsAddRadius(builder, self.radius) - LocalResponseNormalizationOptionsAddBias(builder, self.bias) - LocalResponseNormalizationOptionsAddAlpha(builder, self.alpha) - LocalResponseNormalizationOptionsAddBeta(builder, self.beta) - localResponseNormalizationOptions = LocalResponseNormalizationOptionsEnd(builder) - return localResponseNormalizationOptions - - -class LSTMOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = LSTMOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsLSTMOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def LSTMOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # LSTMOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # LSTMOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # LSTMOptions - def CellClip(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - - # LSTMOptions - def ProjClip(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - - # LSTMOptions - def KernelType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # LSTMOptions - def AsymmetricQuantizeInputs(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def LSTMOptionsStart(builder): - builder.StartObject(5) - -def LSTMOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(0, fusedActivationFunction, 0) - -def LSTMOptionsAddCellClip(builder, cellClip): - builder.PrependFloat32Slot(1, cellClip, 0.0) - -def LSTMOptionsAddProjClip(builder, projClip): - builder.PrependFloat32Slot(2, projClip, 0.0) - -def LSTMOptionsAddKernelType(builder, kernelType): - builder.PrependInt8Slot(3, kernelType, 0) - -def LSTMOptionsAddAsymmetricQuantizeInputs(builder, asymmetricQuantizeInputs): - builder.PrependBoolSlot(4, asymmetricQuantizeInputs, 0) - -def LSTMOptionsEnd(builder): - return builder.EndObject() - - - -class LSTMOptionsT(object): - - # LSTMOptionsT - def __init__( - self, - fusedActivationFunction = 0, - cellClip = 0.0, - projClip = 0.0, - kernelType = 0, - asymmetricQuantizeInputs = False, - ): - self.fusedActivationFunction = fusedActivationFunction # type: int - self.cellClip = cellClip # type: float - self.projClip = projClip # type: float - self.kernelType = kernelType # type: int - self.asymmetricQuantizeInputs = asymmetricQuantizeInputs # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - lstmoptions = LSTMOptions() - lstmoptions.Init(buf, pos) - return cls.InitFromObj(lstmoptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, lstmoptions): - x = LSTMOptionsT() - x._UnPack(lstmoptions) - return x - - # LSTMOptionsT - def _UnPack(self, lstmoptions): - if lstmoptions is None: - return - self.fusedActivationFunction = lstmoptions.FusedActivationFunction() - self.cellClip = lstmoptions.CellClip() - self.projClip = lstmoptions.ProjClip() - self.kernelType = lstmoptions.KernelType() - self.asymmetricQuantizeInputs = lstmoptions.AsymmetricQuantizeInputs() - - # LSTMOptionsT - def Pack(self, builder): - LSTMOptionsStart(builder) - LSTMOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - LSTMOptionsAddCellClip(builder, self.cellClip) - LSTMOptionsAddProjClip(builder, self.projClip) - LSTMOptionsAddKernelType(builder, self.kernelType) - LSTMOptionsAddAsymmetricQuantizeInputs(builder, self.asymmetricQuantizeInputs) - lstmoptions = LSTMOptionsEnd(builder) - return lstmoptions - - -class UnidirectionalSequenceLSTMOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = UnidirectionalSequenceLSTMOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsUnidirectionalSequenceLSTMOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def UnidirectionalSequenceLSTMOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # UnidirectionalSequenceLSTMOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # UnidirectionalSequenceLSTMOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # UnidirectionalSequenceLSTMOptions - def CellClip(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - - # UnidirectionalSequenceLSTMOptions - def ProjClip(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - - # UnidirectionalSequenceLSTMOptions - def TimeMajor(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # UnidirectionalSequenceLSTMOptions - def AsymmetricQuantizeInputs(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # UnidirectionalSequenceLSTMOptions - def DiagonalRecurrentTensors(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def UnidirectionalSequenceLSTMOptionsStart(builder): - builder.StartObject(6) - -def UnidirectionalSequenceLSTMOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(0, fusedActivationFunction, 0) - -def UnidirectionalSequenceLSTMOptionsAddCellClip(builder, cellClip): - builder.PrependFloat32Slot(1, cellClip, 0.0) - -def UnidirectionalSequenceLSTMOptionsAddProjClip(builder, projClip): - builder.PrependFloat32Slot(2, projClip, 0.0) - -def UnidirectionalSequenceLSTMOptionsAddTimeMajor(builder, timeMajor): - builder.PrependBoolSlot(3, timeMajor, 0) - -def UnidirectionalSequenceLSTMOptionsAddAsymmetricQuantizeInputs(builder, asymmetricQuantizeInputs): - builder.PrependBoolSlot(4, asymmetricQuantizeInputs, 0) - -def UnidirectionalSequenceLSTMOptionsAddDiagonalRecurrentTensors(builder, diagonalRecurrentTensors): - builder.PrependBoolSlot(5, diagonalRecurrentTensors, 0) - -def UnidirectionalSequenceLSTMOptionsEnd(builder): - return builder.EndObject() - - - -class UnidirectionalSequenceLSTMOptionsT(object): - - # UnidirectionalSequenceLSTMOptionsT - def __init__( - self, - fusedActivationFunction = 0, - cellClip = 0.0, - projClip = 0.0, - timeMajor = False, - asymmetricQuantizeInputs = False, - diagonalRecurrentTensors = False, - ): - self.fusedActivationFunction = fusedActivationFunction # type: int - self.cellClip = cellClip # type: float - self.projClip = projClip # type: float - self.timeMajor = timeMajor # type: bool - self.asymmetricQuantizeInputs = asymmetricQuantizeInputs # type: bool - self.diagonalRecurrentTensors = diagonalRecurrentTensors # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - unidirectionalSequenceLstmoptions = UnidirectionalSequenceLSTMOptions() - unidirectionalSequenceLstmoptions.Init(buf, pos) - return cls.InitFromObj(unidirectionalSequenceLstmoptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, unidirectionalSequenceLstmoptions): - x = UnidirectionalSequenceLSTMOptionsT() - x._UnPack(unidirectionalSequenceLstmoptions) - return x - - # UnidirectionalSequenceLSTMOptionsT - def _UnPack(self, unidirectionalSequenceLstmoptions): - if unidirectionalSequenceLstmoptions is None: - return - self.fusedActivationFunction = unidirectionalSequenceLstmoptions.FusedActivationFunction() - self.cellClip = unidirectionalSequenceLstmoptions.CellClip() - self.projClip = unidirectionalSequenceLstmoptions.ProjClip() - self.timeMajor = unidirectionalSequenceLstmoptions.TimeMajor() - self.asymmetricQuantizeInputs = unidirectionalSequenceLstmoptions.AsymmetricQuantizeInputs() - self.diagonalRecurrentTensors = unidirectionalSequenceLstmoptions.DiagonalRecurrentTensors() - - # UnidirectionalSequenceLSTMOptionsT - def Pack(self, builder): - UnidirectionalSequenceLSTMOptionsStart(builder) - UnidirectionalSequenceLSTMOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - UnidirectionalSequenceLSTMOptionsAddCellClip(builder, self.cellClip) - UnidirectionalSequenceLSTMOptionsAddProjClip(builder, self.projClip) - UnidirectionalSequenceLSTMOptionsAddTimeMajor(builder, self.timeMajor) - UnidirectionalSequenceLSTMOptionsAddAsymmetricQuantizeInputs(builder, self.asymmetricQuantizeInputs) - UnidirectionalSequenceLSTMOptionsAddDiagonalRecurrentTensors(builder, self.diagonalRecurrentTensors) - unidirectionalSequenceLstmoptions = UnidirectionalSequenceLSTMOptionsEnd(builder) - return unidirectionalSequenceLstmoptions - - -class BidirectionalSequenceLSTMOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = BidirectionalSequenceLSTMOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsBidirectionalSequenceLSTMOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def BidirectionalSequenceLSTMOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # BidirectionalSequenceLSTMOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # BidirectionalSequenceLSTMOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # BidirectionalSequenceLSTMOptions - def CellClip(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - - # BidirectionalSequenceLSTMOptions - def ProjClip(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - - # BidirectionalSequenceLSTMOptions - def MergeOutputs(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # BidirectionalSequenceLSTMOptions - def TimeMajor(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return True - - # BidirectionalSequenceLSTMOptions - def AsymmetricQuantizeInputs(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def BidirectionalSequenceLSTMOptionsStart(builder): - builder.StartObject(6) - -def BidirectionalSequenceLSTMOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(0, fusedActivationFunction, 0) - -def BidirectionalSequenceLSTMOptionsAddCellClip(builder, cellClip): - builder.PrependFloat32Slot(1, cellClip, 0.0) - -def BidirectionalSequenceLSTMOptionsAddProjClip(builder, projClip): - builder.PrependFloat32Slot(2, projClip, 0.0) - -def BidirectionalSequenceLSTMOptionsAddMergeOutputs(builder, mergeOutputs): - builder.PrependBoolSlot(3, mergeOutputs, 0) - -def BidirectionalSequenceLSTMOptionsAddTimeMajor(builder, timeMajor): - builder.PrependBoolSlot(4, timeMajor, 1) - -def BidirectionalSequenceLSTMOptionsAddAsymmetricQuantizeInputs(builder, asymmetricQuantizeInputs): - builder.PrependBoolSlot(5, asymmetricQuantizeInputs, 0) - -def BidirectionalSequenceLSTMOptionsEnd(builder): - return builder.EndObject() - - - -class BidirectionalSequenceLSTMOptionsT(object): - - # BidirectionalSequenceLSTMOptionsT - def __init__( - self, - fusedActivationFunction = 0, - cellClip = 0.0, - projClip = 0.0, - mergeOutputs = False, - timeMajor = True, - asymmetricQuantizeInputs = False, - ): - self.fusedActivationFunction = fusedActivationFunction # type: int - self.cellClip = cellClip # type: float - self.projClip = projClip # type: float - self.mergeOutputs = mergeOutputs # type: bool - self.timeMajor = timeMajor # type: bool - self.asymmetricQuantizeInputs = asymmetricQuantizeInputs # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - bidirectionalSequenceLstmoptions = BidirectionalSequenceLSTMOptions() - bidirectionalSequenceLstmoptions.Init(buf, pos) - return cls.InitFromObj(bidirectionalSequenceLstmoptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, bidirectionalSequenceLstmoptions): - x = BidirectionalSequenceLSTMOptionsT() - x._UnPack(bidirectionalSequenceLstmoptions) - return x - - # BidirectionalSequenceLSTMOptionsT - def _UnPack(self, bidirectionalSequenceLstmoptions): - if bidirectionalSequenceLstmoptions is None: - return - self.fusedActivationFunction = bidirectionalSequenceLstmoptions.FusedActivationFunction() - self.cellClip = bidirectionalSequenceLstmoptions.CellClip() - self.projClip = bidirectionalSequenceLstmoptions.ProjClip() - self.mergeOutputs = bidirectionalSequenceLstmoptions.MergeOutputs() - self.timeMajor = bidirectionalSequenceLstmoptions.TimeMajor() - self.asymmetricQuantizeInputs = bidirectionalSequenceLstmoptions.AsymmetricQuantizeInputs() - - # BidirectionalSequenceLSTMOptionsT - def Pack(self, builder): - BidirectionalSequenceLSTMOptionsStart(builder) - BidirectionalSequenceLSTMOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - BidirectionalSequenceLSTMOptionsAddCellClip(builder, self.cellClip) - BidirectionalSequenceLSTMOptionsAddProjClip(builder, self.projClip) - BidirectionalSequenceLSTMOptionsAddMergeOutputs(builder, self.mergeOutputs) - BidirectionalSequenceLSTMOptionsAddTimeMajor(builder, self.timeMajor) - BidirectionalSequenceLSTMOptionsAddAsymmetricQuantizeInputs(builder, self.asymmetricQuantizeInputs) - bidirectionalSequenceLstmoptions = BidirectionalSequenceLSTMOptionsEnd(builder) - return bidirectionalSequenceLstmoptions - - -class ResizeBilinearOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ResizeBilinearOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsResizeBilinearOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ResizeBilinearOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ResizeBilinearOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ResizeBilinearOptions - def AlignCorners(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # ResizeBilinearOptions - def HalfPixelCenters(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def ResizeBilinearOptionsStart(builder): - builder.StartObject(4) - -def ResizeBilinearOptionsAddAlignCorners(builder, alignCorners): - builder.PrependBoolSlot(2, alignCorners, 0) - -def ResizeBilinearOptionsAddHalfPixelCenters(builder, halfPixelCenters): - builder.PrependBoolSlot(3, halfPixelCenters, 0) - -def ResizeBilinearOptionsEnd(builder): - return builder.EndObject() - - - -class ResizeBilinearOptionsT(object): - - # ResizeBilinearOptionsT - def __init__( - self, - alignCorners = False, - halfPixelCenters = False, - ): - self.alignCorners = alignCorners # type: bool - self.halfPixelCenters = halfPixelCenters # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - resizeBilinearOptions = ResizeBilinearOptions() - resizeBilinearOptions.Init(buf, pos) - return cls.InitFromObj(resizeBilinearOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, resizeBilinearOptions): - x = ResizeBilinearOptionsT() - x._UnPack(resizeBilinearOptions) - return x - - # ResizeBilinearOptionsT - def _UnPack(self, resizeBilinearOptions): - if resizeBilinearOptions is None: - return - self.alignCorners = resizeBilinearOptions.AlignCorners() - self.halfPixelCenters = resizeBilinearOptions.HalfPixelCenters() - - # ResizeBilinearOptionsT - def Pack(self, builder): - ResizeBilinearOptionsStart(builder) - ResizeBilinearOptionsAddAlignCorners(builder, self.alignCorners) - ResizeBilinearOptionsAddHalfPixelCenters(builder, self.halfPixelCenters) - resizeBilinearOptions = ResizeBilinearOptionsEnd(builder) - return resizeBilinearOptions - - -class ResizeNearestNeighborOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ResizeNearestNeighborOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsResizeNearestNeighborOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ResizeNearestNeighborOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ResizeNearestNeighborOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ResizeNearestNeighborOptions - def AlignCorners(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # ResizeNearestNeighborOptions - def HalfPixelCenters(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def ResizeNearestNeighborOptionsStart(builder): - builder.StartObject(2) - -def ResizeNearestNeighborOptionsAddAlignCorners(builder, alignCorners): - builder.PrependBoolSlot(0, alignCorners, 0) - -def ResizeNearestNeighborOptionsAddHalfPixelCenters(builder, halfPixelCenters): - builder.PrependBoolSlot(1, halfPixelCenters, 0) - -def ResizeNearestNeighborOptionsEnd(builder): - return builder.EndObject() - - - -class ResizeNearestNeighborOptionsT(object): - - # ResizeNearestNeighborOptionsT - def __init__( - self, - alignCorners = False, - halfPixelCenters = False, - ): - self.alignCorners = alignCorners # type: bool - self.halfPixelCenters = halfPixelCenters # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - resizeNearestNeighborOptions = ResizeNearestNeighborOptions() - resizeNearestNeighborOptions.Init(buf, pos) - return cls.InitFromObj(resizeNearestNeighborOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, resizeNearestNeighborOptions): - x = ResizeNearestNeighborOptionsT() - x._UnPack(resizeNearestNeighborOptions) - return x - - # ResizeNearestNeighborOptionsT - def _UnPack(self, resizeNearestNeighborOptions): - if resizeNearestNeighborOptions is None: - return - self.alignCorners = resizeNearestNeighborOptions.AlignCorners() - self.halfPixelCenters = resizeNearestNeighborOptions.HalfPixelCenters() - - # ResizeNearestNeighborOptionsT - def Pack(self, builder): - ResizeNearestNeighborOptionsStart(builder) - ResizeNearestNeighborOptionsAddAlignCorners(builder, self.alignCorners) - ResizeNearestNeighborOptionsAddHalfPixelCenters(builder, self.halfPixelCenters) - resizeNearestNeighborOptions = ResizeNearestNeighborOptionsEnd(builder) - return resizeNearestNeighborOptions - - -class CallOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = CallOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsCallOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def CallOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # CallOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # CallOptions - def Subgraph(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - -def CallOptionsStart(builder): - builder.StartObject(1) - -def CallOptionsAddSubgraph(builder, subgraph): - builder.PrependUint32Slot(0, subgraph, 0) - -def CallOptionsEnd(builder): - return builder.EndObject() - - - -class CallOptionsT(object): - - # CallOptionsT - def __init__( - self, - subgraph = 0, - ): - self.subgraph = subgraph # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - callOptions = CallOptions() - callOptions.Init(buf, pos) - return cls.InitFromObj(callOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, callOptions): - x = CallOptionsT() - x._UnPack(callOptions) - return x - - # CallOptionsT - def _UnPack(self, callOptions): - if callOptions is None: - return - self.subgraph = callOptions.Subgraph() - - # CallOptionsT - def Pack(self, builder): - CallOptionsStart(builder) - CallOptionsAddSubgraph(builder, self.subgraph) - callOptions = CallOptionsEnd(builder) - return callOptions - - -class PadOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = PadOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsPadOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def PadOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # PadOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def PadOptionsStart(builder): - builder.StartObject(0) - -def PadOptionsEnd(builder): - return builder.EndObject() - - - -class PadOptionsT(object): - - # PadOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - padOptions = PadOptions() - padOptions.Init(buf, pos) - return cls.InitFromObj(padOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, padOptions): - x = PadOptionsT() - x._UnPack(padOptions) - return x - - # PadOptionsT - def _UnPack(self, padOptions): - if padOptions is None: - return - - # PadOptionsT - def Pack(self, builder): - PadOptionsStart(builder) - padOptions = PadOptionsEnd(builder) - return padOptions - - -class PadV2Options(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = PadV2Options() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsPadV2Options(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def PadV2OptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # PadV2Options - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def PadV2OptionsStart(builder): - builder.StartObject(0) - -def PadV2OptionsEnd(builder): - return builder.EndObject() - - - -class PadV2OptionsT(object): - - # PadV2OptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - padV2Options = PadV2Options() - padV2Options.Init(buf, pos) - return cls.InitFromObj(padV2Options) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, padV2Options): - x = PadV2OptionsT() - x._UnPack(padV2Options) - return x - - # PadV2OptionsT - def _UnPack(self, padV2Options): - if padV2Options is None: - return - - # PadV2OptionsT - def Pack(self, builder): - PadV2OptionsStart(builder) - padV2Options = PadV2OptionsEnd(builder) - return padV2Options - - -class ReshapeOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ReshapeOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsReshapeOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ReshapeOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ReshapeOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ReshapeOptions - def NewShape(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # ReshapeOptions - def NewShapeAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # ReshapeOptions - def NewShapeLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # ReshapeOptions - def NewShapeIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - -def ReshapeOptionsStart(builder): - builder.StartObject(1) - -def ReshapeOptionsAddNewShape(builder, newShape): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(newShape), 0) - -def ReshapeOptionsStartNewShapeVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def ReshapeOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class ReshapeOptionsT(object): - - # ReshapeOptionsT - def __init__( - self, - newShape = None, - ): - self.newShape = newShape # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - reshapeOptions = ReshapeOptions() - reshapeOptions.Init(buf, pos) - return cls.InitFromObj(reshapeOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, reshapeOptions): - x = ReshapeOptionsT() - x._UnPack(reshapeOptions) - return x - - # ReshapeOptionsT - def _UnPack(self, reshapeOptions): - if reshapeOptions is None: - return - if not reshapeOptions.NewShapeIsNone(): - if np is None: - self.newShape = [] - for i in range(reshapeOptions.NewShapeLength()): - self.newShape.append(reshapeOptions.NewShape(i)) - else: - self.newShape = reshapeOptions.NewShapeAsNumpy() - - # ReshapeOptionsT - def Pack(self, builder): - if self.newShape is not None: - if np is not None and type(self.newShape) is np.ndarray: - newShape = builder.CreateNumpyVector(self.newShape) - else: - ReshapeOptionsStartNewShapeVector(builder, len(self.newShape)) - for i in reversed(range(len(self.newShape))): - builder.PrependInt32(self.newShape[i]) - newShape = builder.EndVector() - ReshapeOptionsStart(builder) - if self.newShape is not None: - ReshapeOptionsAddNewShape(builder, newShape) - reshapeOptions = ReshapeOptionsEnd(builder) - return reshapeOptions - - -class SpaceToBatchNDOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SpaceToBatchNDOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSpaceToBatchNDOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SpaceToBatchNDOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SpaceToBatchNDOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def SpaceToBatchNDOptionsStart(builder): - builder.StartObject(0) - -def SpaceToBatchNDOptionsEnd(builder): - return builder.EndObject() - - - -class SpaceToBatchNDOptionsT(object): - - # SpaceToBatchNDOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - spaceToBatchNdoptions = SpaceToBatchNDOptions() - spaceToBatchNdoptions.Init(buf, pos) - return cls.InitFromObj(spaceToBatchNdoptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, spaceToBatchNdoptions): - x = SpaceToBatchNDOptionsT() - x._UnPack(spaceToBatchNdoptions) - return x - - # SpaceToBatchNDOptionsT - def _UnPack(self, spaceToBatchNdoptions): - if spaceToBatchNdoptions is None: - return - - # SpaceToBatchNDOptionsT - def Pack(self, builder): - SpaceToBatchNDOptionsStart(builder) - spaceToBatchNdoptions = SpaceToBatchNDOptionsEnd(builder) - return spaceToBatchNdoptions - - -class BatchToSpaceNDOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = BatchToSpaceNDOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsBatchToSpaceNDOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def BatchToSpaceNDOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # BatchToSpaceNDOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def BatchToSpaceNDOptionsStart(builder): - builder.StartObject(0) - -def BatchToSpaceNDOptionsEnd(builder): - return builder.EndObject() - - - -class BatchToSpaceNDOptionsT(object): - - # BatchToSpaceNDOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - batchToSpaceNdoptions = BatchToSpaceNDOptions() - batchToSpaceNdoptions.Init(buf, pos) - return cls.InitFromObj(batchToSpaceNdoptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, batchToSpaceNdoptions): - x = BatchToSpaceNDOptionsT() - x._UnPack(batchToSpaceNdoptions) - return x - - # BatchToSpaceNDOptionsT - def _UnPack(self, batchToSpaceNdoptions): - if batchToSpaceNdoptions is None: - return - - # BatchToSpaceNDOptionsT - def Pack(self, builder): - BatchToSpaceNDOptionsStart(builder) - batchToSpaceNdoptions = BatchToSpaceNDOptionsEnd(builder) - return batchToSpaceNdoptions - - -class SkipGramOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SkipGramOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSkipGramOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SkipGramOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SkipGramOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SkipGramOptions - def NgramSize(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # SkipGramOptions - def MaxSkipSize(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # SkipGramOptions - def IncludeAllNgrams(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def SkipGramOptionsStart(builder): - builder.StartObject(3) - -def SkipGramOptionsAddNgramSize(builder, ngramSize): - builder.PrependInt32Slot(0, ngramSize, 0) - -def SkipGramOptionsAddMaxSkipSize(builder, maxSkipSize): - builder.PrependInt32Slot(1, maxSkipSize, 0) - -def SkipGramOptionsAddIncludeAllNgrams(builder, includeAllNgrams): - builder.PrependBoolSlot(2, includeAllNgrams, 0) - -def SkipGramOptionsEnd(builder): - return builder.EndObject() - - - -class SkipGramOptionsT(object): - - # SkipGramOptionsT - def __init__( - self, - ngramSize = 0, - maxSkipSize = 0, - includeAllNgrams = False, - ): - self.ngramSize = ngramSize # type: int - self.maxSkipSize = maxSkipSize # type: int - self.includeAllNgrams = includeAllNgrams # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - skipGramOptions = SkipGramOptions() - skipGramOptions.Init(buf, pos) - return cls.InitFromObj(skipGramOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, skipGramOptions): - x = SkipGramOptionsT() - x._UnPack(skipGramOptions) - return x - - # SkipGramOptionsT - def _UnPack(self, skipGramOptions): - if skipGramOptions is None: - return - self.ngramSize = skipGramOptions.NgramSize() - self.maxSkipSize = skipGramOptions.MaxSkipSize() - self.includeAllNgrams = skipGramOptions.IncludeAllNgrams() - - # SkipGramOptionsT - def Pack(self, builder): - SkipGramOptionsStart(builder) - SkipGramOptionsAddNgramSize(builder, self.ngramSize) - SkipGramOptionsAddMaxSkipSize(builder, self.maxSkipSize) - SkipGramOptionsAddIncludeAllNgrams(builder, self.includeAllNgrams) - skipGramOptions = SkipGramOptionsEnd(builder) - return skipGramOptions - - -class SpaceToDepthOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SpaceToDepthOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSpaceToDepthOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SpaceToDepthOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SpaceToDepthOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SpaceToDepthOptions - def BlockSize(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def SpaceToDepthOptionsStart(builder): - builder.StartObject(1) - -def SpaceToDepthOptionsAddBlockSize(builder, blockSize): - builder.PrependInt32Slot(0, blockSize, 0) - -def SpaceToDepthOptionsEnd(builder): - return builder.EndObject() - - - -class SpaceToDepthOptionsT(object): - - # SpaceToDepthOptionsT - def __init__( - self, - blockSize = 0, - ): - self.blockSize = blockSize # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - spaceToDepthOptions = SpaceToDepthOptions() - spaceToDepthOptions.Init(buf, pos) - return cls.InitFromObj(spaceToDepthOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, spaceToDepthOptions): - x = SpaceToDepthOptionsT() - x._UnPack(spaceToDepthOptions) - return x - - # SpaceToDepthOptionsT - def _UnPack(self, spaceToDepthOptions): - if spaceToDepthOptions is None: - return - self.blockSize = spaceToDepthOptions.BlockSize() - - # SpaceToDepthOptionsT - def Pack(self, builder): - SpaceToDepthOptionsStart(builder) - SpaceToDepthOptionsAddBlockSize(builder, self.blockSize) - spaceToDepthOptions = SpaceToDepthOptionsEnd(builder) - return spaceToDepthOptions - - -class DepthToSpaceOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = DepthToSpaceOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsDepthToSpaceOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def DepthToSpaceOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # DepthToSpaceOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # DepthToSpaceOptions - def BlockSize(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def DepthToSpaceOptionsStart(builder): - builder.StartObject(1) - -def DepthToSpaceOptionsAddBlockSize(builder, blockSize): - builder.PrependInt32Slot(0, blockSize, 0) - -def DepthToSpaceOptionsEnd(builder): - return builder.EndObject() - - - -class DepthToSpaceOptionsT(object): - - # DepthToSpaceOptionsT - def __init__( - self, - blockSize = 0, - ): - self.blockSize = blockSize # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - depthToSpaceOptions = DepthToSpaceOptions() - depthToSpaceOptions.Init(buf, pos) - return cls.InitFromObj(depthToSpaceOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, depthToSpaceOptions): - x = DepthToSpaceOptionsT() - x._UnPack(depthToSpaceOptions) - return x - - # DepthToSpaceOptionsT - def _UnPack(self, depthToSpaceOptions): - if depthToSpaceOptions is None: - return - self.blockSize = depthToSpaceOptions.BlockSize() - - # DepthToSpaceOptionsT - def Pack(self, builder): - DepthToSpaceOptionsStart(builder) - DepthToSpaceOptionsAddBlockSize(builder, self.blockSize) - depthToSpaceOptions = DepthToSpaceOptionsEnd(builder) - return depthToSpaceOptions - - -class SubOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SubOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSubOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SubOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SubOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SubOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # SubOptions - def PotScaleInt16(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return True - -def SubOptionsStart(builder): - builder.StartObject(2) - -def SubOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(0, fusedActivationFunction, 0) - -def SubOptionsAddPotScaleInt16(builder, potScaleInt16): - builder.PrependBoolSlot(1, potScaleInt16, 1) - -def SubOptionsEnd(builder): - return builder.EndObject() - - - -class SubOptionsT(object): - - # SubOptionsT - def __init__( - self, - fusedActivationFunction = 0, - potScaleInt16 = True, - ): - self.fusedActivationFunction = fusedActivationFunction # type: int - self.potScaleInt16 = potScaleInt16 # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - subOptions = SubOptions() - subOptions.Init(buf, pos) - return cls.InitFromObj(subOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, subOptions): - x = SubOptionsT() - x._UnPack(subOptions) - return x - - # SubOptionsT - def _UnPack(self, subOptions): - if subOptions is None: - return - self.fusedActivationFunction = subOptions.FusedActivationFunction() - self.potScaleInt16 = subOptions.PotScaleInt16() - - # SubOptionsT - def Pack(self, builder): - SubOptionsStart(builder) - SubOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - SubOptionsAddPotScaleInt16(builder, self.potScaleInt16) - subOptions = SubOptionsEnd(builder) - return subOptions - - -class DivOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = DivOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsDivOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def DivOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # DivOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # DivOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def DivOptionsStart(builder): - builder.StartObject(1) - -def DivOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(0, fusedActivationFunction, 0) - -def DivOptionsEnd(builder): - return builder.EndObject() - - - -class DivOptionsT(object): - - # DivOptionsT - def __init__( - self, - fusedActivationFunction = 0, - ): - self.fusedActivationFunction = fusedActivationFunction # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - divOptions = DivOptions() - divOptions.Init(buf, pos) - return cls.InitFromObj(divOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, divOptions): - x = DivOptionsT() - x._UnPack(divOptions) - return x - - # DivOptionsT - def _UnPack(self, divOptions): - if divOptions is None: - return - self.fusedActivationFunction = divOptions.FusedActivationFunction() - - # DivOptionsT - def Pack(self, builder): - DivOptionsStart(builder) - DivOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - divOptions = DivOptionsEnd(builder) - return divOptions - - -class TopKV2Options(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = TopKV2Options() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsTopKV2Options(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def TopKV2OptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # TopKV2Options - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def TopKV2OptionsStart(builder): - builder.StartObject(0) - -def TopKV2OptionsEnd(builder): - return builder.EndObject() - - - -class TopKV2OptionsT(object): - - # TopKV2OptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - topKv2Options = TopKV2Options() - topKv2Options.Init(buf, pos) - return cls.InitFromObj(topKv2Options) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, topKv2Options): - x = TopKV2OptionsT() - x._UnPack(topKv2Options) - return x - - # TopKV2OptionsT - def _UnPack(self, topKv2Options): - if topKv2Options is None: - return - - # TopKV2OptionsT - def Pack(self, builder): - TopKV2OptionsStart(builder) - topKv2Options = TopKV2OptionsEnd(builder) - return topKv2Options - - -class EmbeddingLookupSparseOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = EmbeddingLookupSparseOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsEmbeddingLookupSparseOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def EmbeddingLookupSparseOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # EmbeddingLookupSparseOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # EmbeddingLookupSparseOptions - def Combiner(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def EmbeddingLookupSparseOptionsStart(builder): - builder.StartObject(1) - -def EmbeddingLookupSparseOptionsAddCombiner(builder, combiner): - builder.PrependInt8Slot(0, combiner, 0) - -def EmbeddingLookupSparseOptionsEnd(builder): - return builder.EndObject() - - - -class EmbeddingLookupSparseOptionsT(object): - - # EmbeddingLookupSparseOptionsT - def __init__( - self, - combiner = 0, - ): - self.combiner = combiner # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - embeddingLookupSparseOptions = EmbeddingLookupSparseOptions() - embeddingLookupSparseOptions.Init(buf, pos) - return cls.InitFromObj(embeddingLookupSparseOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, embeddingLookupSparseOptions): - x = EmbeddingLookupSparseOptionsT() - x._UnPack(embeddingLookupSparseOptions) - return x - - # EmbeddingLookupSparseOptionsT - def _UnPack(self, embeddingLookupSparseOptions): - if embeddingLookupSparseOptions is None: - return - self.combiner = embeddingLookupSparseOptions.Combiner() - - # EmbeddingLookupSparseOptionsT - def Pack(self, builder): - EmbeddingLookupSparseOptionsStart(builder) - EmbeddingLookupSparseOptionsAddCombiner(builder, self.combiner) - embeddingLookupSparseOptions = EmbeddingLookupSparseOptionsEnd(builder) - return embeddingLookupSparseOptions - - -class GatherOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = GatherOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsGatherOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def GatherOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # GatherOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # GatherOptions - def Axis(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # GatherOptions - def BatchDims(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def GatherOptionsStart(builder): - builder.StartObject(2) - -def GatherOptionsAddAxis(builder, axis): - builder.PrependInt32Slot(0, axis, 0) - -def GatherOptionsAddBatchDims(builder, batchDims): - builder.PrependInt32Slot(1, batchDims, 0) - -def GatherOptionsEnd(builder): - return builder.EndObject() - - - -class GatherOptionsT(object): - - # GatherOptionsT - def __init__( - self, - axis = 0, - batchDims = 0, - ): - self.axis = axis # type: int - self.batchDims = batchDims # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - gatherOptions = GatherOptions() - gatherOptions.Init(buf, pos) - return cls.InitFromObj(gatherOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, gatherOptions): - x = GatherOptionsT() - x._UnPack(gatherOptions) - return x - - # GatherOptionsT - def _UnPack(self, gatherOptions): - if gatherOptions is None: - return - self.axis = gatherOptions.Axis() - self.batchDims = gatherOptions.BatchDims() - - # GatherOptionsT - def Pack(self, builder): - GatherOptionsStart(builder) - GatherOptionsAddAxis(builder, self.axis) - GatherOptionsAddBatchDims(builder, self.batchDims) - gatherOptions = GatherOptionsEnd(builder) - return gatherOptions - - -class TransposeOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = TransposeOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsTransposeOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def TransposeOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # TransposeOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def TransposeOptionsStart(builder): - builder.StartObject(0) - -def TransposeOptionsEnd(builder): - return builder.EndObject() - - - -class TransposeOptionsT(object): - - # TransposeOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - transposeOptions = TransposeOptions() - transposeOptions.Init(buf, pos) - return cls.InitFromObj(transposeOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, transposeOptions): - x = TransposeOptionsT() - x._UnPack(transposeOptions) - return x - - # TransposeOptionsT - def _UnPack(self, transposeOptions): - if transposeOptions is None: - return - - # TransposeOptionsT - def Pack(self, builder): - TransposeOptionsStart(builder) - transposeOptions = TransposeOptionsEnd(builder) - return transposeOptions - - -class ExpOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ExpOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsExpOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ExpOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ExpOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def ExpOptionsStart(builder): - builder.StartObject(0) - -def ExpOptionsEnd(builder): - return builder.EndObject() - - - -class ExpOptionsT(object): - - # ExpOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - expOptions = ExpOptions() - expOptions.Init(buf, pos) - return cls.InitFromObj(expOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, expOptions): - x = ExpOptionsT() - x._UnPack(expOptions) - return x - - # ExpOptionsT - def _UnPack(self, expOptions): - if expOptions is None: - return - - # ExpOptionsT - def Pack(self, builder): - ExpOptionsStart(builder) - expOptions = ExpOptionsEnd(builder) - return expOptions - - -class CosOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = CosOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsCosOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def CosOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # CosOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def CosOptionsStart(builder): - builder.StartObject(0) - -def CosOptionsEnd(builder): - return builder.EndObject() - - - -class CosOptionsT(object): - - # CosOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - cosOptions = CosOptions() - cosOptions.Init(buf, pos) - return cls.InitFromObj(cosOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, cosOptions): - x = CosOptionsT() - x._UnPack(cosOptions) - return x - - # CosOptionsT - def _UnPack(self, cosOptions): - if cosOptions is None: - return - - # CosOptionsT - def Pack(self, builder): - CosOptionsStart(builder) - cosOptions = CosOptionsEnd(builder) - return cosOptions - - -class ReducerOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ReducerOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsReducerOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ReducerOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ReducerOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ReducerOptions - def KeepDims(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def ReducerOptionsStart(builder): - builder.StartObject(1) - -def ReducerOptionsAddKeepDims(builder, keepDims): - builder.PrependBoolSlot(0, keepDims, 0) - -def ReducerOptionsEnd(builder): - return builder.EndObject() - - - -class ReducerOptionsT(object): - - # ReducerOptionsT - def __init__( - self, - keepDims = False, - ): - self.keepDims = keepDims # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - reducerOptions = ReducerOptions() - reducerOptions.Init(buf, pos) - return cls.InitFromObj(reducerOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, reducerOptions): - x = ReducerOptionsT() - x._UnPack(reducerOptions) - return x - - # ReducerOptionsT - def _UnPack(self, reducerOptions): - if reducerOptions is None: - return - self.keepDims = reducerOptions.KeepDims() - - # ReducerOptionsT - def Pack(self, builder): - ReducerOptionsStart(builder) - ReducerOptionsAddKeepDims(builder, self.keepDims) - reducerOptions = ReducerOptionsEnd(builder) - return reducerOptions - - -class SqueezeOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SqueezeOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSqueezeOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SqueezeOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SqueezeOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SqueezeOptions - def SqueezeDims(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # SqueezeOptions - def SqueezeDimsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # SqueezeOptions - def SqueezeDimsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # SqueezeOptions - def SqueezeDimsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - -def SqueezeOptionsStart(builder): - builder.StartObject(1) - -def SqueezeOptionsAddSqueezeDims(builder, squeezeDims): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(squeezeDims), 0) - -def SqueezeOptionsStartSqueezeDimsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def SqueezeOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class SqueezeOptionsT(object): - - # SqueezeOptionsT - def __init__( - self, - squeezeDims = None, - ): - self.squeezeDims = squeezeDims # type: Optional[List[int]] - - @classmethod - def InitFromBuf(cls, buf, pos): - squeezeOptions = SqueezeOptions() - squeezeOptions.Init(buf, pos) - return cls.InitFromObj(squeezeOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, squeezeOptions): - x = SqueezeOptionsT() - x._UnPack(squeezeOptions) - return x - - # SqueezeOptionsT - def _UnPack(self, squeezeOptions): - if squeezeOptions is None: - return - if not squeezeOptions.SqueezeDimsIsNone(): - if np is None: - self.squeezeDims = [] - for i in range(squeezeOptions.SqueezeDimsLength()): - self.squeezeDims.append(squeezeOptions.SqueezeDims(i)) - else: - self.squeezeDims = squeezeOptions.SqueezeDimsAsNumpy() - - # SqueezeOptionsT - def Pack(self, builder): - if self.squeezeDims is not None: - if np is not None and type(self.squeezeDims) is np.ndarray: - squeezeDims = builder.CreateNumpyVector(self.squeezeDims) - else: - SqueezeOptionsStartSqueezeDimsVector(builder, len(self.squeezeDims)) - for i in reversed(range(len(self.squeezeDims))): - builder.PrependInt32(self.squeezeDims[i]) - squeezeDims = builder.EndVector() - SqueezeOptionsStart(builder) - if self.squeezeDims is not None: - SqueezeOptionsAddSqueezeDims(builder, squeezeDims) - squeezeOptions = SqueezeOptionsEnd(builder) - return squeezeOptions - - -class SplitOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SplitOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSplitOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SplitOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SplitOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SplitOptions - def NumSplits(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def SplitOptionsStart(builder): - builder.StartObject(1) - -def SplitOptionsAddNumSplits(builder, numSplits): - builder.PrependInt32Slot(0, numSplits, 0) - -def SplitOptionsEnd(builder): - return builder.EndObject() - - - -class SplitOptionsT(object): - - # SplitOptionsT - def __init__( - self, - numSplits = 0, - ): - self.numSplits = numSplits # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - splitOptions = SplitOptions() - splitOptions.Init(buf, pos) - return cls.InitFromObj(splitOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, splitOptions): - x = SplitOptionsT() - x._UnPack(splitOptions) - return x - - # SplitOptionsT - def _UnPack(self, splitOptions): - if splitOptions is None: - return - self.numSplits = splitOptions.NumSplits() - - # SplitOptionsT - def Pack(self, builder): - SplitOptionsStart(builder) - SplitOptionsAddNumSplits(builder, self.numSplits) - splitOptions = SplitOptionsEnd(builder) - return splitOptions - - -class SplitVOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SplitVOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSplitVOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SplitVOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SplitVOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SplitVOptions - def NumSplits(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def SplitVOptionsStart(builder): - builder.StartObject(1) - -def SplitVOptionsAddNumSplits(builder, numSplits): - builder.PrependInt32Slot(0, numSplits, 0) - -def SplitVOptionsEnd(builder): - return builder.EndObject() - - - -class SplitVOptionsT(object): - - # SplitVOptionsT - def __init__( - self, - numSplits = 0, - ): - self.numSplits = numSplits # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - splitVoptions = SplitVOptions() - splitVoptions.Init(buf, pos) - return cls.InitFromObj(splitVoptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, splitVoptions): - x = SplitVOptionsT() - x._UnPack(splitVoptions) - return x - - # SplitVOptionsT - def _UnPack(self, splitVoptions): - if splitVoptions is None: - return - self.numSplits = splitVoptions.NumSplits() - - # SplitVOptionsT - def Pack(self, builder): - SplitVOptionsStart(builder) - SplitVOptionsAddNumSplits(builder, self.numSplits) - splitVoptions = SplitVOptionsEnd(builder) - return splitVoptions - - -class StridedSliceOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StridedSliceOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStridedSliceOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StridedSliceOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StridedSliceOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StridedSliceOptions - def BeginMask(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # StridedSliceOptions - def EndMask(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # StridedSliceOptions - def EllipsisMask(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # StridedSliceOptions - def NewAxisMask(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # StridedSliceOptions - def ShrinkAxisMask(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # StridedSliceOptions - def Offset(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def StridedSliceOptionsStart(builder): - builder.StartObject(6) - -def StridedSliceOptionsAddBeginMask(builder, beginMask): - builder.PrependInt32Slot(0, beginMask, 0) - -def StridedSliceOptionsAddEndMask(builder, endMask): - builder.PrependInt32Slot(1, endMask, 0) - -def StridedSliceOptionsAddEllipsisMask(builder, ellipsisMask): - builder.PrependInt32Slot(2, ellipsisMask, 0) - -def StridedSliceOptionsAddNewAxisMask(builder, newAxisMask): - builder.PrependInt32Slot(3, newAxisMask, 0) - -def StridedSliceOptionsAddShrinkAxisMask(builder, shrinkAxisMask): - builder.PrependInt32Slot(4, shrinkAxisMask, 0) - -def StridedSliceOptionsAddOffset(builder, offset): - builder.PrependBoolSlot(5, offset, 0) - -def StridedSliceOptionsEnd(builder): - return builder.EndObject() - - - -class StridedSliceOptionsT(object): - - # StridedSliceOptionsT - def __init__( - self, - beginMask = 0, - endMask = 0, - ellipsisMask = 0, - newAxisMask = 0, - shrinkAxisMask = 0, - offset = False, - ): - self.beginMask = beginMask # type: int - self.endMask = endMask # type: int - self.ellipsisMask = ellipsisMask # type: int - self.newAxisMask = newAxisMask # type: int - self.shrinkAxisMask = shrinkAxisMask # type: int - self.offset = offset # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - stridedSliceOptions = StridedSliceOptions() - stridedSliceOptions.Init(buf, pos) - return cls.InitFromObj(stridedSliceOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stridedSliceOptions): - x = StridedSliceOptionsT() - x._UnPack(stridedSliceOptions) - return x - - # StridedSliceOptionsT - def _UnPack(self, stridedSliceOptions): - if stridedSliceOptions is None: - return - self.beginMask = stridedSliceOptions.BeginMask() - self.endMask = stridedSliceOptions.EndMask() - self.ellipsisMask = stridedSliceOptions.EllipsisMask() - self.newAxisMask = stridedSliceOptions.NewAxisMask() - self.shrinkAxisMask = stridedSliceOptions.ShrinkAxisMask() - self.offset = stridedSliceOptions.Offset() - - # StridedSliceOptionsT - def Pack(self, builder): - StridedSliceOptionsStart(builder) - StridedSliceOptionsAddBeginMask(builder, self.beginMask) - StridedSliceOptionsAddEndMask(builder, self.endMask) - StridedSliceOptionsAddEllipsisMask(builder, self.ellipsisMask) - StridedSliceOptionsAddNewAxisMask(builder, self.newAxisMask) - StridedSliceOptionsAddShrinkAxisMask(builder, self.shrinkAxisMask) - StridedSliceOptionsAddOffset(builder, self.offset) - stridedSliceOptions = StridedSliceOptionsEnd(builder) - return stridedSliceOptions - - -class LogSoftmaxOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = LogSoftmaxOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsLogSoftmaxOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def LogSoftmaxOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # LogSoftmaxOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def LogSoftmaxOptionsStart(builder): - builder.StartObject(0) - -def LogSoftmaxOptionsEnd(builder): - return builder.EndObject() - - - -class LogSoftmaxOptionsT(object): - - # LogSoftmaxOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - logSoftmaxOptions = LogSoftmaxOptions() - logSoftmaxOptions.Init(buf, pos) - return cls.InitFromObj(logSoftmaxOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, logSoftmaxOptions): - x = LogSoftmaxOptionsT() - x._UnPack(logSoftmaxOptions) - return x - - # LogSoftmaxOptionsT - def _UnPack(self, logSoftmaxOptions): - if logSoftmaxOptions is None: - return - - # LogSoftmaxOptionsT - def Pack(self, builder): - LogSoftmaxOptionsStart(builder) - logSoftmaxOptions = LogSoftmaxOptionsEnd(builder) - return logSoftmaxOptions - - -class CastOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = CastOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsCastOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def CastOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # CastOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # CastOptions - def InDataType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # CastOptions - def OutDataType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def CastOptionsStart(builder): - builder.StartObject(2) - -def CastOptionsAddInDataType(builder, inDataType): - builder.PrependInt8Slot(0, inDataType, 0) - -def CastOptionsAddOutDataType(builder, outDataType): - builder.PrependInt8Slot(1, outDataType, 0) - -def CastOptionsEnd(builder): - return builder.EndObject() - - - -class CastOptionsT(object): - - # CastOptionsT - def __init__( - self, - inDataType = 0, - outDataType = 0, - ): - self.inDataType = inDataType # type: int - self.outDataType = outDataType # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - castOptions = CastOptions() - castOptions.Init(buf, pos) - return cls.InitFromObj(castOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, castOptions): - x = CastOptionsT() - x._UnPack(castOptions) - return x - - # CastOptionsT - def _UnPack(self, castOptions): - if castOptions is None: - return - self.inDataType = castOptions.InDataType() - self.outDataType = castOptions.OutDataType() - - # CastOptionsT - def Pack(self, builder): - CastOptionsStart(builder) - CastOptionsAddInDataType(builder, self.inDataType) - CastOptionsAddOutDataType(builder, self.outDataType) - castOptions = CastOptionsEnd(builder) - return castOptions - - -class DequantizeOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = DequantizeOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsDequantizeOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def DequantizeOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # DequantizeOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def DequantizeOptionsStart(builder): - builder.StartObject(0) - -def DequantizeOptionsEnd(builder): - return builder.EndObject() - - - -class DequantizeOptionsT(object): - - # DequantizeOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - dequantizeOptions = DequantizeOptions() - dequantizeOptions.Init(buf, pos) - return cls.InitFromObj(dequantizeOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, dequantizeOptions): - x = DequantizeOptionsT() - x._UnPack(dequantizeOptions) - return x - - # DequantizeOptionsT - def _UnPack(self, dequantizeOptions): - if dequantizeOptions is None: - return - - # DequantizeOptionsT - def Pack(self, builder): - DequantizeOptionsStart(builder) - dequantizeOptions = DequantizeOptionsEnd(builder) - return dequantizeOptions - - -class MaximumMinimumOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = MaximumMinimumOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsMaximumMinimumOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def MaximumMinimumOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # MaximumMinimumOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def MaximumMinimumOptionsStart(builder): - builder.StartObject(0) - -def MaximumMinimumOptionsEnd(builder): - return builder.EndObject() - - - -class MaximumMinimumOptionsT(object): - - # MaximumMinimumOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - maximumMinimumOptions = MaximumMinimumOptions() - maximumMinimumOptions.Init(buf, pos) - return cls.InitFromObj(maximumMinimumOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, maximumMinimumOptions): - x = MaximumMinimumOptionsT() - x._UnPack(maximumMinimumOptions) - return x - - # MaximumMinimumOptionsT - def _UnPack(self, maximumMinimumOptions): - if maximumMinimumOptions is None: - return - - # MaximumMinimumOptionsT - def Pack(self, builder): - MaximumMinimumOptionsStart(builder) - maximumMinimumOptions = MaximumMinimumOptionsEnd(builder) - return maximumMinimumOptions - - -class TileOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = TileOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsTileOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def TileOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # TileOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def TileOptionsStart(builder): - builder.StartObject(0) - -def TileOptionsEnd(builder): - return builder.EndObject() - - - -class TileOptionsT(object): - - # TileOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - tileOptions = TileOptions() - tileOptions.Init(buf, pos) - return cls.InitFromObj(tileOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, tileOptions): - x = TileOptionsT() - x._UnPack(tileOptions) - return x - - # TileOptionsT - def _UnPack(self, tileOptions): - if tileOptions is None: - return - - # TileOptionsT - def Pack(self, builder): - TileOptionsStart(builder) - tileOptions = TileOptionsEnd(builder) - return tileOptions - - -class ArgMaxOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ArgMaxOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsArgMaxOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ArgMaxOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ArgMaxOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ArgMaxOptions - def OutputType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def ArgMaxOptionsStart(builder): - builder.StartObject(1) - -def ArgMaxOptionsAddOutputType(builder, outputType): - builder.PrependInt8Slot(0, outputType, 0) - -def ArgMaxOptionsEnd(builder): - return builder.EndObject() - - - -class ArgMaxOptionsT(object): - - # ArgMaxOptionsT - def __init__( - self, - outputType = 0, - ): - self.outputType = outputType # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - argMaxOptions = ArgMaxOptions() - argMaxOptions.Init(buf, pos) - return cls.InitFromObj(argMaxOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, argMaxOptions): - x = ArgMaxOptionsT() - x._UnPack(argMaxOptions) - return x - - # ArgMaxOptionsT - def _UnPack(self, argMaxOptions): - if argMaxOptions is None: - return - self.outputType = argMaxOptions.OutputType() - - # ArgMaxOptionsT - def Pack(self, builder): - ArgMaxOptionsStart(builder) - ArgMaxOptionsAddOutputType(builder, self.outputType) - argMaxOptions = ArgMaxOptionsEnd(builder) - return argMaxOptions - - -class ArgMinOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ArgMinOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsArgMinOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ArgMinOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ArgMinOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ArgMinOptions - def OutputType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def ArgMinOptionsStart(builder): - builder.StartObject(1) - -def ArgMinOptionsAddOutputType(builder, outputType): - builder.PrependInt8Slot(0, outputType, 0) - -def ArgMinOptionsEnd(builder): - return builder.EndObject() - - - -class ArgMinOptionsT(object): - - # ArgMinOptionsT - def __init__( - self, - outputType = 0, - ): - self.outputType = outputType # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - argMinOptions = ArgMinOptions() - argMinOptions.Init(buf, pos) - return cls.InitFromObj(argMinOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, argMinOptions): - x = ArgMinOptionsT() - x._UnPack(argMinOptions) - return x - - # ArgMinOptionsT - def _UnPack(self, argMinOptions): - if argMinOptions is None: - return - self.outputType = argMinOptions.OutputType() - - # ArgMinOptionsT - def Pack(self, builder): - ArgMinOptionsStart(builder) - ArgMinOptionsAddOutputType(builder, self.outputType) - argMinOptions = ArgMinOptionsEnd(builder) - return argMinOptions - - -class GreaterOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = GreaterOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsGreaterOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def GreaterOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # GreaterOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def GreaterOptionsStart(builder): - builder.StartObject(0) - -def GreaterOptionsEnd(builder): - return builder.EndObject() - - - -class GreaterOptionsT(object): - - # GreaterOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - greaterOptions = GreaterOptions() - greaterOptions.Init(buf, pos) - return cls.InitFromObj(greaterOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, greaterOptions): - x = GreaterOptionsT() - x._UnPack(greaterOptions) - return x - - # GreaterOptionsT - def _UnPack(self, greaterOptions): - if greaterOptions is None: - return - - # GreaterOptionsT - def Pack(self, builder): - GreaterOptionsStart(builder) - greaterOptions = GreaterOptionsEnd(builder) - return greaterOptions - - -class GreaterEqualOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = GreaterEqualOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsGreaterEqualOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def GreaterEqualOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # GreaterEqualOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def GreaterEqualOptionsStart(builder): - builder.StartObject(0) - -def GreaterEqualOptionsEnd(builder): - return builder.EndObject() - - - -class GreaterEqualOptionsT(object): - - # GreaterEqualOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - greaterEqualOptions = GreaterEqualOptions() - greaterEqualOptions.Init(buf, pos) - return cls.InitFromObj(greaterEqualOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, greaterEqualOptions): - x = GreaterEqualOptionsT() - x._UnPack(greaterEqualOptions) - return x - - # GreaterEqualOptionsT - def _UnPack(self, greaterEqualOptions): - if greaterEqualOptions is None: - return - - # GreaterEqualOptionsT - def Pack(self, builder): - GreaterEqualOptionsStart(builder) - greaterEqualOptions = GreaterEqualOptionsEnd(builder) - return greaterEqualOptions - - -class LessOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = LessOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsLessOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def LessOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # LessOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def LessOptionsStart(builder): - builder.StartObject(0) - -def LessOptionsEnd(builder): - return builder.EndObject() - - - -class LessOptionsT(object): - - # LessOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - lessOptions = LessOptions() - lessOptions.Init(buf, pos) - return cls.InitFromObj(lessOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, lessOptions): - x = LessOptionsT() - x._UnPack(lessOptions) - return x - - # LessOptionsT - def _UnPack(self, lessOptions): - if lessOptions is None: - return - - # LessOptionsT - def Pack(self, builder): - LessOptionsStart(builder) - lessOptions = LessOptionsEnd(builder) - return lessOptions - - -class LessEqualOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = LessEqualOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsLessEqualOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def LessEqualOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # LessEqualOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def LessEqualOptionsStart(builder): - builder.StartObject(0) - -def LessEqualOptionsEnd(builder): - return builder.EndObject() - - - -class LessEqualOptionsT(object): - - # LessEqualOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - lessEqualOptions = LessEqualOptions() - lessEqualOptions.Init(buf, pos) - return cls.InitFromObj(lessEqualOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, lessEqualOptions): - x = LessEqualOptionsT() - x._UnPack(lessEqualOptions) - return x - - # LessEqualOptionsT - def _UnPack(self, lessEqualOptions): - if lessEqualOptions is None: - return - - # LessEqualOptionsT - def Pack(self, builder): - LessEqualOptionsStart(builder) - lessEqualOptions = LessEqualOptionsEnd(builder) - return lessEqualOptions - - -class NegOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = NegOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsNegOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def NegOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # NegOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def NegOptionsStart(builder): - builder.StartObject(0) - -def NegOptionsEnd(builder): - return builder.EndObject() - - - -class NegOptionsT(object): - - # NegOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - negOptions = NegOptions() - negOptions.Init(buf, pos) - return cls.InitFromObj(negOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, negOptions): - x = NegOptionsT() - x._UnPack(negOptions) - return x - - # NegOptionsT - def _UnPack(self, negOptions): - if negOptions is None: - return - - # NegOptionsT - def Pack(self, builder): - NegOptionsStart(builder) - negOptions = NegOptionsEnd(builder) - return negOptions - - -class SelectOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SelectOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSelectOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SelectOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SelectOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def SelectOptionsStart(builder): - builder.StartObject(0) - -def SelectOptionsEnd(builder): - return builder.EndObject() - - - -class SelectOptionsT(object): - - # SelectOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - selectOptions = SelectOptions() - selectOptions.Init(buf, pos) - return cls.InitFromObj(selectOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, selectOptions): - x = SelectOptionsT() - x._UnPack(selectOptions) - return x - - # SelectOptionsT - def _UnPack(self, selectOptions): - if selectOptions is None: - return - - # SelectOptionsT - def Pack(self, builder): - SelectOptionsStart(builder) - selectOptions = SelectOptionsEnd(builder) - return selectOptions - - -class SliceOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SliceOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSliceOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SliceOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SliceOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def SliceOptionsStart(builder): - builder.StartObject(0) - -def SliceOptionsEnd(builder): - return builder.EndObject() - - - -class SliceOptionsT(object): - - # SliceOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - sliceOptions = SliceOptions() - sliceOptions.Init(buf, pos) - return cls.InitFromObj(sliceOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, sliceOptions): - x = SliceOptionsT() - x._UnPack(sliceOptions) - return x - - # SliceOptionsT - def _UnPack(self, sliceOptions): - if sliceOptions is None: - return - - # SliceOptionsT - def Pack(self, builder): - SliceOptionsStart(builder) - sliceOptions = SliceOptionsEnd(builder) - return sliceOptions - - -class TransposeConvOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = TransposeConvOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsTransposeConvOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def TransposeConvOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # TransposeConvOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # TransposeConvOptions - def Padding(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # TransposeConvOptions - def StrideW(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # TransposeConvOptions - def StrideH(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # TransposeConvOptions - def FusedActivationFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # TransposeConvOptions - def QuantizedBiasType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def TransposeConvOptionsStart(builder): - builder.StartObject(5) - -def TransposeConvOptionsAddPadding(builder, padding): - builder.PrependInt8Slot(0, padding, 0) - -def TransposeConvOptionsAddStrideW(builder, strideW): - builder.PrependInt32Slot(1, strideW, 0) - -def TransposeConvOptionsAddStrideH(builder, strideH): - builder.PrependInt32Slot(2, strideH, 0) - -def TransposeConvOptionsAddFusedActivationFunction(builder, fusedActivationFunction): - builder.PrependInt8Slot(3, fusedActivationFunction, 0) - -def TransposeConvOptionsAddQuantizedBiasType(builder, quantizedBiasType): - builder.PrependInt8Slot(4, quantizedBiasType, 0) - -def TransposeConvOptionsEnd(builder): - return builder.EndObject() - - - -class TransposeConvOptionsT(object): - - # TransposeConvOptionsT - def __init__( - self, - padding = 0, - strideW = 0, - strideH = 0, - fusedActivationFunction = 0, - quantizedBiasType = 0, - ): - self.padding = padding # type: int - self.strideW = strideW # type: int - self.strideH = strideH # type: int - self.fusedActivationFunction = fusedActivationFunction # type: int - self.quantizedBiasType = quantizedBiasType # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - transposeConvOptions = TransposeConvOptions() - transposeConvOptions.Init(buf, pos) - return cls.InitFromObj(transposeConvOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, transposeConvOptions): - x = TransposeConvOptionsT() - x._UnPack(transposeConvOptions) - return x - - # TransposeConvOptionsT - def _UnPack(self, transposeConvOptions): - if transposeConvOptions is None: - return - self.padding = transposeConvOptions.Padding() - self.strideW = transposeConvOptions.StrideW() - self.strideH = transposeConvOptions.StrideH() - self.fusedActivationFunction = transposeConvOptions.FusedActivationFunction() - self.quantizedBiasType = transposeConvOptions.QuantizedBiasType() - - # TransposeConvOptionsT - def Pack(self, builder): - TransposeConvOptionsStart(builder) - TransposeConvOptionsAddPadding(builder, self.padding) - TransposeConvOptionsAddStrideW(builder, self.strideW) - TransposeConvOptionsAddStrideH(builder, self.strideH) - TransposeConvOptionsAddFusedActivationFunction(builder, self.fusedActivationFunction) - TransposeConvOptionsAddQuantizedBiasType(builder, self.quantizedBiasType) - transposeConvOptions = TransposeConvOptionsEnd(builder) - return transposeConvOptions - - -class ExpandDimsOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ExpandDimsOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsExpandDimsOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ExpandDimsOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ExpandDimsOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def ExpandDimsOptionsStart(builder): - builder.StartObject(0) - -def ExpandDimsOptionsEnd(builder): - return builder.EndObject() - - - -class ExpandDimsOptionsT(object): - - # ExpandDimsOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - expandDimsOptions = ExpandDimsOptions() - expandDimsOptions.Init(buf, pos) - return cls.InitFromObj(expandDimsOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, expandDimsOptions): - x = ExpandDimsOptionsT() - x._UnPack(expandDimsOptions) - return x - - # ExpandDimsOptionsT - def _UnPack(self, expandDimsOptions): - if expandDimsOptions is None: - return - - # ExpandDimsOptionsT - def Pack(self, builder): - ExpandDimsOptionsStart(builder) - expandDimsOptions = ExpandDimsOptionsEnd(builder) - return expandDimsOptions - - -class SparseToDenseOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SparseToDenseOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSparseToDenseOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SparseToDenseOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SparseToDenseOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SparseToDenseOptions - def ValidateIndices(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def SparseToDenseOptionsStart(builder): - builder.StartObject(1) - -def SparseToDenseOptionsAddValidateIndices(builder, validateIndices): - builder.PrependBoolSlot(0, validateIndices, 0) - -def SparseToDenseOptionsEnd(builder): - return builder.EndObject() - - - -class SparseToDenseOptionsT(object): - - # SparseToDenseOptionsT - def __init__( - self, - validateIndices = False, - ): - self.validateIndices = validateIndices # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - sparseToDenseOptions = SparseToDenseOptions() - sparseToDenseOptions.Init(buf, pos) - return cls.InitFromObj(sparseToDenseOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, sparseToDenseOptions): - x = SparseToDenseOptionsT() - x._UnPack(sparseToDenseOptions) - return x - - # SparseToDenseOptionsT - def _UnPack(self, sparseToDenseOptions): - if sparseToDenseOptions is None: - return - self.validateIndices = sparseToDenseOptions.ValidateIndices() - - # SparseToDenseOptionsT - def Pack(self, builder): - SparseToDenseOptionsStart(builder) - SparseToDenseOptionsAddValidateIndices(builder, self.validateIndices) - sparseToDenseOptions = SparseToDenseOptionsEnd(builder) - return sparseToDenseOptions - - -class EqualOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = EqualOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsEqualOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def EqualOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # EqualOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def EqualOptionsStart(builder): - builder.StartObject(0) - -def EqualOptionsEnd(builder): - return builder.EndObject() - - - -class EqualOptionsT(object): - - # EqualOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - equalOptions = EqualOptions() - equalOptions.Init(buf, pos) - return cls.InitFromObj(equalOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, equalOptions): - x = EqualOptionsT() - x._UnPack(equalOptions) - return x - - # EqualOptionsT - def _UnPack(self, equalOptions): - if equalOptions is None: - return - - # EqualOptionsT - def Pack(self, builder): - EqualOptionsStart(builder) - equalOptions = EqualOptionsEnd(builder) - return equalOptions - - -class NotEqualOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = NotEqualOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsNotEqualOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def NotEqualOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # NotEqualOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def NotEqualOptionsStart(builder): - builder.StartObject(0) - -def NotEqualOptionsEnd(builder): - return builder.EndObject() - - - -class NotEqualOptionsT(object): - - # NotEqualOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - notEqualOptions = NotEqualOptions() - notEqualOptions.Init(buf, pos) - return cls.InitFromObj(notEqualOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, notEqualOptions): - x = NotEqualOptionsT() - x._UnPack(notEqualOptions) - return x - - # NotEqualOptionsT - def _UnPack(self, notEqualOptions): - if notEqualOptions is None: - return - - # NotEqualOptionsT - def Pack(self, builder): - NotEqualOptionsStart(builder) - notEqualOptions = NotEqualOptionsEnd(builder) - return notEqualOptions - - -class ShapeOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ShapeOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsShapeOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ShapeOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ShapeOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ShapeOptions - def OutType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def ShapeOptionsStart(builder): - builder.StartObject(1) - -def ShapeOptionsAddOutType(builder, outType): - builder.PrependInt8Slot(0, outType, 0) - -def ShapeOptionsEnd(builder): - return builder.EndObject() - - - -class ShapeOptionsT(object): - - # ShapeOptionsT - def __init__( - self, - outType = 0, - ): - self.outType = outType # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - shapeOptions = ShapeOptions() - shapeOptions.Init(buf, pos) - return cls.InitFromObj(shapeOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, shapeOptions): - x = ShapeOptionsT() - x._UnPack(shapeOptions) - return x - - # ShapeOptionsT - def _UnPack(self, shapeOptions): - if shapeOptions is None: - return - self.outType = shapeOptions.OutType() - - # ShapeOptionsT - def Pack(self, builder): - ShapeOptionsStart(builder) - ShapeOptionsAddOutType(builder, self.outType) - shapeOptions = ShapeOptionsEnd(builder) - return shapeOptions - - -class RankOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = RankOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsRankOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def RankOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # RankOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def RankOptionsStart(builder): - builder.StartObject(0) - -def RankOptionsEnd(builder): - return builder.EndObject() - - - -class RankOptionsT(object): - - # RankOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - rankOptions = RankOptions() - rankOptions.Init(buf, pos) - return cls.InitFromObj(rankOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, rankOptions): - x = RankOptionsT() - x._UnPack(rankOptions) - return x - - # RankOptionsT - def _UnPack(self, rankOptions): - if rankOptions is None: - return - - # RankOptionsT - def Pack(self, builder): - RankOptionsStart(builder) - rankOptions = RankOptionsEnd(builder) - return rankOptions - - -class PowOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = PowOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsPowOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def PowOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # PowOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def PowOptionsStart(builder): - builder.StartObject(0) - -def PowOptionsEnd(builder): - return builder.EndObject() - - - -class PowOptionsT(object): - - # PowOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - powOptions = PowOptions() - powOptions.Init(buf, pos) - return cls.InitFromObj(powOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, powOptions): - x = PowOptionsT() - x._UnPack(powOptions) - return x - - # PowOptionsT - def _UnPack(self, powOptions): - if powOptions is None: - return - - # PowOptionsT - def Pack(self, builder): - PowOptionsStart(builder) - powOptions = PowOptionsEnd(builder) - return powOptions - - -class FakeQuantOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = FakeQuantOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsFakeQuantOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def FakeQuantOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # FakeQuantOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # FakeQuantOptions - def Min(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - - # FakeQuantOptions - def Max(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - - # FakeQuantOptions - def NumBits(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # FakeQuantOptions - def NarrowRange(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def FakeQuantOptionsStart(builder): - builder.StartObject(4) - -def FakeQuantOptionsAddMin(builder, min): - builder.PrependFloat32Slot(0, min, 0.0) - -def FakeQuantOptionsAddMax(builder, max): - builder.PrependFloat32Slot(1, max, 0.0) - -def FakeQuantOptionsAddNumBits(builder, numBits): - builder.PrependInt32Slot(2, numBits, 0) - -def FakeQuantOptionsAddNarrowRange(builder, narrowRange): - builder.PrependBoolSlot(3, narrowRange, 0) - -def FakeQuantOptionsEnd(builder): - return builder.EndObject() - - - -class FakeQuantOptionsT(object): - - # FakeQuantOptionsT - def __init__( - self, - min = 0.0, - max = 0.0, - numBits = 0, - narrowRange = False, - ): - self.min = min # type: float - self.max = max # type: float - self.numBits = numBits # type: int - self.narrowRange = narrowRange # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - fakeQuantOptions = FakeQuantOptions() - fakeQuantOptions.Init(buf, pos) - return cls.InitFromObj(fakeQuantOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, fakeQuantOptions): - x = FakeQuantOptionsT() - x._UnPack(fakeQuantOptions) - return x - - # FakeQuantOptionsT - def _UnPack(self, fakeQuantOptions): - if fakeQuantOptions is None: - return - self.min = fakeQuantOptions.Min() - self.max = fakeQuantOptions.Max() - self.numBits = fakeQuantOptions.NumBits() - self.narrowRange = fakeQuantOptions.NarrowRange() - - # FakeQuantOptionsT - def Pack(self, builder): - FakeQuantOptionsStart(builder) - FakeQuantOptionsAddMin(builder, self.min) - FakeQuantOptionsAddMax(builder, self.max) - FakeQuantOptionsAddNumBits(builder, self.numBits) - FakeQuantOptionsAddNarrowRange(builder, self.narrowRange) - fakeQuantOptions = FakeQuantOptionsEnd(builder) - return fakeQuantOptions - - -class PackOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = PackOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsPackOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def PackOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # PackOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # PackOptions - def ValuesCount(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # PackOptions - def Axis(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def PackOptionsStart(builder): - builder.StartObject(2) - -def PackOptionsAddValuesCount(builder, valuesCount): - builder.PrependInt32Slot(0, valuesCount, 0) - -def PackOptionsAddAxis(builder, axis): - builder.PrependInt32Slot(1, axis, 0) - -def PackOptionsEnd(builder): - return builder.EndObject() - - - -class PackOptionsT(object): - - # PackOptionsT - def __init__( - self, - valuesCount = 0, - axis = 0, - ): - self.valuesCount = valuesCount # type: int - self.axis = axis # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - packOptions = PackOptions() - packOptions.Init(buf, pos) - return cls.InitFromObj(packOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, packOptions): - x = PackOptionsT() - x._UnPack(packOptions) - return x - - # PackOptionsT - def _UnPack(self, packOptions): - if packOptions is None: - return - self.valuesCount = packOptions.ValuesCount() - self.axis = packOptions.Axis() - - # PackOptionsT - def Pack(self, builder): - PackOptionsStart(builder) - PackOptionsAddValuesCount(builder, self.valuesCount) - PackOptionsAddAxis(builder, self.axis) - packOptions = PackOptionsEnd(builder) - return packOptions - - -class LogicalOrOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = LogicalOrOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsLogicalOrOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def LogicalOrOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # LogicalOrOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def LogicalOrOptionsStart(builder): - builder.StartObject(0) - -def LogicalOrOptionsEnd(builder): - return builder.EndObject() - - - -class LogicalOrOptionsT(object): - - # LogicalOrOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - logicalOrOptions = LogicalOrOptions() - logicalOrOptions.Init(buf, pos) - return cls.InitFromObj(logicalOrOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, logicalOrOptions): - x = LogicalOrOptionsT() - x._UnPack(logicalOrOptions) - return x - - # LogicalOrOptionsT - def _UnPack(self, logicalOrOptions): - if logicalOrOptions is None: - return - - # LogicalOrOptionsT - def Pack(self, builder): - LogicalOrOptionsStart(builder) - logicalOrOptions = LogicalOrOptionsEnd(builder) - return logicalOrOptions - - -class OneHotOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = OneHotOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsOneHotOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def OneHotOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # OneHotOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # OneHotOptions - def Axis(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def OneHotOptionsStart(builder): - builder.StartObject(1) - -def OneHotOptionsAddAxis(builder, axis): - builder.PrependInt32Slot(0, axis, 0) - -def OneHotOptionsEnd(builder): - return builder.EndObject() - - - -class OneHotOptionsT(object): - - # OneHotOptionsT - def __init__( - self, - axis = 0, - ): - self.axis = axis # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - oneHotOptions = OneHotOptions() - oneHotOptions.Init(buf, pos) - return cls.InitFromObj(oneHotOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, oneHotOptions): - x = OneHotOptionsT() - x._UnPack(oneHotOptions) - return x - - # OneHotOptionsT - def _UnPack(self, oneHotOptions): - if oneHotOptions is None: - return - self.axis = oneHotOptions.Axis() - - # OneHotOptionsT - def Pack(self, builder): - OneHotOptionsStart(builder) - OneHotOptionsAddAxis(builder, self.axis) - oneHotOptions = OneHotOptionsEnd(builder) - return oneHotOptions - - -class AbsOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = AbsOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsAbsOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def AbsOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # AbsOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def AbsOptionsStart(builder): - builder.StartObject(0) - -def AbsOptionsEnd(builder): - return builder.EndObject() - - - -class AbsOptionsT(object): - - # AbsOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - absOptions = AbsOptions() - absOptions.Init(buf, pos) - return cls.InitFromObj(absOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, absOptions): - x = AbsOptionsT() - x._UnPack(absOptions) - return x - - # AbsOptionsT - def _UnPack(self, absOptions): - if absOptions is None: - return - - # AbsOptionsT - def Pack(self, builder): - AbsOptionsStart(builder) - absOptions = AbsOptionsEnd(builder) - return absOptions - - -class HardSwishOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = HardSwishOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsHardSwishOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def HardSwishOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # HardSwishOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def HardSwishOptionsStart(builder): - builder.StartObject(0) - -def HardSwishOptionsEnd(builder): - return builder.EndObject() - - - -class HardSwishOptionsT(object): - - # HardSwishOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - hardSwishOptions = HardSwishOptions() - hardSwishOptions.Init(buf, pos) - return cls.InitFromObj(hardSwishOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, hardSwishOptions): - x = HardSwishOptionsT() - x._UnPack(hardSwishOptions) - return x - - # HardSwishOptionsT - def _UnPack(self, hardSwishOptions): - if hardSwishOptions is None: - return - - # HardSwishOptionsT - def Pack(self, builder): - HardSwishOptionsStart(builder) - hardSwishOptions = HardSwishOptionsEnd(builder) - return hardSwishOptions - - -class LogicalAndOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = LogicalAndOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsLogicalAndOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def LogicalAndOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # LogicalAndOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def LogicalAndOptionsStart(builder): - builder.StartObject(0) - -def LogicalAndOptionsEnd(builder): - return builder.EndObject() - - - -class LogicalAndOptionsT(object): - - # LogicalAndOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - logicalAndOptions = LogicalAndOptions() - logicalAndOptions.Init(buf, pos) - return cls.InitFromObj(logicalAndOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, logicalAndOptions): - x = LogicalAndOptionsT() - x._UnPack(logicalAndOptions) - return x - - # LogicalAndOptionsT - def _UnPack(self, logicalAndOptions): - if logicalAndOptions is None: - return - - # LogicalAndOptionsT - def Pack(self, builder): - LogicalAndOptionsStart(builder) - logicalAndOptions = LogicalAndOptionsEnd(builder) - return logicalAndOptions - - -class LogicalNotOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = LogicalNotOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsLogicalNotOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def LogicalNotOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # LogicalNotOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def LogicalNotOptionsStart(builder): - builder.StartObject(0) - -def LogicalNotOptionsEnd(builder): - return builder.EndObject() - - - -class LogicalNotOptionsT(object): - - # LogicalNotOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - logicalNotOptions = LogicalNotOptions() - logicalNotOptions.Init(buf, pos) - return cls.InitFromObj(logicalNotOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, logicalNotOptions): - x = LogicalNotOptionsT() - x._UnPack(logicalNotOptions) - return x - - # LogicalNotOptionsT - def _UnPack(self, logicalNotOptions): - if logicalNotOptions is None: - return - - # LogicalNotOptionsT - def Pack(self, builder): - LogicalNotOptionsStart(builder) - logicalNotOptions = LogicalNotOptionsEnd(builder) - return logicalNotOptions - - -class UnpackOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = UnpackOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsUnpackOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def UnpackOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # UnpackOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # UnpackOptions - def Num(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # UnpackOptions - def Axis(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def UnpackOptionsStart(builder): - builder.StartObject(2) - -def UnpackOptionsAddNum(builder, num): - builder.PrependInt32Slot(0, num, 0) - -def UnpackOptionsAddAxis(builder, axis): - builder.PrependInt32Slot(1, axis, 0) - -def UnpackOptionsEnd(builder): - return builder.EndObject() - - - -class UnpackOptionsT(object): - - # UnpackOptionsT - def __init__( - self, - num = 0, - axis = 0, - ): - self.num = num # type: int - self.axis = axis # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - unpackOptions = UnpackOptions() - unpackOptions.Init(buf, pos) - return cls.InitFromObj(unpackOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, unpackOptions): - x = UnpackOptionsT() - x._UnPack(unpackOptions) - return x - - # UnpackOptionsT - def _UnPack(self, unpackOptions): - if unpackOptions is None: - return - self.num = unpackOptions.Num() - self.axis = unpackOptions.Axis() - - # UnpackOptionsT - def Pack(self, builder): - UnpackOptionsStart(builder) - UnpackOptionsAddNum(builder, self.num) - UnpackOptionsAddAxis(builder, self.axis) - unpackOptions = UnpackOptionsEnd(builder) - return unpackOptions - - -class FloorDivOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = FloorDivOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsFloorDivOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def FloorDivOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # FloorDivOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def FloorDivOptionsStart(builder): - builder.StartObject(0) - -def FloorDivOptionsEnd(builder): - return builder.EndObject() - - - -class FloorDivOptionsT(object): - - # FloorDivOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - floorDivOptions = FloorDivOptions() - floorDivOptions.Init(buf, pos) - return cls.InitFromObj(floorDivOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, floorDivOptions): - x = FloorDivOptionsT() - x._UnPack(floorDivOptions) - return x - - # FloorDivOptionsT - def _UnPack(self, floorDivOptions): - if floorDivOptions is None: - return - - # FloorDivOptionsT - def Pack(self, builder): - FloorDivOptionsStart(builder) - floorDivOptions = FloorDivOptionsEnd(builder) - return floorDivOptions - - -class SquareOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SquareOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSquareOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SquareOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SquareOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def SquareOptionsStart(builder): - builder.StartObject(0) - -def SquareOptionsEnd(builder): - return builder.EndObject() - - - -class SquareOptionsT(object): - - # SquareOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - squareOptions = SquareOptions() - squareOptions.Init(buf, pos) - return cls.InitFromObj(squareOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, squareOptions): - x = SquareOptionsT() - x._UnPack(squareOptions) - return x - - # SquareOptionsT - def _UnPack(self, squareOptions): - if squareOptions is None: - return - - # SquareOptionsT - def Pack(self, builder): - SquareOptionsStart(builder) - squareOptions = SquareOptionsEnd(builder) - return squareOptions - - -class ZerosLikeOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ZerosLikeOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsZerosLikeOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ZerosLikeOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ZerosLikeOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def ZerosLikeOptionsStart(builder): - builder.StartObject(0) - -def ZerosLikeOptionsEnd(builder): - return builder.EndObject() - - - -class ZerosLikeOptionsT(object): - - # ZerosLikeOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - zerosLikeOptions = ZerosLikeOptions() - zerosLikeOptions.Init(buf, pos) - return cls.InitFromObj(zerosLikeOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, zerosLikeOptions): - x = ZerosLikeOptionsT() - x._UnPack(zerosLikeOptions) - return x - - # ZerosLikeOptionsT - def _UnPack(self, zerosLikeOptions): - if zerosLikeOptions is None: - return - - # ZerosLikeOptionsT - def Pack(self, builder): - ZerosLikeOptionsStart(builder) - zerosLikeOptions = ZerosLikeOptionsEnd(builder) - return zerosLikeOptions - - -class FillOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = FillOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsFillOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def FillOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # FillOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def FillOptionsStart(builder): - builder.StartObject(0) - -def FillOptionsEnd(builder): - return builder.EndObject() - - - -class FillOptionsT(object): - - # FillOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - fillOptions = FillOptions() - fillOptions.Init(buf, pos) - return cls.InitFromObj(fillOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, fillOptions): - x = FillOptionsT() - x._UnPack(fillOptions) - return x - - # FillOptionsT - def _UnPack(self, fillOptions): - if fillOptions is None: - return - - # FillOptionsT - def Pack(self, builder): - FillOptionsStart(builder) - fillOptions = FillOptionsEnd(builder) - return fillOptions - - -class FloorModOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = FloorModOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsFloorModOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def FloorModOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # FloorModOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def FloorModOptionsStart(builder): - builder.StartObject(0) - -def FloorModOptionsEnd(builder): - return builder.EndObject() - - - -class FloorModOptionsT(object): - - # FloorModOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - floorModOptions = FloorModOptions() - floorModOptions.Init(buf, pos) - return cls.InitFromObj(floorModOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, floorModOptions): - x = FloorModOptionsT() - x._UnPack(floorModOptions) - return x - - # FloorModOptionsT - def _UnPack(self, floorModOptions): - if floorModOptions is None: - return - - # FloorModOptionsT - def Pack(self, builder): - FloorModOptionsStart(builder) - floorModOptions = FloorModOptionsEnd(builder) - return floorModOptions - - -class RangeOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = RangeOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsRangeOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def RangeOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # RangeOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def RangeOptionsStart(builder): - builder.StartObject(0) - -def RangeOptionsEnd(builder): - return builder.EndObject() - - - -class RangeOptionsT(object): - - # RangeOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - rangeOptions = RangeOptions() - rangeOptions.Init(buf, pos) - return cls.InitFromObj(rangeOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, rangeOptions): - x = RangeOptionsT() - x._UnPack(rangeOptions) - return x - - # RangeOptionsT - def _UnPack(self, rangeOptions): - if rangeOptions is None: - return - - # RangeOptionsT - def Pack(self, builder): - RangeOptionsStart(builder) - rangeOptions = RangeOptionsEnd(builder) - return rangeOptions - - -class LeakyReluOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = LeakyReluOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsLeakyReluOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def LeakyReluOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # LeakyReluOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # LeakyReluOptions - def Alpha(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - -def LeakyReluOptionsStart(builder): - builder.StartObject(1) - -def LeakyReluOptionsAddAlpha(builder, alpha): - builder.PrependFloat32Slot(0, alpha, 0.0) - -def LeakyReluOptionsEnd(builder): - return builder.EndObject() - - - -class LeakyReluOptionsT(object): - - # LeakyReluOptionsT - def __init__( - self, - alpha = 0.0, - ): - self.alpha = alpha # type: float - - @classmethod - def InitFromBuf(cls, buf, pos): - leakyReluOptions = LeakyReluOptions() - leakyReluOptions.Init(buf, pos) - return cls.InitFromObj(leakyReluOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, leakyReluOptions): - x = LeakyReluOptionsT() - x._UnPack(leakyReluOptions) - return x - - # LeakyReluOptionsT - def _UnPack(self, leakyReluOptions): - if leakyReluOptions is None: - return - self.alpha = leakyReluOptions.Alpha() - - # LeakyReluOptionsT - def Pack(self, builder): - LeakyReluOptionsStart(builder) - LeakyReluOptionsAddAlpha(builder, self.alpha) - leakyReluOptions = LeakyReluOptionsEnd(builder) - return leakyReluOptions - - -class SquaredDifferenceOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SquaredDifferenceOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSquaredDifferenceOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SquaredDifferenceOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SquaredDifferenceOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def SquaredDifferenceOptionsStart(builder): - builder.StartObject(0) - -def SquaredDifferenceOptionsEnd(builder): - return builder.EndObject() - - - -class SquaredDifferenceOptionsT(object): - - # SquaredDifferenceOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - squaredDifferenceOptions = SquaredDifferenceOptions() - squaredDifferenceOptions.Init(buf, pos) - return cls.InitFromObj(squaredDifferenceOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, squaredDifferenceOptions): - x = SquaredDifferenceOptionsT() - x._UnPack(squaredDifferenceOptions) - return x - - # SquaredDifferenceOptionsT - def _UnPack(self, squaredDifferenceOptions): - if squaredDifferenceOptions is None: - return - - # SquaredDifferenceOptionsT - def Pack(self, builder): - SquaredDifferenceOptionsStart(builder) - squaredDifferenceOptions = SquaredDifferenceOptionsEnd(builder) - return squaredDifferenceOptions - - -class MirrorPadOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = MirrorPadOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsMirrorPadOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def MirrorPadOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # MirrorPadOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # MirrorPadOptions - def Mode(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def MirrorPadOptionsStart(builder): - builder.StartObject(1) - -def MirrorPadOptionsAddMode(builder, mode): - builder.PrependInt8Slot(0, mode, 0) - -def MirrorPadOptionsEnd(builder): - return builder.EndObject() - - - -class MirrorPadOptionsT(object): - - # MirrorPadOptionsT - def __init__( - self, - mode = 0, - ): - self.mode = mode # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - mirrorPadOptions = MirrorPadOptions() - mirrorPadOptions.Init(buf, pos) - return cls.InitFromObj(mirrorPadOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, mirrorPadOptions): - x = MirrorPadOptionsT() - x._UnPack(mirrorPadOptions) - return x - - # MirrorPadOptionsT - def _UnPack(self, mirrorPadOptions): - if mirrorPadOptions is None: - return - self.mode = mirrorPadOptions.Mode() - - # MirrorPadOptionsT - def Pack(self, builder): - MirrorPadOptionsStart(builder) - MirrorPadOptionsAddMode(builder, self.mode) - mirrorPadOptions = MirrorPadOptionsEnd(builder) - return mirrorPadOptions - - -class UniqueOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = UniqueOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsUniqueOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def UniqueOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # UniqueOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # UniqueOptions - def IdxOutType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 2 - -def UniqueOptionsStart(builder): - builder.StartObject(1) - -def UniqueOptionsAddIdxOutType(builder, idxOutType): - builder.PrependInt8Slot(0, idxOutType, 2) - -def UniqueOptionsEnd(builder): - return builder.EndObject() - - - -class UniqueOptionsT(object): - - # UniqueOptionsT - def __init__( - self, - idxOutType = 2, - ): - self.idxOutType = idxOutType # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - uniqueOptions = UniqueOptions() - uniqueOptions.Init(buf, pos) - return cls.InitFromObj(uniqueOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, uniqueOptions): - x = UniqueOptionsT() - x._UnPack(uniqueOptions) - return x - - # UniqueOptionsT - def _UnPack(self, uniqueOptions): - if uniqueOptions is None: - return - self.idxOutType = uniqueOptions.IdxOutType() - - # UniqueOptionsT - def Pack(self, builder): - UniqueOptionsStart(builder) - UniqueOptionsAddIdxOutType(builder, self.idxOutType) - uniqueOptions = UniqueOptionsEnd(builder) - return uniqueOptions - - -class ReverseV2Options(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ReverseV2Options() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsReverseV2Options(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ReverseV2OptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ReverseV2Options - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def ReverseV2OptionsStart(builder): - builder.StartObject(0) - -def ReverseV2OptionsEnd(builder): - return builder.EndObject() - - - -class ReverseV2OptionsT(object): - - # ReverseV2OptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - reverseV2Options = ReverseV2Options() - reverseV2Options.Init(buf, pos) - return cls.InitFromObj(reverseV2Options) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, reverseV2Options): - x = ReverseV2OptionsT() - x._UnPack(reverseV2Options) - return x - - # ReverseV2OptionsT - def _UnPack(self, reverseV2Options): - if reverseV2Options is None: - return - - # ReverseV2OptionsT - def Pack(self, builder): - ReverseV2OptionsStart(builder) - reverseV2Options = ReverseV2OptionsEnd(builder) - return reverseV2Options - - -class AddNOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = AddNOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsAddNOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def AddNOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # AddNOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def AddNOptionsStart(builder): - builder.StartObject(0) - -def AddNOptionsEnd(builder): - return builder.EndObject() - - - -class AddNOptionsT(object): - - # AddNOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - addNoptions = AddNOptions() - addNoptions.Init(buf, pos) - return cls.InitFromObj(addNoptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, addNoptions): - x = AddNOptionsT() - x._UnPack(addNoptions) - return x - - # AddNOptionsT - def _UnPack(self, addNoptions): - if addNoptions is None: - return - - # AddNOptionsT - def Pack(self, builder): - AddNOptionsStart(builder) - addNoptions = AddNOptionsEnd(builder) - return addNoptions - - -class GatherNdOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = GatherNdOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsGatherNdOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def GatherNdOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # GatherNdOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def GatherNdOptionsStart(builder): - builder.StartObject(0) - -def GatherNdOptionsEnd(builder): - return builder.EndObject() - - - -class GatherNdOptionsT(object): - - # GatherNdOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - gatherNdOptions = GatherNdOptions() - gatherNdOptions.Init(buf, pos) - return cls.InitFromObj(gatherNdOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, gatherNdOptions): - x = GatherNdOptionsT() - x._UnPack(gatherNdOptions) - return x - - # GatherNdOptionsT - def _UnPack(self, gatherNdOptions): - if gatherNdOptions is None: - return - - # GatherNdOptionsT - def Pack(self, builder): - GatherNdOptionsStart(builder) - gatherNdOptions = GatherNdOptionsEnd(builder) - return gatherNdOptions - - -class WhereOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = WhereOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsWhereOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def WhereOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # WhereOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def WhereOptionsStart(builder): - builder.StartObject(0) - -def WhereOptionsEnd(builder): - return builder.EndObject() - - - -class WhereOptionsT(object): - - # WhereOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - whereOptions = WhereOptions() - whereOptions.Init(buf, pos) - return cls.InitFromObj(whereOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, whereOptions): - x = WhereOptionsT() - x._UnPack(whereOptions) - return x - - # WhereOptionsT - def _UnPack(self, whereOptions): - if whereOptions is None: - return - - # WhereOptionsT - def Pack(self, builder): - WhereOptionsStart(builder) - whereOptions = WhereOptionsEnd(builder) - return whereOptions - - -class ReverseSequenceOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ReverseSequenceOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsReverseSequenceOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ReverseSequenceOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ReverseSequenceOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ReverseSequenceOptions - def SeqDim(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # ReverseSequenceOptions - def BatchDim(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def ReverseSequenceOptionsStart(builder): - builder.StartObject(2) - -def ReverseSequenceOptionsAddSeqDim(builder, seqDim): - builder.PrependInt32Slot(0, seqDim, 0) - -def ReverseSequenceOptionsAddBatchDim(builder, batchDim): - builder.PrependInt32Slot(1, batchDim, 0) - -def ReverseSequenceOptionsEnd(builder): - return builder.EndObject() - - - -class ReverseSequenceOptionsT(object): - - # ReverseSequenceOptionsT - def __init__( - self, - seqDim = 0, - batchDim = 0, - ): - self.seqDim = seqDim # type: int - self.batchDim = batchDim # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - reverseSequenceOptions = ReverseSequenceOptions() - reverseSequenceOptions.Init(buf, pos) - return cls.InitFromObj(reverseSequenceOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, reverseSequenceOptions): - x = ReverseSequenceOptionsT() - x._UnPack(reverseSequenceOptions) - return x - - # ReverseSequenceOptionsT - def _UnPack(self, reverseSequenceOptions): - if reverseSequenceOptions is None: - return - self.seqDim = reverseSequenceOptions.SeqDim() - self.batchDim = reverseSequenceOptions.BatchDim() - - # ReverseSequenceOptionsT - def Pack(self, builder): - ReverseSequenceOptionsStart(builder) - ReverseSequenceOptionsAddSeqDim(builder, self.seqDim) - ReverseSequenceOptionsAddBatchDim(builder, self.batchDim) - reverseSequenceOptions = ReverseSequenceOptionsEnd(builder) - return reverseSequenceOptions - - -class MatrixDiagOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = MatrixDiagOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsMatrixDiagOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def MatrixDiagOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # MatrixDiagOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def MatrixDiagOptionsStart(builder): - builder.StartObject(0) - -def MatrixDiagOptionsEnd(builder): - return builder.EndObject() - - - -class MatrixDiagOptionsT(object): - - # MatrixDiagOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - matrixDiagOptions = MatrixDiagOptions() - matrixDiagOptions.Init(buf, pos) - return cls.InitFromObj(matrixDiagOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, matrixDiagOptions): - x = MatrixDiagOptionsT() - x._UnPack(matrixDiagOptions) - return x - - # MatrixDiagOptionsT - def _UnPack(self, matrixDiagOptions): - if matrixDiagOptions is None: - return - - # MatrixDiagOptionsT - def Pack(self, builder): - MatrixDiagOptionsStart(builder) - matrixDiagOptions = MatrixDiagOptionsEnd(builder) - return matrixDiagOptions - - -class QuantizeOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = QuantizeOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsQuantizeOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def QuantizeOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # QuantizeOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def QuantizeOptionsStart(builder): - builder.StartObject(0) - -def QuantizeOptionsEnd(builder): - return builder.EndObject() - - - -class QuantizeOptionsT(object): - - # QuantizeOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - quantizeOptions = QuantizeOptions() - quantizeOptions.Init(buf, pos) - return cls.InitFromObj(quantizeOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, quantizeOptions): - x = QuantizeOptionsT() - x._UnPack(quantizeOptions) - return x - - # QuantizeOptionsT - def _UnPack(self, quantizeOptions): - if quantizeOptions is None: - return - - # QuantizeOptionsT - def Pack(self, builder): - QuantizeOptionsStart(builder) - quantizeOptions = QuantizeOptionsEnd(builder) - return quantizeOptions - - -class MatrixSetDiagOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = MatrixSetDiagOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsMatrixSetDiagOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def MatrixSetDiagOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # MatrixSetDiagOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def MatrixSetDiagOptionsStart(builder): - builder.StartObject(0) - -def MatrixSetDiagOptionsEnd(builder): - return builder.EndObject() - - - -class MatrixSetDiagOptionsT(object): - - # MatrixSetDiagOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - matrixSetDiagOptions = MatrixSetDiagOptions() - matrixSetDiagOptions.Init(buf, pos) - return cls.InitFromObj(matrixSetDiagOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, matrixSetDiagOptions): - x = MatrixSetDiagOptionsT() - x._UnPack(matrixSetDiagOptions) - return x - - # MatrixSetDiagOptionsT - def _UnPack(self, matrixSetDiagOptions): - if matrixSetDiagOptions is None: - return - - # MatrixSetDiagOptionsT - def Pack(self, builder): - MatrixSetDiagOptionsStart(builder) - matrixSetDiagOptions = MatrixSetDiagOptionsEnd(builder) - return matrixSetDiagOptions - - -class IfOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = IfOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsIfOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def IfOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # IfOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # IfOptions - def ThenSubgraphIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # IfOptions - def ElseSubgraphIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def IfOptionsStart(builder): - builder.StartObject(2) - -def IfOptionsAddThenSubgraphIndex(builder, thenSubgraphIndex): - builder.PrependInt32Slot(0, thenSubgraphIndex, 0) - -def IfOptionsAddElseSubgraphIndex(builder, elseSubgraphIndex): - builder.PrependInt32Slot(1, elseSubgraphIndex, 0) - -def IfOptionsEnd(builder): - return builder.EndObject() - - - -class IfOptionsT(object): - - # IfOptionsT - def __init__( - self, - thenSubgraphIndex = 0, - elseSubgraphIndex = 0, - ): - self.thenSubgraphIndex = thenSubgraphIndex # type: int - self.elseSubgraphIndex = elseSubgraphIndex # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - ifOptions = IfOptions() - ifOptions.Init(buf, pos) - return cls.InitFromObj(ifOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, ifOptions): - x = IfOptionsT() - x._UnPack(ifOptions) - return x - - # IfOptionsT - def _UnPack(self, ifOptions): - if ifOptions is None: - return - self.thenSubgraphIndex = ifOptions.ThenSubgraphIndex() - self.elseSubgraphIndex = ifOptions.ElseSubgraphIndex() - - # IfOptionsT - def Pack(self, builder): - IfOptionsStart(builder) - IfOptionsAddThenSubgraphIndex(builder, self.thenSubgraphIndex) - IfOptionsAddElseSubgraphIndex(builder, self.elseSubgraphIndex) - ifOptions = IfOptionsEnd(builder) - return ifOptions - - -class CallOnceOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = CallOnceOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsCallOnceOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def CallOnceOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # CallOnceOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # CallOnceOptions - def InitSubgraphIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def CallOnceOptionsStart(builder): - builder.StartObject(1) - -def CallOnceOptionsAddInitSubgraphIndex(builder, initSubgraphIndex): - builder.PrependInt32Slot(0, initSubgraphIndex, 0) - -def CallOnceOptionsEnd(builder): - return builder.EndObject() - - - -class CallOnceOptionsT(object): - - # CallOnceOptionsT - def __init__( - self, - initSubgraphIndex = 0, - ): - self.initSubgraphIndex = initSubgraphIndex # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - callOnceOptions = CallOnceOptions() - callOnceOptions.Init(buf, pos) - return cls.InitFromObj(callOnceOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, callOnceOptions): - x = CallOnceOptionsT() - x._UnPack(callOnceOptions) - return x - - # CallOnceOptionsT - def _UnPack(self, callOnceOptions): - if callOnceOptions is None: - return - self.initSubgraphIndex = callOnceOptions.InitSubgraphIndex() - - # CallOnceOptionsT - def Pack(self, builder): - CallOnceOptionsStart(builder) - CallOnceOptionsAddInitSubgraphIndex(builder, self.initSubgraphIndex) - callOnceOptions = CallOnceOptionsEnd(builder) - return callOnceOptions - - -class WhileOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = WhileOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsWhileOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def WhileOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # WhileOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # WhileOptions - def CondSubgraphIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # WhileOptions - def BodySubgraphIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def WhileOptionsStart(builder): - builder.StartObject(2) - -def WhileOptionsAddCondSubgraphIndex(builder, condSubgraphIndex): - builder.PrependInt32Slot(0, condSubgraphIndex, 0) - -def WhileOptionsAddBodySubgraphIndex(builder, bodySubgraphIndex): - builder.PrependInt32Slot(1, bodySubgraphIndex, 0) - -def WhileOptionsEnd(builder): - return builder.EndObject() - - - -class WhileOptionsT(object): - - # WhileOptionsT - def __init__( - self, - condSubgraphIndex = 0, - bodySubgraphIndex = 0, - ): - self.condSubgraphIndex = condSubgraphIndex # type: int - self.bodySubgraphIndex = bodySubgraphIndex # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - whileOptions = WhileOptions() - whileOptions.Init(buf, pos) - return cls.InitFromObj(whileOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, whileOptions): - x = WhileOptionsT() - x._UnPack(whileOptions) - return x - - # WhileOptionsT - def _UnPack(self, whileOptions): - if whileOptions is None: - return - self.condSubgraphIndex = whileOptions.CondSubgraphIndex() - self.bodySubgraphIndex = whileOptions.BodySubgraphIndex() - - # WhileOptionsT - def Pack(self, builder): - WhileOptionsStart(builder) - WhileOptionsAddCondSubgraphIndex(builder, self.condSubgraphIndex) - WhileOptionsAddBodySubgraphIndex(builder, self.bodySubgraphIndex) - whileOptions = WhileOptionsEnd(builder) - return whileOptions - - -class NonMaxSuppressionV4Options(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = NonMaxSuppressionV4Options() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsNonMaxSuppressionV4Options(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def NonMaxSuppressionV4OptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # NonMaxSuppressionV4Options - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def NonMaxSuppressionV4OptionsStart(builder): - builder.StartObject(0) - -def NonMaxSuppressionV4OptionsEnd(builder): - return builder.EndObject() - - - -class NonMaxSuppressionV4OptionsT(object): - - # NonMaxSuppressionV4OptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - nonMaxSuppressionV4Options = NonMaxSuppressionV4Options() - nonMaxSuppressionV4Options.Init(buf, pos) - return cls.InitFromObj(nonMaxSuppressionV4Options) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, nonMaxSuppressionV4Options): - x = NonMaxSuppressionV4OptionsT() - x._UnPack(nonMaxSuppressionV4Options) - return x - - # NonMaxSuppressionV4OptionsT - def _UnPack(self, nonMaxSuppressionV4Options): - if nonMaxSuppressionV4Options is None: - return - - # NonMaxSuppressionV4OptionsT - def Pack(self, builder): - NonMaxSuppressionV4OptionsStart(builder) - nonMaxSuppressionV4Options = NonMaxSuppressionV4OptionsEnd(builder) - return nonMaxSuppressionV4Options - - -class NonMaxSuppressionV5Options(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = NonMaxSuppressionV5Options() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsNonMaxSuppressionV5Options(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def NonMaxSuppressionV5OptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # NonMaxSuppressionV5Options - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def NonMaxSuppressionV5OptionsStart(builder): - builder.StartObject(0) - -def NonMaxSuppressionV5OptionsEnd(builder): - return builder.EndObject() - - - -class NonMaxSuppressionV5OptionsT(object): - - # NonMaxSuppressionV5OptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - nonMaxSuppressionV5Options = NonMaxSuppressionV5Options() - nonMaxSuppressionV5Options.Init(buf, pos) - return cls.InitFromObj(nonMaxSuppressionV5Options) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, nonMaxSuppressionV5Options): - x = NonMaxSuppressionV5OptionsT() - x._UnPack(nonMaxSuppressionV5Options) - return x - - # NonMaxSuppressionV5OptionsT - def _UnPack(self, nonMaxSuppressionV5Options): - if nonMaxSuppressionV5Options is None: - return - - # NonMaxSuppressionV5OptionsT - def Pack(self, builder): - NonMaxSuppressionV5OptionsStart(builder) - nonMaxSuppressionV5Options = NonMaxSuppressionV5OptionsEnd(builder) - return nonMaxSuppressionV5Options - - -class ScatterNdOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ScatterNdOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsScatterNdOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ScatterNdOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ScatterNdOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def ScatterNdOptionsStart(builder): - builder.StartObject(0) - -def ScatterNdOptionsEnd(builder): - return builder.EndObject() - - - -class ScatterNdOptionsT(object): - - # ScatterNdOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - scatterNdOptions = ScatterNdOptions() - scatterNdOptions.Init(buf, pos) - return cls.InitFromObj(scatterNdOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, scatterNdOptions): - x = ScatterNdOptionsT() - x._UnPack(scatterNdOptions) - return x - - # ScatterNdOptionsT - def _UnPack(self, scatterNdOptions): - if scatterNdOptions is None: - return - - # ScatterNdOptionsT - def Pack(self, builder): - ScatterNdOptionsStart(builder) - scatterNdOptions = ScatterNdOptionsEnd(builder) - return scatterNdOptions - - -class SelectV2Options(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SelectV2Options() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSelectV2Options(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SelectV2OptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SelectV2Options - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def SelectV2OptionsStart(builder): - builder.StartObject(0) - -def SelectV2OptionsEnd(builder): - return builder.EndObject() - - - -class SelectV2OptionsT(object): - - # SelectV2OptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - selectV2Options = SelectV2Options() - selectV2Options.Init(buf, pos) - return cls.InitFromObj(selectV2Options) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, selectV2Options): - x = SelectV2OptionsT() - x._UnPack(selectV2Options) - return x - - # SelectV2OptionsT - def _UnPack(self, selectV2Options): - if selectV2Options is None: - return - - # SelectV2OptionsT - def Pack(self, builder): - SelectV2OptionsStart(builder) - selectV2Options = SelectV2OptionsEnd(builder) - return selectV2Options - - -class DensifyOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = DensifyOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsDensifyOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def DensifyOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # DensifyOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def DensifyOptionsStart(builder): - builder.StartObject(0) - -def DensifyOptionsEnd(builder): - return builder.EndObject() - - - -class DensifyOptionsT(object): - - # DensifyOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - densifyOptions = DensifyOptions() - densifyOptions.Init(buf, pos) - return cls.InitFromObj(densifyOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, densifyOptions): - x = DensifyOptionsT() - x._UnPack(densifyOptions) - return x - - # DensifyOptionsT - def _UnPack(self, densifyOptions): - if densifyOptions is None: - return - - # DensifyOptionsT - def Pack(self, builder): - DensifyOptionsStart(builder) - densifyOptions = DensifyOptionsEnd(builder) - return densifyOptions - - -class SegmentSumOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SegmentSumOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSegmentSumOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SegmentSumOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SegmentSumOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def SegmentSumOptionsStart(builder): - builder.StartObject(0) - -def SegmentSumOptionsEnd(builder): - return builder.EndObject() - - - -class SegmentSumOptionsT(object): - - # SegmentSumOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - segmentSumOptions = SegmentSumOptions() - segmentSumOptions.Init(buf, pos) - return cls.InitFromObj(segmentSumOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, segmentSumOptions): - x = SegmentSumOptionsT() - x._UnPack(segmentSumOptions) - return x - - # SegmentSumOptionsT - def _UnPack(self, segmentSumOptions): - if segmentSumOptions is None: - return - - # SegmentSumOptionsT - def Pack(self, builder): - SegmentSumOptionsStart(builder) - segmentSumOptions = SegmentSumOptionsEnd(builder) - return segmentSumOptions - - -class BatchMatMulOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = BatchMatMulOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsBatchMatMulOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def BatchMatMulOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # BatchMatMulOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # BatchMatMulOptions - def AdjX(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # BatchMatMulOptions - def AdjY(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # BatchMatMulOptions - def AsymmetricQuantizeInputs(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def BatchMatMulOptionsStart(builder): - builder.StartObject(3) - -def BatchMatMulOptionsAddAdjX(builder, adjX): - builder.PrependBoolSlot(0, adjX, 0) - -def BatchMatMulOptionsAddAdjY(builder, adjY): - builder.PrependBoolSlot(1, adjY, 0) - -def BatchMatMulOptionsAddAsymmetricQuantizeInputs(builder, asymmetricQuantizeInputs): - builder.PrependBoolSlot(2, asymmetricQuantizeInputs, 0) - -def BatchMatMulOptionsEnd(builder): - return builder.EndObject() - - - -class BatchMatMulOptionsT(object): - - # BatchMatMulOptionsT - def __init__( - self, - adjX = False, - adjY = False, - asymmetricQuantizeInputs = False, - ): - self.adjX = adjX # type: bool - self.adjY = adjY # type: bool - self.asymmetricQuantizeInputs = asymmetricQuantizeInputs # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - batchMatMulOptions = BatchMatMulOptions() - batchMatMulOptions.Init(buf, pos) - return cls.InitFromObj(batchMatMulOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, batchMatMulOptions): - x = BatchMatMulOptionsT() - x._UnPack(batchMatMulOptions) - return x - - # BatchMatMulOptionsT - def _UnPack(self, batchMatMulOptions): - if batchMatMulOptions is None: - return - self.adjX = batchMatMulOptions.AdjX() - self.adjY = batchMatMulOptions.AdjY() - self.asymmetricQuantizeInputs = batchMatMulOptions.AsymmetricQuantizeInputs() - - # BatchMatMulOptionsT - def Pack(self, builder): - BatchMatMulOptionsStart(builder) - BatchMatMulOptionsAddAdjX(builder, self.adjX) - BatchMatMulOptionsAddAdjY(builder, self.adjY) - BatchMatMulOptionsAddAsymmetricQuantizeInputs(builder, self.asymmetricQuantizeInputs) - batchMatMulOptions = BatchMatMulOptionsEnd(builder) - return batchMatMulOptions - - -class CumsumOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = CumsumOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsCumsumOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def CumsumOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # CumsumOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # CumsumOptions - def Exclusive(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - - # CumsumOptions - def Reverse(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def CumsumOptionsStart(builder): - builder.StartObject(2) - -def CumsumOptionsAddExclusive(builder, exclusive): - builder.PrependBoolSlot(0, exclusive, 0) - -def CumsumOptionsAddReverse(builder, reverse): - builder.PrependBoolSlot(1, reverse, 0) - -def CumsumOptionsEnd(builder): - return builder.EndObject() - - - -class CumsumOptionsT(object): - - # CumsumOptionsT - def __init__( - self, - exclusive = False, - reverse = False, - ): - self.exclusive = exclusive # type: bool - self.reverse = reverse # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - cumsumOptions = CumsumOptions() - cumsumOptions.Init(buf, pos) - return cls.InitFromObj(cumsumOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, cumsumOptions): - x = CumsumOptionsT() - x._UnPack(cumsumOptions) - return x - - # CumsumOptionsT - def _UnPack(self, cumsumOptions): - if cumsumOptions is None: - return - self.exclusive = cumsumOptions.Exclusive() - self.reverse = cumsumOptions.Reverse() - - # CumsumOptionsT - def Pack(self, builder): - CumsumOptionsStart(builder) - CumsumOptionsAddExclusive(builder, self.exclusive) - CumsumOptionsAddReverse(builder, self.reverse) - cumsumOptions = CumsumOptionsEnd(builder) - return cumsumOptions - - -class BroadcastToOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = BroadcastToOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsBroadcastToOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def BroadcastToOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # BroadcastToOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def BroadcastToOptionsStart(builder): - builder.StartObject(0) - -def BroadcastToOptionsEnd(builder): - return builder.EndObject() - - - -class BroadcastToOptionsT(object): - - # BroadcastToOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - broadcastToOptions = BroadcastToOptions() - broadcastToOptions.Init(buf, pos) - return cls.InitFromObj(broadcastToOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, broadcastToOptions): - x = BroadcastToOptionsT() - x._UnPack(broadcastToOptions) - return x - - # BroadcastToOptionsT - def _UnPack(self, broadcastToOptions): - if broadcastToOptions is None: - return - - # BroadcastToOptionsT - def Pack(self, builder): - BroadcastToOptionsStart(builder) - broadcastToOptions = BroadcastToOptionsEnd(builder) - return broadcastToOptions - - -class Rfft2dOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Rfft2dOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsRfft2dOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def Rfft2dOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # Rfft2dOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def Rfft2dOptionsStart(builder): - builder.StartObject(0) - -def Rfft2dOptionsEnd(builder): - return builder.EndObject() - - - -class Rfft2dOptionsT(object): - - # Rfft2dOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - rfft2dOptions = Rfft2dOptions() - rfft2dOptions.Init(buf, pos) - return cls.InitFromObj(rfft2dOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, rfft2dOptions): - x = Rfft2dOptionsT() - x._UnPack(rfft2dOptions) - return x - - # Rfft2dOptionsT - def _UnPack(self, rfft2dOptions): - if rfft2dOptions is None: - return - - # Rfft2dOptionsT - def Pack(self, builder): - Rfft2dOptionsStart(builder) - rfft2dOptions = Rfft2dOptionsEnd(builder) - return rfft2dOptions - - -class HashtableOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = HashtableOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsHashtableOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def HashtableOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # HashtableOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # HashtableOptions - def TableId(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # HashtableOptions - def KeyDtype(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # HashtableOptions - def ValueDtype(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - -def HashtableOptionsStart(builder): - builder.StartObject(3) - -def HashtableOptionsAddTableId(builder, tableId): - builder.PrependInt32Slot(0, tableId, 0) - -def HashtableOptionsAddKeyDtype(builder, keyDtype): - builder.PrependInt8Slot(1, keyDtype, 0) - -def HashtableOptionsAddValueDtype(builder, valueDtype): - builder.PrependInt8Slot(2, valueDtype, 0) - -def HashtableOptionsEnd(builder): - return builder.EndObject() - - - -class HashtableOptionsT(object): - - # HashtableOptionsT - def __init__( - self, - tableId = 0, - keyDtype = 0, - valueDtype = 0, - ): - self.tableId = tableId # type: int - self.keyDtype = keyDtype # type: int - self.valueDtype = valueDtype # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - hashtableOptions = HashtableOptions() - hashtableOptions.Init(buf, pos) - return cls.InitFromObj(hashtableOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, hashtableOptions): - x = HashtableOptionsT() - x._UnPack(hashtableOptions) - return x - - # HashtableOptionsT - def _UnPack(self, hashtableOptions): - if hashtableOptions is None: - return - self.tableId = hashtableOptions.TableId() - self.keyDtype = hashtableOptions.KeyDtype() - self.valueDtype = hashtableOptions.ValueDtype() - - # HashtableOptionsT - def Pack(self, builder): - HashtableOptionsStart(builder) - HashtableOptionsAddTableId(builder, self.tableId) - HashtableOptionsAddKeyDtype(builder, self.keyDtype) - HashtableOptionsAddValueDtype(builder, self.valueDtype) - hashtableOptions = HashtableOptionsEnd(builder) - return hashtableOptions - - -class HashtableFindOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = HashtableFindOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsHashtableFindOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def HashtableFindOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # HashtableFindOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def HashtableFindOptionsStart(builder): - builder.StartObject(0) - -def HashtableFindOptionsEnd(builder): - return builder.EndObject() - - - -class HashtableFindOptionsT(object): - - # HashtableFindOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - hashtableFindOptions = HashtableFindOptions() - hashtableFindOptions.Init(buf, pos) - return cls.InitFromObj(hashtableFindOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, hashtableFindOptions): - x = HashtableFindOptionsT() - x._UnPack(hashtableFindOptions) - return x - - # HashtableFindOptionsT - def _UnPack(self, hashtableFindOptions): - if hashtableFindOptions is None: - return - - # HashtableFindOptionsT - def Pack(self, builder): - HashtableFindOptionsStart(builder) - hashtableFindOptions = HashtableFindOptionsEnd(builder) - return hashtableFindOptions - - -class HashtableImportOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = HashtableImportOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsHashtableImportOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def HashtableImportOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # HashtableImportOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def HashtableImportOptionsStart(builder): - builder.StartObject(0) - -def HashtableImportOptionsEnd(builder): - return builder.EndObject() - - - -class HashtableImportOptionsT(object): - - # HashtableImportOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - hashtableImportOptions = HashtableImportOptions() - hashtableImportOptions.Init(buf, pos) - return cls.InitFromObj(hashtableImportOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, hashtableImportOptions): - x = HashtableImportOptionsT() - x._UnPack(hashtableImportOptions) - return x - - # HashtableImportOptionsT - def _UnPack(self, hashtableImportOptions): - if hashtableImportOptions is None: - return - - # HashtableImportOptionsT - def Pack(self, builder): - HashtableImportOptionsStart(builder) - hashtableImportOptions = HashtableImportOptionsEnd(builder) - return hashtableImportOptions - - -class HashtableSizeOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = HashtableSizeOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsHashtableSizeOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def HashtableSizeOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # HashtableSizeOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def HashtableSizeOptionsStart(builder): - builder.StartObject(0) - -def HashtableSizeOptionsEnd(builder): - return builder.EndObject() - - - -class HashtableSizeOptionsT(object): - - # HashtableSizeOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - hashtableSizeOptions = HashtableSizeOptions() - hashtableSizeOptions.Init(buf, pos) - return cls.InitFromObj(hashtableSizeOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, hashtableSizeOptions): - x = HashtableSizeOptionsT() - x._UnPack(hashtableSizeOptions) - return x - - # HashtableSizeOptionsT - def _UnPack(self, hashtableSizeOptions): - if hashtableSizeOptions is None: - return - - # HashtableSizeOptionsT - def Pack(self, builder): - HashtableSizeOptionsStart(builder) - hashtableSizeOptions = HashtableSizeOptionsEnd(builder) - return hashtableSizeOptions - - -class VarHandleOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = VarHandleOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsVarHandleOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def VarHandleOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # VarHandleOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # VarHandleOptions - def Container(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - - # VarHandleOptions - def SharedName(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - -def VarHandleOptionsStart(builder): - builder.StartObject(2) - -def VarHandleOptionsAddContainer(builder, container): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(container), 0) - -def VarHandleOptionsAddSharedName(builder, sharedName): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(sharedName), 0) - -def VarHandleOptionsEnd(builder): - return builder.EndObject() - - - -class VarHandleOptionsT(object): - - # VarHandleOptionsT - def __init__( - self, - container = None, - sharedName = None, - ): - self.container = container # type: Optional[str] - self.sharedName = sharedName # type: Optional[str] - - @classmethod - def InitFromBuf(cls, buf, pos): - varHandleOptions = VarHandleOptions() - varHandleOptions.Init(buf, pos) - return cls.InitFromObj(varHandleOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, varHandleOptions): - x = VarHandleOptionsT() - x._UnPack(varHandleOptions) - return x - - # VarHandleOptionsT - def _UnPack(self, varHandleOptions): - if varHandleOptions is None: - return - self.container = varHandleOptions.Container() - self.sharedName = varHandleOptions.SharedName() - - # VarHandleOptionsT - def Pack(self, builder): - if self.container is not None: - container = builder.CreateString(self.container) - if self.sharedName is not None: - sharedName = builder.CreateString(self.sharedName) - VarHandleOptionsStart(builder) - if self.container is not None: - VarHandleOptionsAddContainer(builder, container) - if self.sharedName is not None: - VarHandleOptionsAddSharedName(builder, sharedName) - varHandleOptions = VarHandleOptionsEnd(builder) - return varHandleOptions - - -class ReadVariableOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ReadVariableOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsReadVariableOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ReadVariableOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ReadVariableOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def ReadVariableOptionsStart(builder): - builder.StartObject(0) - -def ReadVariableOptionsEnd(builder): - return builder.EndObject() - - - -class ReadVariableOptionsT(object): - - # ReadVariableOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - readVariableOptions = ReadVariableOptions() - readVariableOptions.Init(buf, pos) - return cls.InitFromObj(readVariableOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, readVariableOptions): - x = ReadVariableOptionsT() - x._UnPack(readVariableOptions) - return x - - # ReadVariableOptionsT - def _UnPack(self, readVariableOptions): - if readVariableOptions is None: - return - - # ReadVariableOptionsT - def Pack(self, builder): - ReadVariableOptionsStart(builder) - readVariableOptions = ReadVariableOptionsEnd(builder) - return readVariableOptions - - -class AssignVariableOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = AssignVariableOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsAssignVariableOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def AssignVariableOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # AssignVariableOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def AssignVariableOptionsStart(builder): - builder.StartObject(0) - -def AssignVariableOptionsEnd(builder): - return builder.EndObject() - - - -class AssignVariableOptionsT(object): - - # AssignVariableOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - assignVariableOptions = AssignVariableOptions() - assignVariableOptions.Init(buf, pos) - return cls.InitFromObj(assignVariableOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, assignVariableOptions): - x = AssignVariableOptionsT() - x._UnPack(assignVariableOptions) - return x - - # AssignVariableOptionsT - def _UnPack(self, assignVariableOptions): - if assignVariableOptions is None: - return - - # AssignVariableOptionsT - def Pack(self, builder): - AssignVariableOptionsStart(builder) - assignVariableOptions = AssignVariableOptionsEnd(builder) - return assignVariableOptions - - -class RandomOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = RandomOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsRandomOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def RandomOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # RandomOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # RandomOptions - def Seed(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # RandomOptions - def Seed2(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - -def RandomOptionsStart(builder): - builder.StartObject(2) - -def RandomOptionsAddSeed(builder, seed): - builder.PrependInt64Slot(0, seed, 0) - -def RandomOptionsAddSeed2(builder, seed2): - builder.PrependInt64Slot(1, seed2, 0) - -def RandomOptionsEnd(builder): - return builder.EndObject() - - - -class RandomOptionsT(object): - - # RandomOptionsT - def __init__( - self, - seed = 0, - seed2 = 0, - ): - self.seed = seed # type: int - self.seed2 = seed2 # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - randomOptions = RandomOptions() - randomOptions.Init(buf, pos) - return cls.InitFromObj(randomOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, randomOptions): - x = RandomOptionsT() - x._UnPack(randomOptions) - return x - - # RandomOptionsT - def _UnPack(self, randomOptions): - if randomOptions is None: - return - self.seed = randomOptions.Seed() - self.seed2 = randomOptions.Seed2() - - # RandomOptionsT - def Pack(self, builder): - RandomOptionsStart(builder) - RandomOptionsAddSeed(builder, self.seed) - RandomOptionsAddSeed2(builder, self.seed2) - randomOptions = RandomOptionsEnd(builder) - return randomOptions - - -class BucketizeOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = BucketizeOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsBucketizeOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def BucketizeOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # BucketizeOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # BucketizeOptions - def Boundaries(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Float32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # BucketizeOptions - def BoundariesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float32Flags, o) - return 0 - - # BucketizeOptions - def BoundariesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # BucketizeOptions - def BoundariesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - -def BucketizeOptionsStart(builder): - builder.StartObject(1) - -def BucketizeOptionsAddBoundaries(builder, boundaries): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(boundaries), 0) - -def BucketizeOptionsStartBoundariesVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def BucketizeOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class BucketizeOptionsT(object): - - # BucketizeOptionsT - def __init__( - self, - boundaries = None, - ): - self.boundaries = boundaries # type: Optional[List[float]] - - @classmethod - def InitFromBuf(cls, buf, pos): - bucketizeOptions = BucketizeOptions() - bucketizeOptions.Init(buf, pos) - return cls.InitFromObj(bucketizeOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, bucketizeOptions): - x = BucketizeOptionsT() - x._UnPack(bucketizeOptions) - return x - - # BucketizeOptionsT - def _UnPack(self, bucketizeOptions): - if bucketizeOptions is None: - return - if not bucketizeOptions.BoundariesIsNone(): - if np is None: - self.boundaries = [] - for i in range(bucketizeOptions.BoundariesLength()): - self.boundaries.append(bucketizeOptions.Boundaries(i)) - else: - self.boundaries = bucketizeOptions.BoundariesAsNumpy() - - # BucketizeOptionsT - def Pack(self, builder): - if self.boundaries is not None: - if np is not None and type(self.boundaries) is np.ndarray: - boundaries = builder.CreateNumpyVector(self.boundaries) - else: - BucketizeOptionsStartBoundariesVector(builder, len(self.boundaries)) - for i in reversed(range(len(self.boundaries))): - builder.PrependFloat32(self.boundaries[i]) - boundaries = builder.EndVector() - BucketizeOptionsStart(builder) - if self.boundaries is not None: - BucketizeOptionsAddBoundaries(builder, boundaries) - bucketizeOptions = BucketizeOptionsEnd(builder) - return bucketizeOptions - - -class GeluOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = GeluOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsGeluOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def GeluOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # GeluOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # GeluOptions - def Approximate(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) - return False - -def GeluOptionsStart(builder): - builder.StartObject(1) - -def GeluOptionsAddApproximate(builder, approximate): - builder.PrependBoolSlot(0, approximate, 0) - -def GeluOptionsEnd(builder): - return builder.EndObject() - - - -class GeluOptionsT(object): - - # GeluOptionsT - def __init__( - self, - approximate = False, - ): - self.approximate = approximate # type: bool - - @classmethod - def InitFromBuf(cls, buf, pos): - geluOptions = GeluOptions() - geluOptions.Init(buf, pos) - return cls.InitFromObj(geluOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, geluOptions): - x = GeluOptionsT() - x._UnPack(geluOptions) - return x - - # GeluOptionsT - def _UnPack(self, geluOptions): - if geluOptions is None: - return - self.approximate = geluOptions.Approximate() - - # GeluOptionsT - def Pack(self, builder): - GeluOptionsStart(builder) - GeluOptionsAddApproximate(builder, self.approximate) - geluOptions = GeluOptionsEnd(builder) - return geluOptions - - -class DynamicUpdateSliceOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = DynamicUpdateSliceOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsDynamicUpdateSliceOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def DynamicUpdateSliceOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # DynamicUpdateSliceOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def DynamicUpdateSliceOptionsStart(builder): - builder.StartObject(0) - -def DynamicUpdateSliceOptionsEnd(builder): - return builder.EndObject() - - - -class DynamicUpdateSliceOptionsT(object): - - # DynamicUpdateSliceOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - dynamicUpdateSliceOptions = DynamicUpdateSliceOptions() - dynamicUpdateSliceOptions.Init(buf, pos) - return cls.InitFromObj(dynamicUpdateSliceOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, dynamicUpdateSliceOptions): - x = DynamicUpdateSliceOptionsT() - x._UnPack(dynamicUpdateSliceOptions) - return x - - # DynamicUpdateSliceOptionsT - def _UnPack(self, dynamicUpdateSliceOptions): - if dynamicUpdateSliceOptions is None: - return - - # DynamicUpdateSliceOptionsT - def Pack(self, builder): - DynamicUpdateSliceOptionsStart(builder) - dynamicUpdateSliceOptions = DynamicUpdateSliceOptionsEnd(builder) - return dynamicUpdateSliceOptions - - -class UnsortedSegmentProdOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = UnsortedSegmentProdOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsUnsortedSegmentProdOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def UnsortedSegmentProdOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # UnsortedSegmentProdOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def UnsortedSegmentProdOptionsStart(builder): - builder.StartObject(0) - -def UnsortedSegmentProdOptionsEnd(builder): - return builder.EndObject() - - - -class UnsortedSegmentProdOptionsT(object): - - # UnsortedSegmentProdOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - unsortedSegmentProdOptions = UnsortedSegmentProdOptions() - unsortedSegmentProdOptions.Init(buf, pos) - return cls.InitFromObj(unsortedSegmentProdOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, unsortedSegmentProdOptions): - x = UnsortedSegmentProdOptionsT() - x._UnPack(unsortedSegmentProdOptions) - return x - - # UnsortedSegmentProdOptionsT - def _UnPack(self, unsortedSegmentProdOptions): - if unsortedSegmentProdOptions is None: - return - - # UnsortedSegmentProdOptionsT - def Pack(self, builder): - UnsortedSegmentProdOptionsStart(builder) - unsortedSegmentProdOptions = UnsortedSegmentProdOptionsEnd(builder) - return unsortedSegmentProdOptions - - -class UnsortedSegmentMaxOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = UnsortedSegmentMaxOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsUnsortedSegmentMaxOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def UnsortedSegmentMaxOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # UnsortedSegmentMaxOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def UnsortedSegmentMaxOptionsStart(builder): - builder.StartObject(0) - -def UnsortedSegmentMaxOptionsEnd(builder): - return builder.EndObject() - - - -class UnsortedSegmentMaxOptionsT(object): - - # UnsortedSegmentMaxOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - unsortedSegmentMaxOptions = UnsortedSegmentMaxOptions() - unsortedSegmentMaxOptions.Init(buf, pos) - return cls.InitFromObj(unsortedSegmentMaxOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, unsortedSegmentMaxOptions): - x = UnsortedSegmentMaxOptionsT() - x._UnPack(unsortedSegmentMaxOptions) - return x - - # UnsortedSegmentMaxOptionsT - def _UnPack(self, unsortedSegmentMaxOptions): - if unsortedSegmentMaxOptions is None: - return - - # UnsortedSegmentMaxOptionsT - def Pack(self, builder): - UnsortedSegmentMaxOptionsStart(builder) - unsortedSegmentMaxOptions = UnsortedSegmentMaxOptionsEnd(builder) - return unsortedSegmentMaxOptions - - -class UnsortedSegmentSumOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = UnsortedSegmentSumOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsUnsortedSegmentSumOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def UnsortedSegmentSumOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # UnsortedSegmentSumOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def UnsortedSegmentSumOptionsStart(builder): - builder.StartObject(0) - -def UnsortedSegmentSumOptionsEnd(builder): - return builder.EndObject() - - - -class UnsortedSegmentSumOptionsT(object): - - # UnsortedSegmentSumOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - unsortedSegmentSumOptions = UnsortedSegmentSumOptions() - unsortedSegmentSumOptions.Init(buf, pos) - return cls.InitFromObj(unsortedSegmentSumOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, unsortedSegmentSumOptions): - x = UnsortedSegmentSumOptionsT() - x._UnPack(unsortedSegmentSumOptions) - return x - - # UnsortedSegmentSumOptionsT - def _UnPack(self, unsortedSegmentSumOptions): - if unsortedSegmentSumOptions is None: - return - - # UnsortedSegmentSumOptionsT - def Pack(self, builder): - UnsortedSegmentSumOptionsStart(builder) - unsortedSegmentSumOptions = UnsortedSegmentSumOptionsEnd(builder) - return unsortedSegmentSumOptions - - -class ATan2Options(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ATan2Options() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsATan2Options(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ATan2OptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ATan2Options - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def ATan2OptionsStart(builder): - builder.StartObject(0) - -def ATan2OptionsEnd(builder): - return builder.EndObject() - - - -class ATan2OptionsT(object): - - # ATan2OptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - atan2Options = ATan2Options() - atan2Options.Init(buf, pos) - return cls.InitFromObj(atan2Options) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, atan2Options): - x = ATan2OptionsT() - x._UnPack(atan2Options) - return x - - # ATan2OptionsT - def _UnPack(self, atan2Options): - if atan2Options is None: - return - - # ATan2OptionsT - def Pack(self, builder): - ATan2OptionsStart(builder) - atan2Options = ATan2OptionsEnd(builder) - return atan2Options - - -class UnsortedSegmentMinOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = UnsortedSegmentMinOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsUnsortedSegmentMinOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def UnsortedSegmentMinOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # UnsortedSegmentMinOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def UnsortedSegmentMinOptionsStart(builder): - builder.StartObject(0) - -def UnsortedSegmentMinOptionsEnd(builder): - return builder.EndObject() - - - -class UnsortedSegmentMinOptionsT(object): - - # UnsortedSegmentMinOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - unsortedSegmentMinOptions = UnsortedSegmentMinOptions() - unsortedSegmentMinOptions.Init(buf, pos) - return cls.InitFromObj(unsortedSegmentMinOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, unsortedSegmentMinOptions): - x = UnsortedSegmentMinOptionsT() - x._UnPack(unsortedSegmentMinOptions) - return x - - # UnsortedSegmentMinOptionsT - def _UnPack(self, unsortedSegmentMinOptions): - if unsortedSegmentMinOptions is None: - return - - # UnsortedSegmentMinOptionsT - def Pack(self, builder): - UnsortedSegmentMinOptionsStart(builder) - unsortedSegmentMinOptions = UnsortedSegmentMinOptionsEnd(builder) - return unsortedSegmentMinOptions - - -class SignOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SignOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSignOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SignOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SignOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def SignOptionsStart(builder): - builder.StartObject(0) - -def SignOptionsEnd(builder): - return builder.EndObject() - - - -class SignOptionsT(object): - - # SignOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - signOptions = SignOptions() - signOptions.Init(buf, pos) - return cls.InitFromObj(signOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, signOptions): - x = SignOptionsT() - x._UnPack(signOptions) - return x - - # SignOptionsT - def _UnPack(self, signOptions): - if signOptions is None: - return - - # SignOptionsT - def Pack(self, builder): - SignOptionsStart(builder) - signOptions = SignOptionsEnd(builder) - return signOptions - - -class BitcastOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = BitcastOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsBitcastOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def BitcastOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # BitcastOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def BitcastOptionsStart(builder): - builder.StartObject(0) - -def BitcastOptionsEnd(builder): - return builder.EndObject() - - - -class BitcastOptionsT(object): - - # BitcastOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - bitcastOptions = BitcastOptions() - bitcastOptions.Init(buf, pos) - return cls.InitFromObj(bitcastOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, bitcastOptions): - x = BitcastOptionsT() - x._UnPack(bitcastOptions) - return x - - # BitcastOptionsT - def _UnPack(self, bitcastOptions): - if bitcastOptions is None: - return - - # BitcastOptionsT - def Pack(self, builder): - BitcastOptionsStart(builder) - bitcastOptions = BitcastOptionsEnd(builder) - return bitcastOptions - - -class BitwiseXorOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = BitwiseXorOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsBitwiseXorOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def BitwiseXorOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # BitwiseXorOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def BitwiseXorOptionsStart(builder): - builder.StartObject(0) - -def BitwiseXorOptionsEnd(builder): - return builder.EndObject() - - - -class BitwiseXorOptionsT(object): - - # BitwiseXorOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - bitwiseXorOptions = BitwiseXorOptions() - bitwiseXorOptions.Init(buf, pos) - return cls.InitFromObj(bitwiseXorOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, bitwiseXorOptions): - x = BitwiseXorOptionsT() - x._UnPack(bitwiseXorOptions) - return x - - # BitwiseXorOptionsT - def _UnPack(self, bitwiseXorOptions): - if bitwiseXorOptions is None: - return - - # BitwiseXorOptionsT - def Pack(self, builder): - BitwiseXorOptionsStart(builder) - bitwiseXorOptions = BitwiseXorOptionsEnd(builder) - return bitwiseXorOptions - - -class RightShiftOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = RightShiftOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsRightShiftOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def RightShiftOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # RightShiftOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def RightShiftOptionsStart(builder): - builder.StartObject(0) - -def RightShiftOptionsEnd(builder): - return builder.EndObject() - - - -class RightShiftOptionsT(object): - - # RightShiftOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - rightShiftOptions = RightShiftOptions() - rightShiftOptions.Init(buf, pos) - return cls.InitFromObj(rightShiftOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, rightShiftOptions): - x = RightShiftOptionsT() - x._UnPack(rightShiftOptions) - return x - - # RightShiftOptionsT - def _UnPack(self, rightShiftOptions): - if rightShiftOptions is None: - return - - # RightShiftOptionsT - def Pack(self, builder): - RightShiftOptionsStart(builder) - rightShiftOptions = RightShiftOptionsEnd(builder) - return rightShiftOptions - - -class DilateOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = DilateOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsDilateOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def DilateOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # DilateOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def DilateOptionsStart(builder): - builder.StartObject(0) - -def DilateOptionsEnd(builder): - return builder.EndObject() - - - -class DilateOptionsT(object): - - # DilateOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - dilateOptions = DilateOptions() - dilateOptions.Init(buf, pos) - return cls.InitFromObj(dilateOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, dilateOptions): - x = DilateOptionsT() - x._UnPack(dilateOptions) - return x - - # DilateOptionsT - def _UnPack(self, dilateOptions): - if dilateOptions is None: - return - - # DilateOptionsT - def Pack(self, builder): - DilateOptionsStart(builder) - dilateOptions = DilateOptionsEnd(builder) - return dilateOptions - - -class ReduceWindowOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ReduceWindowOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsReduceWindowOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ReduceWindowOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ReduceWindowOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ReduceWindowOptions - def ReduceFunction(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def ReduceWindowOptionsStart(builder): - builder.StartObject(1) - -def ReduceWindowOptionsAddReduceFunction(builder, reduceFunction): - builder.PrependInt32Slot(0, reduceFunction, 0) - -def ReduceWindowOptionsEnd(builder): - return builder.EndObject() - - - -class ReduceWindowOptionsT(object): - - # ReduceWindowOptionsT - def __init__( - self, - reduceFunction = 0, - ): - self.reduceFunction = reduceFunction # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - reduceWindowOptions = ReduceWindowOptions() - reduceWindowOptions.Init(buf, pos) - return cls.InitFromObj(reduceWindowOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, reduceWindowOptions): - x = ReduceWindowOptionsT() - x._UnPack(reduceWindowOptions) - return x - - # ReduceWindowOptionsT - def _UnPack(self, reduceWindowOptions): - if reduceWindowOptions is None: - return - self.reduceFunction = reduceWindowOptions.ReduceFunction() - - # ReduceWindowOptionsT - def Pack(self, builder): - ReduceWindowOptionsStart(builder) - ReduceWindowOptionsAddReduceFunction(builder, self.reduceFunction) - reduceWindowOptions = ReduceWindowOptionsEnd(builder) - return reduceWindowOptions - - -class OperatorCode(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = OperatorCode() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsOperatorCode(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def OperatorCodeBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # OperatorCode - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # OperatorCode - def DeprecatedBuiltinCode(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # OperatorCode - def CustomCode(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - - # OperatorCode - def Version(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 1 - - # OperatorCode - def BuiltinCode(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def OperatorCodeStart(builder): - builder.StartObject(4) - -def OperatorCodeAddDeprecatedBuiltinCode(builder, deprecatedBuiltinCode): - builder.PrependInt8Slot(0, deprecatedBuiltinCode, 0) - -def OperatorCodeAddCustomCode(builder, customCode): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(customCode), 0) - -def OperatorCodeAddVersion(builder, version): - builder.PrependInt32Slot(2, version, 1) - -def OperatorCodeAddBuiltinCode(builder, builtinCode): - builder.PrependInt32Slot(3, builtinCode, 0) - -def OperatorCodeEnd(builder): - return builder.EndObject() - - - -class OperatorCodeT(object): - - # OperatorCodeT - def __init__( - self, - deprecatedBuiltinCode = 0, - customCode = None, - version = 1, - builtinCode = 0, - ): - self.deprecatedBuiltinCode = deprecatedBuiltinCode # type: int - self.customCode = customCode # type: Optional[str] - self.version = version # type: int - self.builtinCode = builtinCode # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - operatorCode = OperatorCode() - operatorCode.Init(buf, pos) - return cls.InitFromObj(operatorCode) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, operatorCode): - x = OperatorCodeT() - x._UnPack(operatorCode) - return x - - # OperatorCodeT - def _UnPack(self, operatorCode): - if operatorCode is None: - return - self.deprecatedBuiltinCode = operatorCode.DeprecatedBuiltinCode() - self.customCode = operatorCode.CustomCode() - self.version = operatorCode.Version() - self.builtinCode = operatorCode.BuiltinCode() - - # OperatorCodeT - def Pack(self, builder): - if self.customCode is not None: - customCode = builder.CreateString(self.customCode) - OperatorCodeStart(builder) - OperatorCodeAddDeprecatedBuiltinCode(builder, self.deprecatedBuiltinCode) - if self.customCode is not None: - OperatorCodeAddCustomCode(builder, customCode) - OperatorCodeAddVersion(builder, self.version) - OperatorCodeAddBuiltinCode(builder, self.builtinCode) - operatorCode = OperatorCodeEnd(builder) - return operatorCode - - -class StableHLOCompositeOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StableHLOCompositeOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStableHLOCompositeOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StableHLOCompositeOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StableHLOCompositeOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StableHLOCompositeOptions - def Name(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - - # StableHLOCompositeOptions - def DecompositionSubgraphIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # StableHLOCompositeOptions - def CompositeAttributes(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) - return 0 - - # StableHLOCompositeOptions - def CompositeAttributesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o) - return 0 - - # StableHLOCompositeOptions - def CompositeAttributesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # StableHLOCompositeOptions - def CompositeAttributesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - - # StableHLOCompositeOptions - def CompositeAttributesFormat(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # StableHLOCompositeOptions - def Version(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def StableHLOCompositeOptionsStart(builder): - builder.StartObject(5) - -def StableHLOCompositeOptionsAddName(builder, name): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0) - -def StableHLOCompositeOptionsAddDecompositionSubgraphIndex(builder, decompositionSubgraphIndex): - builder.PrependInt32Slot(1, decompositionSubgraphIndex, 0) - -def StableHLOCompositeOptionsAddCompositeAttributes(builder, compositeAttributes): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(compositeAttributes), 0) - -def StableHLOCompositeOptionsStartCompositeAttributesVector(builder, numElems): - return builder.StartVector(1, numElems, 1) - -def StableHLOCompositeOptionsAddCompositeAttributesFormat(builder, compositeAttributesFormat): - builder.PrependInt8Slot(3, compositeAttributesFormat, 0) - -def StableHLOCompositeOptionsAddVersion(builder, version): - builder.PrependInt32Slot(4, version, 0) - -def StableHLOCompositeOptionsEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class StableHLOCompositeOptionsT(object): - - # StableHLOCompositeOptionsT - def __init__( - self, - name = None, - decompositionSubgraphIndex = 0, - compositeAttributes = None, - compositeAttributesFormat = 0, - version = 0, - ): - self.name = name # type: Optional[str] - self.decompositionSubgraphIndex = decompositionSubgraphIndex # type: int - self.compositeAttributes = compositeAttributes # type: Optional[List[int]] - self.compositeAttributesFormat = compositeAttributesFormat # type: int - self.version = version # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - stableHlocompositeOptions = StableHLOCompositeOptions() - stableHlocompositeOptions.Init(buf, pos) - return cls.InitFromObj(stableHlocompositeOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stableHlocompositeOptions): - x = StableHLOCompositeOptionsT() - x._UnPack(stableHlocompositeOptions) - return x - - # StableHLOCompositeOptionsT - def _UnPack(self, stableHlocompositeOptions): - if stableHlocompositeOptions is None: - return - self.name = stableHlocompositeOptions.Name() - self.decompositionSubgraphIndex = stableHlocompositeOptions.DecompositionSubgraphIndex() - if not stableHlocompositeOptions.CompositeAttributesIsNone(): - if np is None: - self.compositeAttributes = [] - for i in range(stableHlocompositeOptions.CompositeAttributesLength()): - self.compositeAttributes.append(stableHlocompositeOptions.CompositeAttributes(i)) - else: - self.compositeAttributes = stableHlocompositeOptions.CompositeAttributesAsNumpy() - self.compositeAttributesFormat = stableHlocompositeOptions.CompositeAttributesFormat() - self.version = stableHlocompositeOptions.Version() - - # StableHLOCompositeOptionsT - def Pack(self, builder): - if self.name is not None: - name = builder.CreateString(self.name) - if self.compositeAttributes is not None: - if np is not None and type(self.compositeAttributes) is np.ndarray: - compositeAttributes = builder.CreateNumpyVector(self.compositeAttributes) - else: - StableHLOCompositeOptionsStartCompositeAttributesVector(builder, len(self.compositeAttributes)) - for i in reversed(range(len(self.compositeAttributes))): - builder.PrependUint8(self.compositeAttributes[i]) - compositeAttributes = builder.EndVector() - StableHLOCompositeOptionsStart(builder) - if self.name is not None: - StableHLOCompositeOptionsAddName(builder, name) - StableHLOCompositeOptionsAddDecompositionSubgraphIndex(builder, self.decompositionSubgraphIndex) - if self.compositeAttributes is not None: - StableHLOCompositeOptionsAddCompositeAttributes(builder, compositeAttributes) - StableHLOCompositeOptionsAddCompositeAttributesFormat(builder, self.compositeAttributesFormat) - StableHLOCompositeOptionsAddVersion(builder, self.version) - stableHlocompositeOptions = StableHLOCompositeOptionsEnd(builder) - return stableHlocompositeOptions - - -class StablehloShiftLeftOptions(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = StablehloShiftLeftOptions() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsStablehloShiftLeftOptions(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def StablehloShiftLeftOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # StablehloShiftLeftOptions - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def StablehloShiftLeftOptionsStart(builder): - builder.StartObject(0) - -def StablehloShiftLeftOptionsEnd(builder): - return builder.EndObject() - - - -class StablehloShiftLeftOptionsT(object): - - # StablehloShiftLeftOptionsT - def __init__( - self, - ): - pass - - @classmethod - def InitFromBuf(cls, buf, pos): - stablehloShiftLeftOptions = StablehloShiftLeftOptions() - stablehloShiftLeftOptions.Init(buf, pos) - return cls.InitFromObj(stablehloShiftLeftOptions) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, stablehloShiftLeftOptions): - x = StablehloShiftLeftOptionsT() - x._UnPack(stablehloShiftLeftOptions) - return x - - # StablehloShiftLeftOptionsT - def _UnPack(self, stablehloShiftLeftOptions): - if stablehloShiftLeftOptions is None: - return - - # StablehloShiftLeftOptionsT - def Pack(self, builder): - StablehloShiftLeftOptionsStart(builder) - stablehloShiftLeftOptions = StablehloShiftLeftOptionsEnd(builder) - return stablehloShiftLeftOptions - - -class Operator(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Operator() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsOperator(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def OperatorBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # Operator - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Operator - def OpcodeIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - - # Operator - def Inputs(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # Operator - def InputsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # Operator - def InputsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Operator - def InputsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # Operator - def Outputs(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # Operator - def OutputsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # Operator - def OutputsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Operator - def OutputsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - - # Operator - def BuiltinOptionsType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos) - return 0 - - # Operator - def BuiltinOptions(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - from flatbuffers.table import Table - obj = Table(bytearray(), 0) - self._tab.Union(obj, o) - return obj - return None - - # Operator - def CustomOptions(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) - return 0 - - # Operator - def CustomOptionsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o) - return 0 - - # Operator - def CustomOptionsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Operator - def CustomOptionsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - return o == 0 - - # Operator - def CustomOptionsFormat(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # Operator - def MutatingVariableInputs(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.BoolFlags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) - return 0 - - # Operator - def MutatingVariableInputsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.BoolFlags, o) - return 0 - - # Operator - def MutatingVariableInputsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Operator - def MutatingVariableInputsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - return o == 0 - - # Operator - def Intermediates(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # Operator - def IntermediatesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # Operator - def IntermediatesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Operator - def IntermediatesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20)) - return o == 0 - - # Operator - def LargeCustomOptionsOffset(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) - return 0 - - # Operator - def LargeCustomOptionsSize(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) - return 0 - - # Operator - def BuiltinOptions2Type(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos) - return 0 - - # Operator - def BuiltinOptions2(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28)) - if o != 0: - from flatbuffers.table import Table - obj = Table(bytearray(), 0) - self._tab.Union(obj, o) - return obj - return None - - # Operator - def DebugMetadataIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return -1 - -def OperatorStart(builder): - builder.StartObject(14) - -def OperatorAddOpcodeIndex(builder, opcodeIndex): - builder.PrependUint32Slot(0, opcodeIndex, 0) - -def OperatorAddInputs(builder, inputs): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(inputs), 0) - -def OperatorStartInputsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def OperatorAddOutputs(builder, outputs): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(outputs), 0) - -def OperatorStartOutputsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def OperatorAddBuiltinOptionsType(builder, builtinOptionsType): - builder.PrependUint8Slot(3, builtinOptionsType, 0) - -def OperatorAddBuiltinOptions(builder, builtinOptions): - builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(builtinOptions), 0) - -def OperatorAddCustomOptions(builder, customOptions): - builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(customOptions), 0) - -def OperatorStartCustomOptionsVector(builder, numElems): - return builder.StartVector(1, numElems, 1) - -def OperatorAddCustomOptionsFormat(builder, customOptionsFormat): - builder.PrependInt8Slot(6, customOptionsFormat, 0) - -def OperatorAddMutatingVariableInputs(builder, mutatingVariableInputs): - builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(mutatingVariableInputs), 0) - -def OperatorStartMutatingVariableInputsVector(builder, numElems): - return builder.StartVector(1, numElems, 1) - -def OperatorAddIntermediates(builder, intermediates): - builder.PrependUOffsetTRelativeSlot(8, flatbuffers.number_types.UOffsetTFlags.py_type(intermediates), 0) - -def OperatorStartIntermediatesVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def OperatorAddLargeCustomOptionsOffset(builder, largeCustomOptionsOffset): - builder.PrependUint64Slot(9, largeCustomOptionsOffset, 0) - -def OperatorAddLargeCustomOptionsSize(builder, largeCustomOptionsSize): - builder.PrependUint64Slot(10, largeCustomOptionsSize, 0) - -def OperatorAddBuiltinOptions2Type(builder, builtinOptions2Type): - builder.PrependUint8Slot(11, builtinOptions2Type, 0) - -def OperatorAddBuiltinOptions2(builder, builtinOptions2): - builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(builtinOptions2), 0) - -def OperatorAddDebugMetadataIndex(builder, debugMetadataIndex): - builder.PrependInt32Slot(13, debugMetadataIndex, -1) - -def OperatorEnd(builder): - return builder.EndObject() - - -try: - from typing import List, Union -except: - pass - -class OperatorT(object): - - # OperatorT - def __init__( - self, - opcodeIndex = 0, - inputs = None, - outputs = None, - builtinOptionsType = 0, - builtinOptions = None, - customOptions = None, - customOptionsFormat = 0, - mutatingVariableInputs = None, - intermediates = None, - largeCustomOptionsOffset = 0, - largeCustomOptionsSize = 0, - builtinOptions2Type = 0, - builtinOptions2 = None, - debugMetadataIndex = -1, - ): - self.opcodeIndex = opcodeIndex # type: int - self.inputs = inputs # type: Optional[List[int]] - self.outputs = outputs # type: Optional[List[int]] - self.builtinOptionsType = builtinOptionsType # type: int - self.builtinOptions = builtinOptions # type: Union[None, 'Conv2DOptionsT', 'DepthwiseConv2DOptionsT', 'ConcatEmbeddingsOptionsT', 'LSHProjectionOptionsT', 'Pool2DOptionsT', 'SVDFOptionsT', 'RNNOptionsT', 'FullyConnectedOptionsT', 'SoftmaxOptionsT', 'ConcatenationOptionsT', 'AddOptionsT', 'L2NormOptionsT', 'LocalResponseNormalizationOptionsT', 'LSTMOptionsT', 'ResizeBilinearOptionsT', 'CallOptionsT', 'ReshapeOptionsT', 'SkipGramOptionsT', 'SpaceToDepthOptionsT', 'EmbeddingLookupSparseOptionsT', 'MulOptionsT', 'PadOptionsT', 'GatherOptionsT', 'BatchToSpaceNDOptionsT', 'SpaceToBatchNDOptionsT', 'TransposeOptionsT', 'ReducerOptionsT', 'SubOptionsT', 'DivOptionsT', 'SqueezeOptionsT', 'SequenceRNNOptionsT', 'StridedSliceOptionsT', 'ExpOptionsT', 'TopKV2OptionsT', 'SplitOptionsT', 'LogSoftmaxOptionsT', 'CastOptionsT', 'DequantizeOptionsT', 'MaximumMinimumOptionsT', 'ArgMaxOptionsT', 'LessOptionsT', 'NegOptionsT', 'PadV2OptionsT', 'GreaterOptionsT', 'GreaterEqualOptionsT', 'LessEqualOptionsT', 'SelectOptionsT', 'SliceOptionsT', 'TransposeConvOptionsT', 'SparseToDenseOptionsT', 'TileOptionsT', 'ExpandDimsOptionsT', 'EqualOptionsT', 'NotEqualOptionsT', 'ShapeOptionsT', 'PowOptionsT', 'ArgMinOptionsT', 'FakeQuantOptionsT', 'PackOptionsT', 'LogicalOrOptionsT', 'OneHotOptionsT', 'LogicalAndOptionsT', 'LogicalNotOptionsT', 'UnpackOptionsT', 'FloorDivOptionsT', 'SquareOptionsT', 'ZerosLikeOptionsT', 'FillOptionsT', 'BidirectionalSequenceLSTMOptionsT', 'BidirectionalSequenceRNNOptionsT', 'UnidirectionalSequenceLSTMOptionsT', 'FloorModOptionsT', 'RangeOptionsT', 'ResizeNearestNeighborOptionsT', 'LeakyReluOptionsT', 'SquaredDifferenceOptionsT', 'MirrorPadOptionsT', 'AbsOptionsT', 'SplitVOptionsT', 'UniqueOptionsT', 'ReverseV2OptionsT', 'AddNOptionsT', 'GatherNdOptionsT', 'CosOptionsT', 'WhereOptionsT', 'RankOptionsT', 'ReverseSequenceOptionsT', 'MatrixDiagOptionsT', 'QuantizeOptionsT', 'MatrixSetDiagOptionsT', 'HardSwishOptionsT', 'IfOptionsT', 'WhileOptionsT', 'DepthToSpaceOptionsT', 'NonMaxSuppressionV4OptionsT', 'NonMaxSuppressionV5OptionsT', 'ScatterNdOptionsT', 'SelectV2OptionsT', 'DensifyOptionsT', 'SegmentSumOptionsT', 'BatchMatMulOptionsT', 'CumsumOptionsT', 'CallOnceOptionsT', 'BroadcastToOptionsT', 'Rfft2dOptionsT', 'Conv3DOptionsT', 'HashtableOptionsT', 'HashtableFindOptionsT', 'HashtableImportOptionsT', 'HashtableSizeOptionsT', 'VarHandleOptionsT', 'ReadVariableOptionsT', 'AssignVariableOptionsT', 'RandomOptionsT', 'BucketizeOptionsT', 'GeluOptionsT', 'DynamicUpdateSliceOptionsT', 'UnsortedSegmentProdOptionsT', 'UnsortedSegmentMaxOptionsT', 'UnsortedSegmentMinOptionsT', 'UnsortedSegmentSumOptionsT', 'ATan2OptionsT', 'SignOptionsT', 'BitcastOptionsT', 'BitwiseXorOptionsT', 'RightShiftOptionsT'] - self.customOptions = customOptions # type: Optional[List[int]] - self.customOptionsFormat = customOptionsFormat # type: int - self.mutatingVariableInputs = mutatingVariableInputs # type: Optional[List[bool]] - self.intermediates = intermediates # type: Optional[List[int]] - self.largeCustomOptionsOffset = largeCustomOptionsOffset # type: int - self.largeCustomOptionsSize = largeCustomOptionsSize # type: int - self.builtinOptions2Type = builtinOptions2Type # type: int - self.builtinOptions2 = builtinOptions2 # type: Union[None, 'StablehloConcatenateOptionsT', 'StablehloBroadcastInDimOptionsT', 'StablehloSliceOptionsT', 'StablehloConvolutionOptionsT', 'StablehloCustomCallOptionsT', 'StablehloReduceOptionsT', 'StablehloScatterOptionsT', 'StablehloCompareOptionsT', 'StablehloDynamicSliceOptionsT', 'StablehloPadOptionsT', 'StablehloIotaOptionsT', 'StablehloDotGeneralOptionsT', 'StablehloReduceWindowOptionsT', 'StablehloSortOptionsT', 'StablehloWhileOptionsT', 'StablehloGatherOptionsT', 'StablehloTransposeOptionsT', 'DilateOptionsT', 'StablehloRngBitGeneratorOptionsT', 'ReduceWindowOptionsT', 'StableHLOCompositeOptionsT', 'StablehloShiftLeftOptionsT', 'StablehloCaseOptionsT'] - self.debugMetadataIndex = debugMetadataIndex # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - operator = Operator() - operator.Init(buf, pos) - return cls.InitFromObj(operator) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, operator): - x = OperatorT() - x._UnPack(operator) - return x - - # OperatorT - def _UnPack(self, operator): - if operator is None: - return - self.opcodeIndex = operator.OpcodeIndex() - if not operator.InputsIsNone(): - if np is None: - self.inputs = [] - for i in range(operator.InputsLength()): - self.inputs.append(operator.Inputs(i)) - else: - self.inputs = operator.InputsAsNumpy() - if not operator.OutputsIsNone(): - if np is None: - self.outputs = [] - for i in range(operator.OutputsLength()): - self.outputs.append(operator.Outputs(i)) - else: - self.outputs = operator.OutputsAsNumpy() - self.builtinOptionsType = operator.BuiltinOptionsType() - self.builtinOptions = BuiltinOptionsCreator(self.builtinOptionsType, operator.BuiltinOptions()) - if not operator.CustomOptionsIsNone(): - if np is None: - self.customOptions = [] - for i in range(operator.CustomOptionsLength()): - self.customOptions.append(operator.CustomOptions(i)) - else: - self.customOptions = operator.CustomOptionsAsNumpy() - self.customOptionsFormat = operator.CustomOptionsFormat() - if not operator.MutatingVariableInputsIsNone(): - if np is None: - self.mutatingVariableInputs = [] - for i in range(operator.MutatingVariableInputsLength()): - self.mutatingVariableInputs.append(operator.MutatingVariableInputs(i)) - else: - self.mutatingVariableInputs = operator.MutatingVariableInputsAsNumpy() - if not operator.IntermediatesIsNone(): - if np is None: - self.intermediates = [] - for i in range(operator.IntermediatesLength()): - self.intermediates.append(operator.Intermediates(i)) - else: - self.intermediates = operator.IntermediatesAsNumpy() - self.largeCustomOptionsOffset = operator.LargeCustomOptionsOffset() - self.largeCustomOptionsSize = operator.LargeCustomOptionsSize() - self.builtinOptions2Type = operator.BuiltinOptions2Type() - self.builtinOptions2 = BuiltinOptions2Creator(self.builtinOptions2Type, operator.BuiltinOptions2()) - self.debugMetadataIndex = operator.DebugMetadataIndex() - - # OperatorT - def Pack(self, builder): - if self.inputs is not None: - if np is not None and type(self.inputs) is np.ndarray: - inputs = builder.CreateNumpyVector(self.inputs) - else: - OperatorStartInputsVector(builder, len(self.inputs)) - for i in reversed(range(len(self.inputs))): - builder.PrependInt32(self.inputs[i]) - inputs = builder.EndVector() - if self.outputs is not None: - if np is not None and type(self.outputs) is np.ndarray: - outputs = builder.CreateNumpyVector(self.outputs) - else: - OperatorStartOutputsVector(builder, len(self.outputs)) - for i in reversed(range(len(self.outputs))): - builder.PrependInt32(self.outputs[i]) - outputs = builder.EndVector() - if self.builtinOptions is not None: - builtinOptions = self.builtinOptions.Pack(builder) - if self.customOptions is not None: - if np is not None and type(self.customOptions) is np.ndarray: - customOptions = builder.CreateNumpyVector(self.customOptions) - else: - OperatorStartCustomOptionsVector(builder, len(self.customOptions)) - for i in reversed(range(len(self.customOptions))): - builder.PrependUint8(self.customOptions[i]) - customOptions = builder.EndVector() - if self.mutatingVariableInputs is not None: - if np is not None and type(self.mutatingVariableInputs) is np.ndarray: - mutatingVariableInputs = builder.CreateNumpyVector(self.mutatingVariableInputs) - else: - OperatorStartMutatingVariableInputsVector(builder, len(self.mutatingVariableInputs)) - for i in reversed(range(len(self.mutatingVariableInputs))): - builder.PrependBool(self.mutatingVariableInputs[i]) - mutatingVariableInputs = builder.EndVector() - if self.intermediates is not None: - if np is not None and type(self.intermediates) is np.ndarray: - intermediates = builder.CreateNumpyVector(self.intermediates) - else: - OperatorStartIntermediatesVector(builder, len(self.intermediates)) - for i in reversed(range(len(self.intermediates))): - builder.PrependInt32(self.intermediates[i]) - intermediates = builder.EndVector() - if self.builtinOptions2 is not None: - builtinOptions2 = self.builtinOptions2.Pack(builder) - OperatorStart(builder) - OperatorAddOpcodeIndex(builder, self.opcodeIndex) - if self.inputs is not None: - OperatorAddInputs(builder, inputs) - if self.outputs is not None: - OperatorAddOutputs(builder, outputs) - OperatorAddBuiltinOptionsType(builder, self.builtinOptionsType) - if self.builtinOptions is not None: - OperatorAddBuiltinOptions(builder, builtinOptions) - if self.customOptions is not None: - OperatorAddCustomOptions(builder, customOptions) - OperatorAddCustomOptionsFormat(builder, self.customOptionsFormat) - if self.mutatingVariableInputs is not None: - OperatorAddMutatingVariableInputs(builder, mutatingVariableInputs) - if self.intermediates is not None: - OperatorAddIntermediates(builder, intermediates) - OperatorAddLargeCustomOptionsOffset(builder, self.largeCustomOptionsOffset) - OperatorAddLargeCustomOptionsSize(builder, self.largeCustomOptionsSize) - OperatorAddBuiltinOptions2Type(builder, self.builtinOptions2Type) - if self.builtinOptions2 is not None: - OperatorAddBuiltinOptions2(builder, builtinOptions2) - OperatorAddDebugMetadataIndex(builder, self.debugMetadataIndex) - operator = OperatorEnd(builder) - return operator - - -class SubGraph(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SubGraph() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSubGraph(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SubGraphBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SubGraph - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SubGraph - def Tensors(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - obj = Tensor() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # SubGraph - def TensorsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # SubGraph - def TensorsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # SubGraph - def Inputs(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # SubGraph - def InputsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # SubGraph - def InputsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # SubGraph - def InputsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # SubGraph - def Outputs(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # SubGraph - def OutputsAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # SubGraph - def OutputsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # SubGraph - def OutputsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - - # SubGraph - def Operators(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - obj = Operator() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # SubGraph - def OperatorsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # SubGraph - def OperatorsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - return o == 0 - - # SubGraph - def Name(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - - # SubGraph - def DebugMetadataIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return -1 - -def SubGraphStart(builder): - builder.StartObject(6) - -def SubGraphAddTensors(builder, tensors): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(tensors), 0) - -def SubGraphStartTensorsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def SubGraphAddInputs(builder, inputs): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(inputs), 0) - -def SubGraphStartInputsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def SubGraphAddOutputs(builder, outputs): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(outputs), 0) - -def SubGraphStartOutputsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def SubGraphAddOperators(builder, operators): - builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(operators), 0) - -def SubGraphStartOperatorsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def SubGraphAddName(builder, name): - builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0) - -def SubGraphAddDebugMetadataIndex(builder, debugMetadataIndex): - builder.PrependInt32Slot(5, debugMetadataIndex, -1) - -def SubGraphEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class SubGraphT(object): - - # SubGraphT - def __init__( - self, - tensors = None, - inputs = None, - outputs = None, - operators = None, - name = None, - debugMetadataIndex = -1, - ): - self.tensors = tensors # type: Optional[List[TensorT]] - self.inputs = inputs # type: Optional[List[int]] - self.outputs = outputs # type: Optional[List[int]] - self.operators = operators # type: Optional[List[OperatorT]] - self.name = name # type: Optional[str] - self.debugMetadataIndex = debugMetadataIndex # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - subGraph = SubGraph() - subGraph.Init(buf, pos) - return cls.InitFromObj(subGraph) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, subGraph): - x = SubGraphT() - x._UnPack(subGraph) - return x - - # SubGraphT - def _UnPack(self, subGraph): - if subGraph is None: - return - if not subGraph.TensorsIsNone(): - self.tensors = [] - for i in range(subGraph.TensorsLength()): - if subGraph.Tensors(i) is None: - self.tensors.append(None) - else: - tensor_ = TensorT.InitFromObj(subGraph.Tensors(i)) - self.tensors.append(tensor_) - if not subGraph.InputsIsNone(): - if np is None: - self.inputs = [] - for i in range(subGraph.InputsLength()): - self.inputs.append(subGraph.Inputs(i)) - else: - self.inputs = subGraph.InputsAsNumpy() - if not subGraph.OutputsIsNone(): - if np is None: - self.outputs = [] - for i in range(subGraph.OutputsLength()): - self.outputs.append(subGraph.Outputs(i)) - else: - self.outputs = subGraph.OutputsAsNumpy() - if not subGraph.OperatorsIsNone(): - self.operators = [] - for i in range(subGraph.OperatorsLength()): - if subGraph.Operators(i) is None: - self.operators.append(None) - else: - operator_ = OperatorT.InitFromObj(subGraph.Operators(i)) - self.operators.append(operator_) - self.name = subGraph.Name() - self.debugMetadataIndex = subGraph.DebugMetadataIndex() - - # SubGraphT - def Pack(self, builder): - if self.tensors is not None: - tensorslist = [] - for i in range(len(self.tensors)): - tensorslist.append(self.tensors[i].Pack(builder)) - SubGraphStartTensorsVector(builder, len(self.tensors)) - for i in reversed(range(len(self.tensors))): - builder.PrependUOffsetTRelative(tensorslist[i]) - tensors = builder.EndVector() - if self.inputs is not None: - if np is not None and type(self.inputs) is np.ndarray: - inputs = builder.CreateNumpyVector(self.inputs) - else: - SubGraphStartInputsVector(builder, len(self.inputs)) - for i in reversed(range(len(self.inputs))): - builder.PrependInt32(self.inputs[i]) - inputs = builder.EndVector() - if self.outputs is not None: - if np is not None and type(self.outputs) is np.ndarray: - outputs = builder.CreateNumpyVector(self.outputs) - else: - SubGraphStartOutputsVector(builder, len(self.outputs)) - for i in reversed(range(len(self.outputs))): - builder.PrependInt32(self.outputs[i]) - outputs = builder.EndVector() - if self.operators is not None: - operatorslist = [] - for i in range(len(self.operators)): - operatorslist.append(self.operators[i].Pack(builder)) - SubGraphStartOperatorsVector(builder, len(self.operators)) - for i in reversed(range(len(self.operators))): - builder.PrependUOffsetTRelative(operatorslist[i]) - operators = builder.EndVector() - if self.name is not None: - name = builder.CreateString(self.name) - SubGraphStart(builder) - if self.tensors is not None: - SubGraphAddTensors(builder, tensors) - if self.inputs is not None: - SubGraphAddInputs(builder, inputs) - if self.outputs is not None: - SubGraphAddOutputs(builder, outputs) - if self.operators is not None: - SubGraphAddOperators(builder, operators) - if self.name is not None: - SubGraphAddName(builder, name) - SubGraphAddDebugMetadataIndex(builder, self.debugMetadataIndex) - subGraph = SubGraphEnd(builder) - return subGraph - - -class Buffer(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Buffer() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsBuffer(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def BufferBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # Buffer - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Buffer - def Data(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) - return 0 - - # Buffer - def DataAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o) - return 0 - - # Buffer - def DataLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Buffer - def DataIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # Buffer - def Offset(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) - return 0 - - # Buffer - def Size(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) - return 0 - -def BufferStart(builder): - builder.StartObject(3) - -def BufferAddData(builder, data): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(data), 0) - -def BufferStartDataVector(builder, numElems): - return builder.StartVector(1, numElems, 1) - -def BufferAddOffset(builder, offset): - builder.PrependUint64Slot(1, offset, 0) - -def BufferAddSize(builder, size): - builder.PrependUint64Slot(2, size, 0) - -def BufferEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class BufferT(object): - - # BufferT - def __init__( - self, - data = None, - offset = 0, - size = 0, - ): - self.data = data # type: Optional[List[int]] - self.offset = offset # type: int - self.size = size # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - buffer = Buffer() - buffer.Init(buf, pos) - return cls.InitFromObj(buffer) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, buffer): - x = BufferT() - x._UnPack(buffer) - return x - - # BufferT - def _UnPack(self, buffer): - if buffer is None: - return - if not buffer.DataIsNone(): - if np is None: - self.data = [] - for i in range(buffer.DataLength()): - self.data.append(buffer.Data(i)) - else: - self.data = buffer.DataAsNumpy() - self.offset = buffer.Offset() - self.size = buffer.Size() - - # BufferT - def Pack(self, builder): - if self.data is not None: - if np is not None and type(self.data) is np.ndarray: - data = builder.CreateNumpyVector(self.data) - else: - BufferStartDataVector(builder, len(self.data)) - for i in reversed(range(len(self.data))): - builder.PrependUint8(self.data[i]) - data = builder.EndVector() - BufferStart(builder) - if self.data is not None: - BufferAddData(builder, data) - BufferAddOffset(builder, self.offset) - BufferAddSize(builder, self.size) - buffer = BufferEnd(builder) - return buffer - - -class ExternalBufferGroup(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ExternalBufferGroup() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsExternalBufferGroup(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ExternalBufferGroupBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ExternalBufferGroup - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ExternalBufferGroup - def Name(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - -def ExternalBufferGroupStart(builder): - builder.StartObject(1) - -def ExternalBufferGroupAddName(builder, name): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0) - -def ExternalBufferGroupEnd(builder): - return builder.EndObject() - - - -class ExternalBufferGroupT(object): - - # ExternalBufferGroupT - def __init__( - self, - name = None, - ): - self.name = name # type: Optional[str] - - @classmethod - def InitFromBuf(cls, buf, pos): - externalBufferGroup = ExternalBufferGroup() - externalBufferGroup.Init(buf, pos) - return cls.InitFromObj(externalBufferGroup) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, externalBufferGroup): - x = ExternalBufferGroupT() - x._UnPack(externalBufferGroup) - return x - - # ExternalBufferGroupT - def _UnPack(self, externalBufferGroup): - if externalBufferGroup is None: - return - self.name = externalBufferGroup.Name() - - # ExternalBufferGroupT - def Pack(self, builder): - if self.name is not None: - name = builder.CreateString(self.name) - ExternalBufferGroupStart(builder) - if self.name is not None: - ExternalBufferGroupAddName(builder, name) - externalBufferGroup = ExternalBufferGroupEnd(builder) - return externalBufferGroup - - -class ExternalBuffer(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ExternalBuffer() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsExternalBuffer(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ExternalBufferBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # ExternalBuffer - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ExternalBuffer - def Id(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - - # ExternalBuffer - def Group(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - - # ExternalBuffer - def Offset(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) - return 0 - - # ExternalBuffer - def Length(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) - return 0 - - # ExternalBuffer - def Packing(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - -def ExternalBufferStart(builder): - builder.StartObject(5) - -def ExternalBufferAddId(builder, id): - builder.PrependUint32Slot(0, id, 0) - -def ExternalBufferAddGroup(builder, group): - builder.PrependUint32Slot(1, group, 0) - -def ExternalBufferAddOffset(builder, offset): - builder.PrependUint64Slot(2, offset, 0) - -def ExternalBufferAddLength(builder, length): - builder.PrependUint64Slot(3, length, 0) - -def ExternalBufferAddPacking(builder, packing): - builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(packing), 0) - -def ExternalBufferEnd(builder): - return builder.EndObject() - - - -class ExternalBufferT(object): - - # ExternalBufferT - def __init__( - self, - id = 0, - group = 0, - offset = 0, - length = 0, - packing = None, - ): - self.id = id # type: int - self.group = group # type: int - self.offset = offset # type: int - self.length = length # type: int - self.packing = packing # type: Optional[str] - - @classmethod - def InitFromBuf(cls, buf, pos): - externalBuffer = ExternalBuffer() - externalBuffer.Init(buf, pos) - return cls.InitFromObj(externalBuffer) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, externalBuffer): - x = ExternalBufferT() - x._UnPack(externalBuffer) - return x - - # ExternalBufferT - def _UnPack(self, externalBuffer): - if externalBuffer is None: - return - self.id = externalBuffer.Id() - self.group = externalBuffer.Group() - self.offset = externalBuffer.Offset() - self.length = externalBuffer.Length() - self.packing = externalBuffer.Packing() - - # ExternalBufferT - def Pack(self, builder): - if self.packing is not None: - packing = builder.CreateString(self.packing) - ExternalBufferStart(builder) - ExternalBufferAddId(builder, self.id) - ExternalBufferAddGroup(builder, self.group) - ExternalBufferAddOffset(builder, self.offset) - ExternalBufferAddLength(builder, self.length) - if self.packing is not None: - ExternalBufferAddPacking(builder, packing) - externalBuffer = ExternalBufferEnd(builder) - return externalBuffer - - -class Metadata(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Metadata() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsMetadata(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def MetadataBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # Metadata - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Metadata - def Name(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - - # Metadata - def Buffer(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - -def MetadataStart(builder): - builder.StartObject(2) - -def MetadataAddName(builder, name): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0) - -def MetadataAddBuffer(builder, buffer): - builder.PrependUint32Slot(1, buffer, 0) - -def MetadataEnd(builder): - return builder.EndObject() - - - -class MetadataT(object): - - # MetadataT - def __init__( - self, - name = None, - buffer = 0, - ): - self.name = name # type: Optional[str] - self.buffer = buffer # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - metadata = Metadata() - metadata.Init(buf, pos) - return cls.InitFromObj(metadata) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, metadata): - x = MetadataT() - x._UnPack(metadata) - return x - - # MetadataT - def _UnPack(self, metadata): - if metadata is None: - return - self.name = metadata.Name() - self.buffer = metadata.Buffer() - - # MetadataT - def Pack(self, builder): - if self.name is not None: - name = builder.CreateString(self.name) - MetadataStart(builder) - if self.name is not None: - MetadataAddName(builder, name) - MetadataAddBuffer(builder, self.buffer) - metadata = MetadataEnd(builder) - return metadata - - -class TensorMap(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = TensorMap() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsTensorMap(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def TensorMapBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # TensorMap - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # TensorMap - def Name(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - - # TensorMap - def TensorIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - -def TensorMapStart(builder): - builder.StartObject(2) - -def TensorMapAddName(builder, name): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0) - -def TensorMapAddTensorIndex(builder, tensorIndex): - builder.PrependUint32Slot(1, tensorIndex, 0) - -def TensorMapEnd(builder): - return builder.EndObject() - - - -class TensorMapT(object): - - # TensorMapT - def __init__( - self, - name = None, - tensorIndex = 0, - ): - self.name = name # type: Optional[str] - self.tensorIndex = tensorIndex # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - tensorMap = TensorMap() - tensorMap.Init(buf, pos) - return cls.InitFromObj(tensorMap) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, tensorMap): - x = TensorMapT() - x._UnPack(tensorMap) - return x - - # TensorMapT - def _UnPack(self, tensorMap): - if tensorMap is None: - return - self.name = tensorMap.Name() - self.tensorIndex = tensorMap.TensorIndex() - - # TensorMapT - def Pack(self, builder): - if self.name is not None: - name = builder.CreateString(self.name) - TensorMapStart(builder) - if self.name is not None: - TensorMapAddName(builder, name) - TensorMapAddTensorIndex(builder, self.tensorIndex) - tensorMap = TensorMapEnd(builder) - return tensorMap - - -class SignatureDef(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SignatureDef() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSignatureDef(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SignatureDefBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # SignatureDef - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SignatureDef - def Inputs(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - obj = TensorMap() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # SignatureDef - def InputsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # SignatureDef - def InputsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # SignatureDef - def Outputs(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - obj = TensorMap() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # SignatureDef - def OutputsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # SignatureDef - def OutputsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # SignatureDef - def SignatureKey(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - - # SignatureDef - def SubgraphIndex(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - -def SignatureDefStart(builder): - builder.StartObject(5) - -def SignatureDefAddInputs(builder, inputs): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(inputs), 0) - -def SignatureDefStartInputsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def SignatureDefAddOutputs(builder, outputs): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(outputs), 0) - -def SignatureDefStartOutputsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def SignatureDefAddSignatureKey(builder, signatureKey): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(signatureKey), 0) - -def SignatureDefAddSubgraphIndex(builder, subgraphIndex): - builder.PrependUint32Slot(4, subgraphIndex, 0) - -def SignatureDefEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class SignatureDefT(object): - - # SignatureDefT - def __init__( - self, - inputs = None, - outputs = None, - signatureKey = None, - subgraphIndex = 0, - ): - self.inputs = inputs # type: Optional[List[TensorMapT]] - self.outputs = outputs # type: Optional[List[TensorMapT]] - self.signatureKey = signatureKey # type: Optional[str] - self.subgraphIndex = subgraphIndex # type: int - - @classmethod - def InitFromBuf(cls, buf, pos): - signatureDef = SignatureDef() - signatureDef.Init(buf, pos) - return cls.InitFromObj(signatureDef) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, signatureDef): - x = SignatureDefT() - x._UnPack(signatureDef) - return x - - # SignatureDefT - def _UnPack(self, signatureDef): - if signatureDef is None: - return - if not signatureDef.InputsIsNone(): - self.inputs = [] - for i in range(signatureDef.InputsLength()): - if signatureDef.Inputs(i) is None: - self.inputs.append(None) - else: - tensorMap_ = TensorMapT.InitFromObj(signatureDef.Inputs(i)) - self.inputs.append(tensorMap_) - if not signatureDef.OutputsIsNone(): - self.outputs = [] - for i in range(signatureDef.OutputsLength()): - if signatureDef.Outputs(i) is None: - self.outputs.append(None) - else: - tensorMap_ = TensorMapT.InitFromObj(signatureDef.Outputs(i)) - self.outputs.append(tensorMap_) - self.signatureKey = signatureDef.SignatureKey() - self.subgraphIndex = signatureDef.SubgraphIndex() - - # SignatureDefT - def Pack(self, builder): - if self.inputs is not None: - inputslist = [] - for i in range(len(self.inputs)): - inputslist.append(self.inputs[i].Pack(builder)) - SignatureDefStartInputsVector(builder, len(self.inputs)) - for i in reversed(range(len(self.inputs))): - builder.PrependUOffsetTRelative(inputslist[i]) - inputs = builder.EndVector() - if self.outputs is not None: - outputslist = [] - for i in range(len(self.outputs)): - outputslist.append(self.outputs[i].Pack(builder)) - SignatureDefStartOutputsVector(builder, len(self.outputs)) - for i in reversed(range(len(self.outputs))): - builder.PrependUOffsetTRelative(outputslist[i]) - outputs = builder.EndVector() - if self.signatureKey is not None: - signatureKey = builder.CreateString(self.signatureKey) - SignatureDefStart(builder) - if self.inputs is not None: - SignatureDefAddInputs(builder, inputs) - if self.outputs is not None: - SignatureDefAddOutputs(builder, outputs) - if self.signatureKey is not None: - SignatureDefAddSignatureKey(builder, signatureKey) - SignatureDefAddSubgraphIndex(builder, self.subgraphIndex) - signatureDef = SignatureDefEnd(builder) - return signatureDef - - -class Model(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Model() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsModel(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ModelBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) - - # Model - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Model - def Version(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - - # Model - def OperatorCodes(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - obj = OperatorCode() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Model - def OperatorCodesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Model - def OperatorCodesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # Model - def Subgraphs(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - obj = SubGraph() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Model - def SubgraphsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Model - def SubgraphsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - - # Model - def Description(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return None - - # Model - def Buffers(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - obj = Buffer() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Model - def BuffersLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Model - def BuffersIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) - return o == 0 - - # Model - def MetadataBuffer(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # Model - def MetadataBufferAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # Model - def MetadataBufferLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Model - def MetadataBufferIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - return o == 0 - - # Model - def Metadata(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - obj = Metadata() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Model - def MetadataLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Model - def MetadataIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) - return o == 0 - - # Model - def SignatureDefs(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - obj = SignatureDef() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Model - def SignatureDefsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Model - def SignatureDefsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - return o == 0 - - # Model - def ExternalBufferGroups(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - obj = ExternalBufferGroup() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Model - def ExternalBufferGroupsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Model - def ExternalBufferGroupsIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20)) - return o == 0 - - # Model - def ExternalBuffers(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - obj = ExternalBuffer() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Model - def ExternalBuffersLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Model - def ExternalBuffersIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22)) - return o == 0 - -def ModelStart(builder): - builder.StartObject(10) - -def ModelAddVersion(builder, version): - builder.PrependUint32Slot(0, version, 0) - -def ModelAddOperatorCodes(builder, operatorCodes): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(operatorCodes), 0) - -def ModelStartOperatorCodesVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def ModelAddSubgraphs(builder, subgraphs): - builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(subgraphs), 0) - -def ModelStartSubgraphsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def ModelAddDescription(builder, description): - builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(description), 0) - -def ModelAddBuffers(builder, buffers): - builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(buffers), 0) - -def ModelStartBuffersVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def ModelAddMetadataBuffer(builder, metadataBuffer): - builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(metadataBuffer), 0) - -def ModelStartMetadataBufferVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def ModelAddMetadata(builder, metadata): - builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(metadata), 0) - -def ModelStartMetadataVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def ModelAddSignatureDefs(builder, signatureDefs): - builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(signatureDefs), 0) - -def ModelStartSignatureDefsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def ModelAddExternalBufferGroups(builder, externalBufferGroups): - builder.PrependUOffsetTRelativeSlot(8, flatbuffers.number_types.UOffsetTFlags.py_type(externalBufferGroups), 0) - -def ModelStartExternalBufferGroupsVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def ModelAddExternalBuffers(builder, externalBuffers): - builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(externalBuffers), 0) - -def ModelStartExternalBuffersVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def ModelEnd(builder): - return builder.EndObject() - - -try: - from typing import List -except: - pass - -class ModelT(object): - - # ModelT - def __init__( - self, - version = 0, - operatorCodes = None, - subgraphs = None, - description = None, - buffers = None, - metadataBuffer = None, - metadata = None, - signatureDefs = None, - externalBufferGroups = None, - externalBuffers = None, - ): - self.version = version # type: int - self.operatorCodes = operatorCodes # type: Optional[List[OperatorCodeT]] - self.subgraphs = subgraphs # type: Optional[List[SubGraphT]] - self.description = description # type: Optional[str] - self.buffers = buffers # type: Optional[List[BufferT]] - self.metadataBuffer = metadataBuffer # type: Optional[List[int]] - self.metadata = metadata # type: Optional[List[MetadataT]] - self.signatureDefs = signatureDefs # type: Optional[List[SignatureDefT]] - self.externalBufferGroups = externalBufferGroups # type: Optional[List[ExternalBufferGroupT]] - self.externalBuffers = externalBuffers # type: Optional[List[ExternalBufferT]] - - @classmethod - def InitFromBuf(cls, buf, pos): - model = Model() - model.Init(buf, pos) - return cls.InitFromObj(model) - - @classmethod - def InitFromPackedBuf(cls, buf, pos=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) - return cls.InitFromBuf(buf, pos+n) - - @classmethod - def InitFromObj(cls, model): - x = ModelT() - x._UnPack(model) - return x - - # ModelT - def _UnPack(self, model): - if model is None: - return - self.version = model.Version() - if not model.OperatorCodesIsNone(): - self.operatorCodes = [] - for i in range(model.OperatorCodesLength()): - if model.OperatorCodes(i) is None: - self.operatorCodes.append(None) - else: - operatorCode_ = OperatorCodeT.InitFromObj(model.OperatorCodes(i)) - self.operatorCodes.append(operatorCode_) - if not model.SubgraphsIsNone(): - self.subgraphs = [] - for i in range(model.SubgraphsLength()): - if model.Subgraphs(i) is None: - self.subgraphs.append(None) - else: - subGraph_ = SubGraphT.InitFromObj(model.Subgraphs(i)) - self.subgraphs.append(subGraph_) - self.description = model.Description() - if not model.BuffersIsNone(): - self.buffers = [] - for i in range(model.BuffersLength()): - if model.Buffers(i) is None: - self.buffers.append(None) - else: - buffer_ = BufferT.InitFromObj(model.Buffers(i)) - self.buffers.append(buffer_) - if not model.MetadataBufferIsNone(): - if np is None: - self.metadataBuffer = [] - for i in range(model.MetadataBufferLength()): - self.metadataBuffer.append(model.MetadataBuffer(i)) - else: - self.metadataBuffer = model.MetadataBufferAsNumpy() - if not model.MetadataIsNone(): - self.metadata = [] - for i in range(model.MetadataLength()): - if model.Metadata(i) is None: - self.metadata.append(None) - else: - metadata_ = MetadataT.InitFromObj(model.Metadata(i)) - self.metadata.append(metadata_) - if not model.SignatureDefsIsNone(): - self.signatureDefs = [] - for i in range(model.SignatureDefsLength()): - if model.SignatureDefs(i) is None: - self.signatureDefs.append(None) - else: - signatureDef_ = SignatureDefT.InitFromObj(model.SignatureDefs(i)) - self.signatureDefs.append(signatureDef_) - if not model.ExternalBufferGroupsIsNone(): - self.externalBufferGroups = [] - for i in range(model.ExternalBufferGroupsLength()): - if model.ExternalBufferGroups(i) is None: - self.externalBufferGroups.append(None) - else: - externalBufferGroup_ = ExternalBufferGroupT.InitFromObj(model.ExternalBufferGroups(i)) - self.externalBufferGroups.append(externalBufferGroup_) - if not model.ExternalBuffersIsNone(): - self.externalBuffers = [] - for i in range(model.ExternalBuffersLength()): - if model.ExternalBuffers(i) is None: - self.externalBuffers.append(None) - else: - externalBuffer_ = ExternalBufferT.InitFromObj(model.ExternalBuffers(i)) - self.externalBuffers.append(externalBuffer_) - - # ModelT - def Pack(self, builder): - if self.operatorCodes is not None: - operatorCodeslist = [] - for i in range(len(self.operatorCodes)): - operatorCodeslist.append(self.operatorCodes[i].Pack(builder)) - ModelStartOperatorCodesVector(builder, len(self.operatorCodes)) - for i in reversed(range(len(self.operatorCodes))): - builder.PrependUOffsetTRelative(operatorCodeslist[i]) - operatorCodes = builder.EndVector() - if self.subgraphs is not None: - subgraphslist = [] - for i in range(len(self.subgraphs)): - subgraphslist.append(self.subgraphs[i].Pack(builder)) - ModelStartSubgraphsVector(builder, len(self.subgraphs)) - for i in reversed(range(len(self.subgraphs))): - builder.PrependUOffsetTRelative(subgraphslist[i]) - subgraphs = builder.EndVector() - if self.description is not None: - description = builder.CreateString(self.description) - if self.buffers is not None: - bufferslist = [] - for i in range(len(self.buffers)): - bufferslist.append(self.buffers[i].Pack(builder)) - ModelStartBuffersVector(builder, len(self.buffers)) - for i in reversed(range(len(self.buffers))): - builder.PrependUOffsetTRelative(bufferslist[i]) - buffers = builder.EndVector() - if self.metadataBuffer is not None: - if np is not None and type(self.metadataBuffer) is np.ndarray: - metadataBuffer = builder.CreateNumpyVector(self.metadataBuffer) - else: - ModelStartMetadataBufferVector(builder, len(self.metadataBuffer)) - for i in reversed(range(len(self.metadataBuffer))): - builder.PrependInt32(self.metadataBuffer[i]) - metadataBuffer = builder.EndVector() - if self.metadata is not None: - metadatalist = [] - for i in range(len(self.metadata)): - metadatalist.append(self.metadata[i].Pack(builder)) - ModelStartMetadataVector(builder, len(self.metadata)) - for i in reversed(range(len(self.metadata))): - builder.PrependUOffsetTRelative(metadatalist[i]) - metadata = builder.EndVector() - if self.signatureDefs is not None: - signatureDefslist = [] - for i in range(len(self.signatureDefs)): - signatureDefslist.append(self.signatureDefs[i].Pack(builder)) - ModelStartSignatureDefsVector(builder, len(self.signatureDefs)) - for i in reversed(range(len(self.signatureDefs))): - builder.PrependUOffsetTRelative(signatureDefslist[i]) - signatureDefs = builder.EndVector() - if self.externalBufferGroups is not None: - externalBufferGroupslist = [] - for i in range(len(self.externalBufferGroups)): - externalBufferGroupslist.append(self.externalBufferGroups[i].Pack(builder)) - ModelStartExternalBufferGroupsVector(builder, len(self.externalBufferGroups)) - for i in reversed(range(len(self.externalBufferGroups))): - builder.PrependUOffsetTRelative(externalBufferGroupslist[i]) - externalBufferGroups = builder.EndVector() - if self.externalBuffers is not None: - externalBufferslist = [] - for i in range(len(self.externalBuffers)): - externalBufferslist.append(self.externalBuffers[i].Pack(builder)) - ModelStartExternalBuffersVector(builder, len(self.externalBuffers)) - for i in reversed(range(len(self.externalBuffers))): - builder.PrependUOffsetTRelative(externalBufferslist[i]) - externalBuffers = builder.EndVector() - ModelStart(builder) - ModelAddVersion(builder, self.version) - if self.operatorCodes is not None: - ModelAddOperatorCodes(builder, operatorCodes) - if self.subgraphs is not None: - ModelAddSubgraphs(builder, subgraphs) - if self.description is not None: - ModelAddDescription(builder, description) - if self.buffers is not None: - ModelAddBuffers(builder, buffers) - if self.metadataBuffer is not None: - ModelAddMetadataBuffer(builder, metadataBuffer) - if self.metadata is not None: - ModelAddMetadata(builder, metadata) - if self.signatureDefs is not None: - ModelAddSignatureDefs(builder, signatureDefs) - if self.externalBufferGroups is not None: - ModelAddExternalBufferGroups(builder, externalBufferGroups) - if self.externalBuffers is not None: - ModelAddExternalBuffers(builder, externalBuffers) - model = ModelEnd(builder) - return model - - diff --git a/app/src/main/java/com/example/studentfaceregistry/MainActivity.kt b/app/src/main/java/com/example/studentfaceregistry/MainActivity.kt index 3d1af61..9ad9db1 100644 --- a/app/src/main/java/com/example/studentfaceregistry/MainActivity.kt +++ b/app/src/main/java/com/example/studentfaceregistry/MainActivity.kt @@ -86,6 +86,9 @@ class MainActivity : AppCompatActivity() { private val recognitionCache = mutableMapOf() private var lastVisibleDetections: List = emptyList() private var lastVisibleDetectionsAt = 0L + private var perfFrameCount = 0 + private var perfDetectMsSum = 0L + private var perfRefreshMsSum = 0L private val permissionLauncher = registerForActivityResult( ActivityResultContracts.RequestMultiplePermissions() @@ -285,6 +288,10 @@ class MainActivity : AppCompatActivity() { text = "保存识别参数" setOnClickListener { saveMatcherConfig() } }) + matcherConfigPanel.addView(Button(this@MainActivity).apply { + text = "自动校准阈值" + setOnClickListener { applySuggestedThresholds() } + }) addView(matcherConfigPanel) @@ -431,7 +438,39 @@ class MainActivity : AppCompatActivity() { private fun startRecognitionSession() { if (currentMode != AppMode.RECOGNITION) return - val faceProcessor = ensureProcessor() ?: return + recognitionStatusText.text = "正在加载模型..." + lifecycleScope.launch(Dispatchers.IO) { + val existing = processor + if (existing != null) { + withContext(Dispatchers.Main) { + if (currentMode == AppMode.RECOGNITION) bindRecognitionCamera(existing) + } + return@launch + } + + val created = runCatching { + FaceProcessor(this@MainActivity).also { it.warmUp() } + } + withContext(Dispatchers.Main) { + if (currentMode != AppMode.RECOGNITION) { + created.getOrNull()?.close() + return@withContext + } + val faceProcessor = created.getOrNull() + if (faceProcessor == null) { + val error = created.exceptionOrNull() + val message = error?.message ?: error?.javaClass?.simpleName ?: "unknown error" + recognitionStatusText.text = "模型初始化失败:$message" + toast("模型初始化失败:$message") + return@withContext + } + processor = faceProcessor + bindRecognitionCamera(faceProcessor) + } + } + } + + private fun bindRecognitionCamera(faceProcessor: FaceProcessor) { previewView.post { val providerFuture = ProcessCameraProvider.getInstance(this) providerFuture.addListener({ @@ -515,7 +554,9 @@ class MainActivity : AppCompatActivity() { try { val mediaImage = image.image ?: return@launch val inputImage = InputImage.fromMediaImage(mediaImage, image.imageInfo.rotationDegrees) + val detectStart = SystemClock.elapsedRealtime() val faces = faceProcessor.detectFaces(inputImage) + val detectMs = SystemClock.elapsedRealtime() - detectStart if (faces.isEmpty()) { withContext(Dispatchers.Main) { @@ -543,11 +584,27 @@ class MainActivity : AppCompatActivity() { val refreshedResults = mutableMapOf() if (facesNeedingRefresh.isNotEmpty()) { + val refreshStart = SystemClock.elapsedRealtime() val bitmap = ImageUtils.imageProxyToBitmap(image) facesNeedingRefresh.forEach { (index, face) -> val refreshed = refreshRecognition(faceProcessor, bitmap, face) refreshedResults[index] = refreshed } + val refreshMs = SystemClock.elapsedRealtime() - refreshStart + perfFrameCount++ + perfDetectMsSum += detectMs + perfRefreshMsSum += refreshMs + if (perfFrameCount >= 60) { + Log.i( + "MainActivity", + "FacePerf 检测平均=${perfDetectMsSum / perfFrameCount}ms " + + "刷新推理平均=${perfRefreshMsSum / perfFrameCount}ms " + + "人脸数=${faces.size}" + ) + perfFrameCount = 0 + perfDetectMsSum = 0L + perfRefreshMsSum = 0L + } } val rawDetections = faces.mapIndexed { index, face -> @@ -655,23 +712,6 @@ class MainActivity : AppCompatActivity() { uploadUrlText.text = "-" } - private fun ensureProcessor(): FaceProcessor? { - val current = processor - if (current != null) return current - - val created = runCatching { - FaceProcessor(this).also { it.warmUp() } - } - .onFailure { - val message = it.message ?: "unknown error" - recognitionStatusText.text = "模型初始化失败:$message" - toast("模型初始化失败:$message") - } - .getOrNull() - processor = created - return created - } - private fun hasCameraPermission(): Boolean { return ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED } @@ -722,6 +762,20 @@ class MainActivity : AppCompatActivity() { return "当前参数:欧氏 <= ${formatThreshold(euclideanThreshold)},余弦 >= ${formatThreshold(cosineThreshold)}" } + private fun applySuggestedThresholds() { + if (students.size < 3) { + toast("至少需要 3 名已注册学生才能校准阈值") + return + } + val suggested = matcher.suggestThresholds(students) + euclideanThresholdInput.setText(formatThreshold(suggested.euclidean)) + cosineThresholdInput.setText(formatThreshold(suggested.cosine)) + matcherConfigSummaryText.text = + "建议参数(基于 ${students.size} 名学生):欧氏 <= ${formatThreshold(suggested.euclidean)}," + + "余弦 >= ${formatThreshold(suggested.cosine)},点击“保存识别参数”生效" + toast("已填入建议阈值,确认后点击保存") + } + private fun formatThreshold(value: Float): String { return String.format(java.util.Locale.US, "%.2f", value) } @@ -860,11 +914,11 @@ class MainActivity : AppCompatActivity() { ): RecognitionResult { val primary = matcher.findNearest(faceProcessor.embedFace(bitmap, face), students) val cached = face.trackingId?.let { recognitionCache[it] } + // 未匹配时只做单次推理;仅在疑似匹配或人脸明显移动时才用多裁剪升级, + // 避免对陌生面孔持续做 3 次推理 val needsEscalation = cached == null || - !cached.result.isMatched || - primary.matchType != MatchType.MATCH || - primary.confidence < cached.result.confidence - 0.05f || - hasTrackMovedSignificantly(cached.lastBounds, face.boundingBox) + hasTrackMovedSignificantly(cached.lastBounds, face.boundingBox) || + primary.matchType != MatchType.NO_MATCH if (!needsEscalation) { return primary @@ -944,15 +998,15 @@ class MainActivity : AppCompatActivity() { private const val DEFAULT_EUCLIDEAN_THRESHOLD = 1.0f private const val DEFAULT_COSINE_THRESHOLD = 0.6f private const val MATCH_REFRESH_MS = 900L - private const val UNSURE_REFRESH_MS = 260L - private const val NO_MATCH_REFRESH_MS = 160L + private const val UNSURE_REFRESH_MS = 500L + private const val NO_MATCH_REFRESH_MS = 800L private const val TRACK_STALE_MS = 900L private const val TRACK_MOVE_THRESHOLD = 0.16f private const val TRACK_SIZE_THRESHOLD = 0.20f private const val MATCH_STABLE_CONFIDENCE = 0.82f private const val ANALYSIS_INTERVAL_MS = 80L private const val DETECTION_GRACE_MS = 700L - private val ANALYSIS_SIZE = Size(640, 480) + private val ANALYSIS_SIZE = Size(1280, 720) } } diff --git a/app/src/main/java/com/example/studentfaceregistry/data/Student.kt b/app/src/main/java/com/example/studentfaceregistry/data/Student.kt index 72e8865..1383f04 100644 --- a/app/src/main/java/com/example/studentfaceregistry/data/Student.kt +++ b/app/src/main/java/com/example/studentfaceregistry/data/Student.kt @@ -6,5 +6,6 @@ data class Student( val name: String, val photoUri: String, val embedding: FloatArray, + val extraEmbeddings: List = emptyList(), val createdAt: Long = System.currentTimeMillis() ) diff --git a/app/src/main/java/com/example/studentfaceregistry/data/StudentRepository.kt b/app/src/main/java/com/example/studentfaceregistry/data/StudentRepository.kt index 991d578..d265648 100644 --- a/app/src/main/java/com/example/studentfaceregistry/data/StudentRepository.kt +++ b/app/src/main/java/com/example/studentfaceregistry/data/StudentRepository.kt @@ -39,6 +39,7 @@ class StudentRepository(context: Context) { name = obj.getString("name"), photoUri = obj.getString("photoUri"), embedding = decodeEmbedding(obj.getJSONArray("embedding")), + extraEmbeddings = decodeEmbeddings(obj.optJSONArray("extraEmbeddings")), createdAt = obj.optLong("createdAt", System.currentTimeMillis()) ) ) @@ -57,6 +58,10 @@ class StudentRepository(context: Context) { put("photoUri", student.photoUri) put("createdAt", student.createdAt) put("embedding", JSONArray(student.embedding.toList())) + put( + "extraEmbeddings", + JSONArray(student.extraEmbeddings.map { JSONArray(it.toList()) }) + ) } ) } @@ -66,4 +71,13 @@ class StudentRepository(context: Context) { private fun decodeEmbedding(array: JSONArray): FloatArray { return FloatArray(array.length()) { index -> array.getDouble(index).toFloat() } } + + private fun decodeEmbeddings(array: JSONArray?): List { + if (array == null) return emptyList() + return buildList { + for (index in 0 until array.length()) { + add(decodeEmbedding(array.getJSONArray(index))) + } + } + } } diff --git a/app/src/main/java/com/example/studentfaceregistry/face/FaceEmbedder.kt b/app/src/main/java/com/example/studentfaceregistry/face/FaceEmbedder.kt index 2bf4cb3..c57ee8f 100644 --- a/app/src/main/java/com/example/studentfaceregistry/face/FaceEmbedder.kt +++ b/app/src/main/java/com/example/studentfaceregistry/face/FaceEmbedder.kt @@ -125,7 +125,7 @@ class FaceEmbedder(context: Context, private val modelType: ModelType = ModelTyp companion object { private const val TAG = "FaceEmbedder" - const val MODEL_ASSET_NAME = "facenet.tflite" + const val MODEL_ASSET_NAME = "mobilefacenet.tflite" } private fun inferInputSize(floatCount: Int): Int { diff --git a/app/src/main/java/com/example/studentfaceregistry/face/FaceMatcher.kt b/app/src/main/java/com/example/studentfaceregistry/face/FaceMatcher.kt index 5dabe41..2314d9a 100644 --- a/app/src/main/java/com/example/studentfaceregistry/face/FaceMatcher.kt +++ b/app/src/main/java/com/example/studentfaceregistry/face/FaceMatcher.kt @@ -28,7 +28,13 @@ class FaceMatcher( var secondNearestEuclidean = Float.MAX_VALUE for (student in students) { - val cosineSim = cosineSimilarity(embedding, student.embedding) + // 对该学生存储的所有特征(主特征 + 多角度补充特征)取最高相似度 + var bestCosine = -Float.MAX_VALUE + for (candidate in student.allEmbeddings()) { + val cosineSim = cosineSimilarity(embedding, candidate) + if (cosineSim > bestCosine) bestCosine = cosineSim + } + val cosineSim = bestCosine val euclideanDist = euclideanDistanceFromCosine(cosineSim) if (euclideanDist < nearestEuclidean) { @@ -51,26 +57,6 @@ class FaceMatcher( } } - /** - * 查找所有可能的匹配(返回多个候选) - */ - fun findAllMatches( - embedding: FloatArray, - students: List, - topK: Int = 3 - ): List { - val candidates = students.map { student -> - val cosineSim = cosineSimilarity(embedding, student.embedding) - MatchCandidate( - student = student, - euclideanDistance = euclideanDistanceFromCosine(cosineSim), - cosineSimilarity = cosineSim - ) - } - - return candidates.sortedBy { it.euclideanDistance }.take(topK) - } - /** * 计算欧氏距离 */ @@ -84,6 +70,8 @@ class FaceMatcher( return sqrt(sum) } + private fun Student.allEmbeddings(): List = listOf(embedding) + extraEmbeddings + /** * 对已 L2 归一化向量,通过余弦相似度推导欧氏距离,避免重复遍历 */ @@ -136,14 +124,17 @@ class FaceMatcher( /** * 根据一组距离自适应调整阈值 - * 适用于首次导入大量数据后优化识别效果 + * 基于已注册学生两两之间的(异类)距离分布给出保守建议: + * 阈值取异类距离分布的低分位,保证绝大多数异类对被正确拒绝。 + * 注意:本方法没有同人距离数据,只能给出"上界"参考, + * 现场采集同人数据后可进一步放宽。 */ fun suggestThresholds(students: List): SuggestedThresholds { if (students.size < 3) { return SuggestedThresholds(euclideanThreshold, cosineThreshold) } - // 计算所有学生两两之间的距离(采样) + // 计算所有学生两两之间的距离(采样,上限 200 对) val distances = mutableListOf() val sampleSize = minOf(students.size, 50) val step = maxOf(1, students.size / sampleSize) @@ -161,13 +152,15 @@ class FaceMatcher( distances.sort() - // 建议使用较小百分位作为阈值(假设同一个人多次录入的距离较小) + // 使用低分位异类距离作为欧氏阈值上界:仅约 10% 的异类对会低于该距离 val p10Index = (distances.size * 0.1).toInt().coerceIn(0, distances.size - 1) - val p20Index = (distances.size * 0.2).toInt().coerceIn(0, distances.size - 1) + val p05Index = (distances.size * 0.05).toInt().coerceIn(0, distances.size - 1) + val suggestedEuclidean = distances[p10Index] return SuggestedThresholds( - euclidean = distances[p10Index], - cosine = 1f - distances[p20Index] * 0.5f + euclidean = suggestedEuclidean, + // 对 L2 归一化向量:cos = 1 - d^2 / 2,用更保守的 p05 距离推导余弦阈值 + cosine = 1f - (distances[p05Index] * distances[p05Index]) / 2f ) } } @@ -182,15 +175,6 @@ enum class MatchType { NO_DATA // 没有数据 } -/** - * 匹配候选 - */ -data class MatchCandidate( - val student: Student, - val euclideanDistance: Float, - val cosineSimilarity: Float -) - /** * 建议的阈值 */ diff --git a/app/src/main/java/com/example/studentfaceregistry/face/SmartEnrollment.kt b/app/src/main/java/com/example/studentfaceregistry/face/SmartEnrollment.kt index 7328f08..419e9e6 100644 --- a/app/src/main/java/com/example/studentfaceregistry/face/SmartEnrollment.kt +++ b/app/src/main/java/com/example/studentfaceregistry/face/SmartEnrollment.kt @@ -12,8 +12,10 @@ import com.google.mlkit.vision.face.FaceDetection import com.google.mlkit.vision.face.FaceDetectorOptions import com.google.mlkit.vision.face.FaceLandmark import kotlinx.coroutines.tasks.await +import kotlin.math.abs import kotlin.math.PI import kotlin.math.atan2 +import kotlin.math.roundToInt import kotlin.math.sqrt /** @@ -79,6 +81,28 @@ class SmartEnrollment(context: Context) : AutoCloseable { faceInfo.faceArea } + // 质量检查:人脸大小 + val faceBox = largestFace.face.boundingBox + if (faceBox.width() < MIN_ENROLL_FACE_PX || faceBox.height() < MIN_ENROLL_FACE_PX) { + return EnrollmentResult.Failure( + "照片中的人脸太小(${faceBox.width()}px),请换更近或更高清的照片。" + ) + } + + // 质量检查:角度 + val yaw = yawAngle(largestFace.face) + val pitch = pitchAngle(largestFace.face) + if (abs(yaw) > MAX_ENROLL_YAW || abs(pitch) > MAX_ENROLL_PITCH) { + return EnrollmentResult.Failure( + "请使用正面人脸照片(当前左右偏转 ${yaw.roundToInt()}°、上下 ${pitch.roundToInt()}°)。" + ) + } + + // 质量检查:清晰度 + if (!isSharpEnough(cropFace(bitmap, largestFace.cropRect))) { + return EnrollmentResult.Failure("照片模糊,请换更清晰的照片。") + } + val embeddings = mutableListOf() for (paddingRatio in IMAGE_PADDING_RATIOS) { val cropRect = safeCropRect(bitmap, largestFace.face.boundingBox, paddingRatio) ?: continue @@ -131,6 +155,9 @@ class SmartEnrollment(context: Context) : AutoCloseable { faceInfo.faceArea } + if (largestFace.face.boundingBox.width() < MIN_ENROLL_FACE_PX) return@mapNotNull null + if (!isSharpEnough(cropFace(bitmap, largestFace.cropRect))) return@mapNotNull null + FaceFrameInfo(bitmap, largestFace.face, largestFace.cropRect, largestFace.faceArea) } @@ -147,15 +174,15 @@ class SmartEnrollment(context: Context) : AutoCloseable { val selectedFrames = selectBestFramesFromGroups(groupedFrames, maxFrames) // 提取每帧的特征 - val embeddings = selectedFrames.map { frameInfo -> - val cropped = cropFace(frameInfo.bitmap, frameInfo.cropRect) - val aligned = alignFace(cropped, frameInfo.face, frameInfo.cropRect) - val preprocessed = preprocessor.preprocess(aligned) - embedder.embed(preprocessed) + val frameEmbeddings = selectedFrames.map { frameInfo -> + frameInfo to embedFrame(frameInfo) } - // 融合特征 - val fusedEmbedding = fuseEmbeddings(embeddings) + // 按偏航角分组:正脸融合为主特征,左右侧脸融合为补充特征 + val (primaryEmbeddings, extraEmbeddings) = splitByYaw(frameEmbeddings) + val fusedEmbedding = fuseEmbeddings(primaryEmbeddings) + // splitByYaw 返回的补充特征已经是每组融合后的向量 + val fusedExtras = extraEmbeddings // 计算角度覆盖 val yawRange = calculateAngleRange(selectedFrames, { f -> yawAngle(f.face) }) @@ -166,7 +193,8 @@ class SmartEnrollment(context: Context) : AutoCloseable { sourceType = EnrollmentSourceType.VIDEO, frameCount = selectedFrames.size, yawRange = yawRange, - pitchRange = pitchRange + pitchRange = pitchRange, + extraEmbeddings = fusedExtras ) } catch (e: Exception) { EnrollmentResult.Failure("视频处理失败:${e.message}") @@ -337,6 +365,82 @@ class SmartEnrollment(context: Context) : AutoCloseable { return Bitmap.createBitmap(bitmap, box.left, box.top, box.width(), box.height()) } + /** + * 对单帧提取特征(裁剪 + 对齐 + 预处理 + 推理) + */ + private fun embedFrame(frameInfo: FaceFrameInfo): FloatArray { + val cropped = cropFace(frameInfo.bitmap, frameInfo.cropRect) + val aligned = alignFace(cropped, frameInfo.face, frameInfo.cropRect) + val preprocessed = preprocessor.preprocess(aligned) + return embedder.embed(preprocessed) + } + + /** + * 按偏航角将帧特征分组:正脸(主特征)、左右侧脸(补充特征) + */ + private fun splitByYaw( + frames: List> + ): Pair, List> { + val front = mutableListOf() + val left = mutableListOf() + val right = mutableListOf() + + for ((frameInfo, embedding) in frames) { + val yaw = yawAngle(frameInfo.face) + when { + yaw < -10f -> left.add(embedding) + yaw > 10f -> right.add(embedding) + else -> front.add(embedding) + } + } + + val extras = mutableListOf() + if (left.size >= 2) extras.add(fuseEmbeddings(left)) + if (right.size >= 2) extras.add(fuseEmbeddings(right)) + val primary = if (front.isNotEmpty()) front else frames.map { it.second } + return primary to extras + } + + /** + * 基于 Laplacian 方差判断人脸区域是否清晰 + */ + private fun isSharpEnough(bitmap: Bitmap, threshold: Double = BLUR_VARIANCE_THRESHOLD): Boolean { + val width = bitmap.width + val height = bitmap.height + if (width < 3 || height < 3) return false + + val pixels = IntArray(width * height) + bitmap.getPixels(pixels, 0, width, 0, 0, width, height) + + var sum = 0.0 + var sumSquares = 0.0 + var count = 0L + for (y in 1 until height - 1) { + var index = y * width + 1 + for (x in 1 until width - 1) { + val lap = 4 * luma(pixels[index]) - + luma(pixels[index - 1]) - luma(pixels[index + 1]) - + luma(pixels[index - width]) - luma(pixels[index + width]) + sum += lap + sumSquares += lap * lap + count++ + index++ + } + } + if (count == 0L) return false + + val mean = sum / count + val variance = sumSquares / count - mean * mean + return variance >= threshold + } + + private fun luma(pixel: Int): Int { + val r = (pixel shr 16) and 0xFF + val g = (pixel shr 8) and 0xFF + val b = pixel and 0xFF + return (r * 299 + g * 587 + b * 114) / 1000 + } + private suspend fun detectUsableFaces(bitmap: Bitmap): List { return detector.process(InputImage.fromBitmap(bitmap, 0)).await() .mapNotNull { face -> @@ -430,6 +534,10 @@ class SmartEnrollment(context: Context) : AutoCloseable { private val VIDEO_EXTENSIONS = setOf(".mp4", ".avi", ".mov", ".wmv", ".flv", ".mkv", ".webm", ".3gp") private val VIDEO_MIME_TYPES = setOf("application/mp4") private val IMAGE_PADDING_RATIOS = floatArrayOf(0.18f, 0.25f, 0.34f) + private const val MIN_ENROLL_FACE_PX = 96 + private const val MAX_ENROLL_YAW = 30f + private const val MAX_ENROLL_PITCH = 15f + private const val BLUR_VARIANCE_THRESHOLD = 40.0 } } @@ -476,7 +584,8 @@ sealed class EnrollmentResult { val sourceType: EnrollmentSourceType = EnrollmentSourceType.IMAGE, val frameCount: Int = 1, val yawRange: Float = 0f, - val pitchRange: Float = 0f + val pitchRange: Float = 0f, + val extraEmbeddings: List = emptyList() ) : EnrollmentResult() { override fun equals(other: Any?): Boolean { if (this === other) return true @@ -489,6 +598,10 @@ sealed class EnrollmentResult { if (pitchRange != other.pitchRange) return false if (!embedding.contentEquals(other.embedding)) return false if (sourceType != other.sourceType) return false + if (extraEmbeddings.size != other.extraEmbeddings.size) return false + if (extraEmbeddings.indices.any { + !extraEmbeddings[it].contentEquals(other.extraEmbeddings[it]) + }) return false return true } @@ -499,6 +612,7 @@ sealed class EnrollmentResult { result = 31 * result + pitchRange.hashCode() result = 31 * result + embedding.contentHashCode() result = 31 * result + sourceType.hashCode() + result = 31 * result + extraEmbeddings.sumOf { it.contentHashCode() } return result } } diff --git a/app/src/main/java/com/example/studentfaceregistry/face/VideoEnrollment.kt b/app/src/main/java/com/example/studentfaceregistry/face/VideoEnrollment.kt deleted file mode 100644 index dcc1cb3..0000000 --- a/app/src/main/java/com/example/studentfaceregistry/face/VideoEnrollment.kt +++ /dev/null @@ -1,388 +0,0 @@ -package com.example.studentfaceregistry.face - -import android.graphics.Bitmap -import android.graphics.Rect -import com.google.mlkit.vision.common.InputImage -import com.google.mlkit.vision.face.Face -import com.google.mlkit.vision.face.FaceDetection -import com.google.mlkit.vision.face.FaceDetectorOptions -import com.google.mlkit.vision.face.FaceLandmark -import kotlinx.coroutines.tasks.await -import kotlin.math.PI -import kotlin.math.abs -import kotlin.math.atan2 -import kotlin.math.cos -import kotlin.math.sin -import kotlin.math.sqrt - -/** - * 视频人脸注册器 - * 从视频中提取多角度人脸帧,融合生成更鲁棒的特征向量 - * - * 使用场景: - * - 学生录制视频时转头、点头 - * - 自动选择质量好的帧 - * - 融合多帧特征,提升识别准确率 - */ -class VideoEnrollment(private val context: android.content.Context) : AutoCloseable { - - private val detector = FaceDetection.getClient( - FaceDetectorOptions.Builder() - .setPerformanceMode(FaceDetectorOptions.PERFORMANCE_MODE_ACCURATE) - .setLandmarkMode(FaceDetectorOptions.LANDMARK_MODE_ALL) - .setClassificationMode(FaceDetectorOptions.CLASSIFICATION_MODE_ALL) - .build() - ) - - private val embedder = FaceEmbedder(context, FaceEmbedder.ModelType.ARCFACE) - - /** - * 从视频帧序列中提取人脸特征 - * @param frames 视频帧列表(Bitmap) - * @param minFrames 最少需要的人脸帧数 - * @param maxFrames 最多使用的人脸帧数(用于特征融合) - * @return 融合后的特征向量 - */ - suspend fun enrollFromFrames( - frames: List, - minFrames: Int = 5, - maxFrames: Int = 20 - ): VideoEnrollmentResult { - val faceFrames = mutableListOf() - - // 检测所有帧中的人脸 - for ((index, frame) in frames.withIndex()) { - val faces = detector.process(InputImage.fromBitmap(frame, 0)).await() - for (face in faces) { - val quality = calculateFaceQuality(face) - if (quality >= MIN_QUALITY_THRESHOLD) { - val yaw = calculateYawAngle(face) - val pitch = calculatePitchAngle(face) - faceFrames.add( - FaceFrame( - bitmap = frame, - face = face, - quality = quality, - yaw = yaw, - pitch = pitch, - frameIndex = index - ) - ) - } - } - } - - if (faceFrames.size < minFrames) { - return VideoEnrollmentResult.Failure( - reason = "检测到 ${faceFrames.size} 帧有效人脸,需要至少 $minFrames 帧。请确保视频中人脸清晰且有多角度展示。" - ) - } - - // 按角度分组,确保多角度覆盖 - val groupedFrames = groupFramesByAngle(faceFrames) - - // 从每组选择质量最好的帧 - val selectedFrames = selectBestFramesFromGroups(groupedFrames, maxFrames) - - // 提取每帧的特征 - val embeddings = selectedFrames.map { frame -> - extractSingleEmbedding(frame) - } - - // 融合特征(平均 + L2 归一化) - val fusedEmbedding = fuseEmbeddings(embeddings) - - return VideoEnrollmentResult.Success( - embedding = fusedEmbedding, - frameCount = selectedFrames.size, - totalDetected = faceFrames.size, - angleCoverage = calculateAngleCoverage(selectedFrames) - ) - } - - /** - * 计算人脸质量分数(0-1) - */ - private fun calculateFaceQuality(face: Face): Float { - var score = 1.0f - - // 可见度分数 - val leftEyeVisible = face.getLandmark(FaceLandmark.LEFT_EYE) != null - val rightEyeVisible = face.getLandmark(FaceLandmark.RIGHT_EYE) != null - if (!leftEyeVisible || !rightEyeVisible) score *= 0.7f - - // 置信度分数 - val confidence = face.trackingId?.let { 1.0f } ?: 0.9f - score *= confidence - - // 人脸大小分数(越大越好) - val faceArea = face.boundingBox.width() * face.boundingBox.height() - val sizeScore = (faceArea / 100000f).coerceIn(0.5f, 1.0f) - score *= sizeScore - - return score - } - - /** - * 计算人脸偏航角(左右转头,-90 到 90 度) - */ - private fun calculateYawAngle(face: Face): Float { - val leftCheek = face.getLandmark(FaceLandmark.LEFT_CHEEK) ?: return 0f - val rightCheek = face.getLandmark(FaceLandmark.RIGHT_CHEEK) ?: return 0f - - val dx = rightCheek.position.x - leftCheek.position.x - val dy = rightCheek.position.y - leftCheek.position.y - - // 计算角度 - val angle = atan2(dy.toDouble(), dx.toDouble()).toFloat() * 180f / PI.toFloat() - - return angle.coerceIn(-90f, 90f) - } - - /** - * 计算人脸俯仰角(上下点头,-90 到 90 度) - */ - private fun calculatePitchAngle(face: Face): Float { - val nose = face.getLandmark(FaceLandmark.NOSE_BASE) ?: return 0f - val leftEye = face.getLandmark(FaceLandmark.LEFT_EYE) ?: return 0f - val rightEye = face.getLandmark(FaceLandmark.RIGHT_EYE) ?: return 0f - - // 眼睛中心点 - val eyeCenterY = (leftEye.position.y + rightEye.position.y) / 2f - - val dx = nose.position.x - (leftEye.position.x + rightEye.position.x) / 2f - val dy = nose.position.y - eyeCenterY - - val angle = atan2(dy.toDouble(), dx.toDouble()).toFloat() * 180f / PI.toFloat() - - return angle.coerceIn(-90f, 90f) - } - - /** - * 按角度分组人脸帧 - */ - private fun groupFramesByAngle(frames: List): Map> { - val buckets = mutableMapOf>() - - for (frame in frames) { - val bucket = getAngleBucket(frame.yaw, frame.pitch) - if (!buckets.containsKey(bucket)) { - buckets[bucket] = mutableListOf() - } - buckets[bucket]!!.add(frame) - } - - return buckets - } - - /** - * 获取角度分组 - */ - private fun getAngleBucket(yaw: Float, pitch: Float): VideoAngleBucket { - val yawBucket = when { - yaw < -30 -> -2 // 左 - yaw < -10 -> -1 // 左前 - yaw < 10 -> 0 // 正 - yaw < 30 -> 1 // 右前 - else -> 2 // 右 - } - - val pitchBucket = when { - pitch < -15 -> -1 // 上 - pitch < 15 -> 0 // 中 - else -> 1 // 下 - } - - return VideoAngleBucket(yawBucket, pitchBucket) - } - - /** - * 从每组中选择质量最好的帧 - */ - private fun selectBestFramesFromGroups( - groups: Map>, - maxFrames: Int - ): List { - val selected = mutableListOf() - - // 先按组排序(组内按质量降序) - val sortedGroups = groups.entries.sortedByDescending { entry -> - entry.value.maxOfOrNull { it.quality } ?: 0f - } - - for ((_, frames) in sortedGroups) { - val sortedFrames = frames.sortedByDescending { it.quality } - for (frame in sortedFrames) { - if (selected.size >= maxFrames) break - // 避免选择同一帧多次 - if (!selected.any { it.frameIndex == frame.frameIndex }) { - selected.add(frame) - } - } - } - - return selected - } - - /** - * 提取单帧人脸特征 - */ - private fun extractSingleEmbedding(frame: FaceFrame): FloatArray { - val bitmap = frame.bitmap - val face = frame.face - - // 裁剪人脸 - val cropped = cropFace(bitmap, face.boundingBox) - - // 对齐 - val aligned = alignFace(cropped, face) - - // 预处理 - val preprocessor = ImagePreprocessor() - val preprocessed = preprocessor.preprocess(aligned) - - // 提取特征 - return embedder.embed(preprocessed) - } - - /** - * 融合多个特征向量 - */ - private fun fuseEmbeddings(embeddings: List): FloatArray { - if (embeddings.isEmpty()) throw IllegalArgumentException("embeddings is empty") - if (embeddings.size == 1) return embeddings[0] - - val size = embeddings[0].size - val sum = FloatArray(size) - - for (embedding in embeddings) { - for (i in 0 until size) { - sum[i] += embedding[i] - } - } - - // 平均 - for (i in 0 until size) { - sum[i] /= embeddings.size - } - - // L2 归一化 - return l2Normalize(sum) - } - - /** - * 计算角度覆盖范围 - */ - private fun calculateAngleCoverage(frames: List): AngleCoverage { - var minYaw = Float.MAX_VALUE - var maxYaw = -Float.MAX_VALUE - var minPitch = Float.MAX_VALUE - var maxPitch = -Float.MAX_VALUE - - for (frame in frames) { - minYaw = minOf(minYaw, frame.yaw) - maxYaw = maxOf(maxYaw, frame.yaw) - minPitch = minOf(minPitch, frame.pitch) - maxPitch = maxOf(maxPitch, frame.pitch) - } - - return AngleCoverage( - yawRange = maxYaw - minYaw, - pitchRange = maxPitch - minPitch, - minYaw = minYaw, - maxYaw = maxYaw, - minPitch = minPitch, - maxPitch = maxPitch - ) - } - - /** - * 裁剪人脸 - */ - private fun cropFace(bitmap: Bitmap, box: Rect): Bitmap { - val padding = (maxOf(box.width(), box.height()) * 0.25f).toInt() - val left = (box.left - padding).coerceIn(0, bitmap.width) - val top = (box.top - padding).coerceIn(0, bitmap.height) - val right = (box.right + padding).coerceIn(0, bitmap.width) - val bottom = (box.bottom + padding).coerceIn(0, bitmap.height) - return Bitmap.createBitmap(bitmap, left, top, right - left, bottom - top) - } - - /** - * 对齐人脸 - */ - private fun alignFace(bitmap: Bitmap, face: Face): Bitmap { - val leftEye = face.getLandmark(FaceLandmark.LEFT_EYE) ?: return bitmap - val rightEye = face.getLandmark(FaceLandmark.RIGHT_EYE) ?: return bitmap - - val aligner = FaceAligner() - return aligner.align( - bitmap = bitmap, - leftEyeX = leftEye.position.x, - leftEyeY = leftEye.position.y, - rightEyeX = rightEye.position.x, - rightEyeY = rightEye.position.y, - faceLeft = 0, - faceTop = 0 - ) - } - - private fun l2Normalize(values: FloatArray): FloatArray { - var sum = 0f - for (value in values) sum += value * value - val norm = sqrt(sum.coerceAtLeast(1e-12f)) - return FloatArray(values.size) { values[it] / norm } - } - - override fun close() { - detector.close() - embedder.close() - } - - companion object { - private const val MIN_QUALITY_THRESHOLD = 0.5f - } -} - -/** - * 人脸帧信息 - */ -data class FaceFrame( - val bitmap: Bitmap, - val face: Face, - val quality: Float, - val yaw: Float, // 偏航角(左右转头) - val pitch: Float, // 俯仰角(上下点头) - val frameIndex: Int -) - -/** - * 角度分组 - */ -data class VideoAngleBucket(val yaw: Int, val pitch: Int) - -/** - * 角度覆盖范围 - */ -data class AngleCoverage( - val yawRange: Float, - val pitchRange: Float, - val minYaw: Float, - val maxYaw: Float, - val minPitch: Float, - val maxPitch: Float -) - -/** - * 注册结果 - */ -sealed class VideoEnrollmentResult { - data class Success( - val embedding: FloatArray, - val frameCount: Int, - val totalDetected: Int, - val angleCoverage: AngleCoverage - ) : VideoEnrollmentResult() - - data class Failure(val reason: String) : VideoEnrollmentResult() -} diff --git a/app/src/main/java/com/example/studentfaceregistry/upload/UploadServer.kt b/app/src/main/java/com/example/studentfaceregistry/upload/UploadServer.kt index 5a7e0bc..0f00530 100644 --- a/app/src/main/java/com/example/studentfaceregistry/upload/UploadServer.kt +++ b/app/src/main/java/com/example/studentfaceregistry/upload/UploadServer.kt @@ -226,7 +226,8 @@ class UploadServer( studentNo = studentNo, name = name, photoUri = "upload://$fileName", - embedding = result.embedding + embedding = result.embedding, + extraEmbeddings = result.extraEmbeddings ) ) val sourceInfo = if (result.sourceType == com.example.studentfaceregistry.face.EnrollmentSourceType.VIDEO) { diff --git a/convert_model.py b/convert_model.py index c23478a..8debdd9 100644 --- a/convert_model.py +++ b/convert_model.py @@ -1,134 +1,62 @@ #!/usr/bin/env python3 """ -ArcFace ONNX to TFLite 转换脚本 +ONNX 人脸模型转 TFLite 脚本(基于 onnx2tf) -使用方法: - 1. 先安装依赖:pip install onnx onnxruntime tensorflow - 2. 运行转换:python convert_model.py +环境要求(推荐使用已有 onnx2tf 的 conda 环境): + conda activate base # 已安装 onnx2tf + ai-edge-litert + 或 pip install onnx2tf ai-edge-litert onnx onnxruntime + +用法: + python convert_model.py + +示例: + python convert_model.py backup_models/buffalo_sc/w600k_mbf.onnx app/app/src/main/assets/mobilefacenet.tflite """ import os -import numpy as np +import shutil import subprocess import sys +import tempfile -def install_requirements(): - """安装必要的包""" - packages = ['onnx', 'onnxruntime', 'tensorflow', 'tf2onnx', 'onnx-tf'] - print("检查并安装依赖包...") - for pkg in packages: - try: - __import__(pkg.replace('-', '_')) - print(f" ✓ {pkg} 已安装") - except ImportError: - print(f" 安装 {pkg}...") - subprocess.check_call([sys.executable, '-m', 'pip', 'install', pkg, '-q']) - print("依赖包安装完成!\n") -def download_model(): - """下载 ArcFace 模型""" - model_url = "https://drive.google.com/uc?export=download&id=1gnt6P3jaiwfevV4hreWHPu0Mive5VRyP" - output_path = "/Users/liushuming/projects/app/app/src/main/assets/arcface_ir50_glint360k.onnx" +def main() -> int: + if len(sys.argv) != 3: + print(__doc__) + return 1 - print("下载 ArcFace 模型 (IResNet-50, Glint360K 数据集)...") - print(f"目标路径:{output_path}") + onnx_path = sys.argv[1] + tflite_path = sys.argv[2] - import urllib.request - urllib.request.urlretrieve(model_url, output_path) - - size_mb = os.path.getsize(output_path) / 1024 / 1024 - print(f"下载完成!模型大小:{size_mb:.2f} MB\n") - - return output_path - -def convert_onnx_to_tflite(onnx_path, output_path): - """将 ONNX 模型转换为 TFLite""" - print(f"转换 ONNX -> TFLite...") - print(f"输入:{onnx_path}") - print(f"输出:{output_path}") + if not os.path.isfile(onnx_path): + print(f"错误:找不到输入模型 {onnx_path}") + return 1 + work_dir = tempfile.mkdtemp(prefix="onnx2tf_") try: - import onnx - from onnx_tf.backend import prepare + print(f"转换 {onnx_path} -> {tflite_path}") + subprocess.check_call( + [sys.executable, "-m", "onnx2tf", "-i", onnx_path, "-o", work_dir] + ) - # 加载 ONNX 模型 - onnx_model = onnx.load(onnx_path) - onnx.checker.check_model(onnx_model) + base = os.path.splitext(os.path.basename(onnx_path))[0] + converted = os.path.join(work_dir, f"{base}_float32.tflite") + if not os.path.isfile(converted): + candidates = [ + f for f in os.listdir(work_dir) if f.endswith("_float32.tflite") + ] + if not candidates: + print("错误:onnx2tf 未生成 float32 tflite,请查看上方日志") + return 1 + converted = os.path.join(work_dir, candidates[0]) - # 打印模型信息 - inputs = onnx_model.graph.input - outputs = onnx_model.graph.output - print(f"\n模型输入:{inputs[0].name}, 形状:{[d.dim_value for d in inputs[0].type.tensor_type.shape.dim]}") - print(f"模型输出:{outputs[0].name}, 形状:{[d.dim_value for d in outputs[0].type.tensor_type.shape.dim]}") + os.makedirs(os.path.dirname(tflite_path) or ".", exist_ok=True) + shutil.copyfile(converted, tflite_path) + print(f"完成:{tflite_path}({os.path.getsize(tflite_path) / 1024 / 1024:.2f} MB)") + return 0 + finally: + shutil.rmtree(work_dir, ignore_errors=True) - # 转换为 TensorFlow - print("\n转换为 TensorFlow 格式...") - tf_backend = prepare(onnx_model) - tf_graph = tf_backend.tf_graph - - # 保存为 SavedModel - import tensorflow as tf - saved_model_dir = output_path.replace('.tflite', '_saved_model') - - # 清理已存在的目录 - import shutil - if os.path.exists(saved_model_dir): - shutil.rmtree(saved_model_dir) - - # 保存 graph - with tf.Graph().as_default() as graph: - tf.import_graph_def(tf_graph, name="") - tf.saved_model.save(tf.keras.models.Model(inputs=graph.get_tensor_by_name('input:0'), - outputs=graph.get_tensor_by_name('output:0')), - saved_model_dir) - - # 转换为 TFLite - print("转换为 TFLite 格式...") - converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir) - converter.optimizations = [tf.lite.Optimize.DEFAULT] - - tflite_model = converter.convert() - - with open(output_path, 'wb') as f: - f.write(tflite_model) - - # 清理临时文件 - shutil.rmtree(saved_model_dir) - - size_mb = os.path.getsize(output_path) / 1024 / 1024 - print(f"\n✓ 转换完成!") - print(f" TFLite 模型:{output_path}") - print(f" 模型大小:{size_mb:.2f} MB") - - return True - - except ImportError as e: - print(f"\n错误:缺少依赖包 - {e}") - print("请运行:pip install onnx-tf tensorflow") - return False - except Exception as e: - print(f"\n转换错误:{e}") - return False - -def main(): - print("=" * 60) - print("ArcFace 模型下载和转换工具") - print("=" * 60) - - # 安装依赖 - install_requirements() - - # 下载模型 - onnx_path = download_model() - - # 转换为 TFLite - output_path = "/Users/liushuming/projects/app/app/src/main/assets/facenet.tflite" - convert_onnx_to_tflite(onnx_path, output_path) - - print("\n" + "=" * 60) - print("完成!") - print("模型已保存到:app/src/main/assets/facenet.tflite") - print("=" * 60) if __name__ == "__main__": - main() + sys.exit(main())