diff --git a/tensorflow/lite/builtin_ops.h b/tensorflow/lite/builtin_ops.h index 47695b78645..d685ff17386 100644 --- a/tensorflow/lite/builtin_ops.h +++ b/tensorflow/lite/builtin_ops.h @@ -231,6 +231,7 @@ typedef enum { kTfLiteBuiltinStablehloGather = 201, kTfLiteBuiltinStablehloTranspose = 202, kTfLiteBuiltinDilate = 203, + kTfLiteBuiltinStablehloRngBitGenerator = 204, } TfLiteBuiltinOperator; #ifdef __cplusplus diff --git a/tensorflow/lite/core/api/flatbuffer_conversions.cc b/tensorflow/lite/core/api/flatbuffer_conversions.cc index 7c117765084..3d8b9cbfb56 100644 --- a/tensorflow/lite/core/api/flatbuffer_conversions.cc +++ b/tensorflow/lite/core/api/flatbuffer_conversions.cc @@ -144,6 +144,18 @@ TfLiteMirrorPaddingMode ConvertMirrorPadding(MirrorPadMode padding) { return kTfLiteMirrorPaddingUnknown; } +TfLiteRngAlgorithm ConvertRngAlgorithm(RngAlgorithm algorithm) { + switch (algorithm) { + case RngAlgorithm_THREEFRY: + return kTfLiteRngAlgorithmThreefry; + case RngAlgorithm_PHILOX: + return kTfLiteRngAlgorithmPhilox; + case RngAlgorithm_DEFAULT: + return kTfLiteRngAlgorithmDefault; + } + return kTfLiteRngAlgorithmUnknown; +} + #ifndef TF_LITE_STATIC_MEMORY TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type, ErrorReporter* error_reporter, @@ -899,6 +911,10 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type, *builtin_data = params.release(); return kTfLiteOk; } + case BuiltinOperator_STABLEHLO_RNG_BIT_GENERATOR: { + return ParseStablehloRngBitGenerator(op, error_reporter, allocator, + builtin_data); + } // TODO: skip param parsing for now since ops below don't have kernels case BuiltinOperator_STABLEHLO_SLICE: @@ -2084,6 +2100,32 @@ TfLiteStatus ParseResizeNearestNeighbor(const Operator* op, return kTfLiteOk; } +TfLiteStatus ParseStablehloRngBitGenerator(const Operator* op, + ErrorReporter* error_reporter, + BuiltinDataAllocator* allocator, + void** builtin_data) { + CheckParsePointerParams(op, error_reporter, allocator, builtin_data); + + SafeBuiltinDataAllocator safe_allocator(allocator); + std::unique_ptr + params = safe_allocator.Allocate(); + TF_LITE_ENSURE(error_reporter, params != nullptr); + + const StablehloRngBitGeneratorOptions* schema_params = + op->builtin_options_2_as_StablehloRngBitGeneratorOptions(); + if (schema_params != nullptr) { + params->algorithm = ConvertRngAlgorithm(schema_params->algorithm()); + } else { + // TODO(b/157480169): We should either return kTfLiteError or fill in some + // reasonable defaults in the params struct. We are not doing so until we + // better undertand the ramifications of changing the legacy behavior. + } + + *builtin_data = params.release(); + return kTfLiteOk; +} + // We have this parse function instead of directly returning kTfLiteOk from the // switch-case in ParseOpData because this function is used as part of the // selective registration for the OpResolver implementation in micro. diff --git a/tensorflow/lite/core/api/flatbuffer_conversions.h b/tensorflow/lite/core/api/flatbuffer_conversions.h index 9ffe3971c14..a2f109e8a5f 100644 --- a/tensorflow/lite/core/api/flatbuffer_conversions.h +++ b/tensorflow/lite/core/api/flatbuffer_conversions.h @@ -420,6 +420,11 @@ TfLiteStatus ParseRightShift(const Operator* op, ErrorReporter* error_reporter, BuiltinDataAllocator* allocator, void** builtin_data); +TfLiteStatus ParseStablehloRngBitGenerator(const Operator* op, + ErrorReporter* error_reporter, + BuiltinDataAllocator* allocator, + void** builtin_data); + } // namespace tflite #endif // TENSORFLOW_LITE_CORE_API_FLATBUFFER_CONVERSIONS_H_ diff --git a/tensorflow/lite/core/c/builtin_op_data.h b/tensorflow/lite/core/c/builtin_op_data.h index 0160373694d..166c3353547 100644 --- a/tensorflow/lite/core/c/builtin_op_data.h +++ b/tensorflow/lite/core/c/builtin_op_data.h @@ -570,6 +570,24 @@ typedef struct { int update_computation_subgraph_index; } TfLiteStablehloScatterParams; +typedef enum { + kTfLiteRngAlgorithmUnknown = 0, + // An algorithm auto-selected by the system according to device type. + kTfLiteRngAlgorithmDefault, + // 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) + kTfLiteRngAlgorithmPhilox, + // 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) + kTfLiteRngAlgorithmThreefry, +} TfLiteRngAlgorithm; + +typedef struct { + TfLiteRngAlgorithm algorithm; +} TfLiteStablehloRngBitGeneratorParams; + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tensorflow/lite/python/schema_py_generated.py b/tensorflow/lite/python/schema_py_generated.py index 8f150de5fb0..9fd5dbc142f 100755 --- a/tensorflow/lite/python/schema_py_generated.py +++ b/tensorflow/lite/python/schema_py_generated.py @@ -1593,6 +1593,7 @@ class BuiltinOperator(object): STABLEHLO_GATHER = 201 STABLEHLO_TRANSPOSE = 202 DILATE = 203 + STABLEHLO_RNG_BIT_GENERATOR = 204 # automatically generated by the FlatBuffers compiler, do not modify # namespace: tflite @@ -2007,6 +2008,7 @@ class BuiltinOptions2(object): StablehloGatherOptions = 16 StablehloTransposeOptions = 17 DilateOptions = 18 + StablehloRngBitGeneratorOptions = 19 def BuiltinOptions2Creator(unionType, table): from flatbuffers.table import Table @@ -2048,6 +2050,8 @@ def BuiltinOptions2Creator(unionType, table): 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) return None # automatically generated by the FlatBuffers compiler, do not modify @@ -7869,7 +7873,7 @@ def __init__(self): self.largeCustomOptionsOffset = 0 # type: int self.largeCustomOptionsSize = 0 # type: int self.builtinOptions2Type = 0 # type: int - self.builtinOptions2 = None # type: Union[None, StablehloConcatenateOptionsT, StablehloBroadcastInDimOptionsT, StablehloSliceOptionsT, StablehloConvolutionOptionsT, StablehloCustomCallOptionsT, StablehloReduceOptionsT, StablehloScatterOptionsT, StablehloCompareOptionsT, StablehloDynamicSliceOptionsT, StablehloPadOptionsT, StablehloIotaOptionsT, StablehloDotGeneralOptionsT, StablehloReduceWindowOptionsT, StablehloSortOptionsT, StablehloWhileOptionsT, StablehloGatherOptionsT, StablehloTransposeOptionsT, DilateOptionsT] + self.builtinOptions2 = None # type: Union[None, StablehloConcatenateOptionsT, StablehloBroadcastInDimOptionsT, StablehloSliceOptionsT, StablehloConvolutionOptionsT, StablehloCustomCallOptionsT, StablehloReduceOptionsT, StablehloScatterOptionsT, StablehloCompareOptionsT, StablehloDynamicSliceOptionsT, StablehloPadOptionsT, StablehloIotaOptionsT, StablehloDotGeneralOptionsT, StablehloReduceWindowOptionsT, StablehloSortOptionsT, StablehloWhileOptionsT, StablehloGatherOptionsT, StablehloTransposeOptionsT, DilateOptionsT, StablehloRngBitGeneratorOptionsT] @classmethod def InitFromBuf(cls, buf, pos): @@ -9969,6 +9973,14 @@ def Pack(self, builder): # namespace: tflite +class RngAlgorithm(object): + DEFAULT = 0 + PHILOX = 1 + THREEFRY = 2 +# automatically generated by the FlatBuffers compiler, do not modify + +# namespace: tflite + from flatbuffers.compat import import_numpy np = import_numpy() @@ -14529,6 +14541,82 @@ def Pack(self, builder): from flatbuffers.compat import import_numpy np = import_numpy() +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 Start(builder): + return StablehloRngBitGeneratorOptionsStart(builder) +def StablehloRngBitGeneratorOptionsAddAlgorithm(builder, algorithm): builder.PrependInt8Slot(0, algorithm, 0) +def AddAlgorithm(builder, algorithm): + return StablehloRngBitGeneratorOptionsAddAlgorithm(builder, algorithm) +def StablehloRngBitGeneratorOptionsEnd(builder): return builder.EndObject() +def End(builder): + return StablehloRngBitGeneratorOptionsEnd(builder) + +class StablehloRngBitGeneratorOptionsT(object): + + # StablehloRngBitGeneratorOptionsT + def __init__(self): + self.algorithm = 0 # type: int + + @classmethod + def InitFromBuf(cls, buf, pos): + stablehloRngBitGeneratorOptions = StablehloRngBitGeneratorOptions() + stablehloRngBitGeneratorOptions.Init(buf, pos) + return cls.InitFromObj(stablehloRngBitGeneratorOptions) + + @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 +# automatically generated by the FlatBuffers compiler, do not modify + +# namespace: tflite + +from flatbuffers.compat import import_numpy +np = import_numpy() + class StablehloScatterOptions(object): __slots__ = ['_tab'] diff --git a/tensorflow/lite/schema/schema.fbs b/tensorflow/lite/schema/schema.fbs index e3c46e811ba..e52f30ca16f 100644 --- a/tensorflow/lite/schema/schema.fbs +++ b/tensorflow/lite/schema/schema.fbs @@ -468,6 +468,7 @@ enum BuiltinOperator : int32 { STABLEHLO_GATHER = 201, // WARNING: No runtime support STABLEHLO_TRANSPOSE = 202, // WARNING: No runtime support DILATE = 203, + STABLEHLO_RNG_BIT_GENERATOR = 204, } // LINT.ThenChange(nnapi_linter/linter.proto) @@ -623,6 +624,7 @@ union BuiltinOptions2{ StablehloGatherOptions, StablehloTransposeOptions, DilateOptions, + StablehloRngBitGeneratorOptions, } table StablehloGatherOptions{ @@ -767,6 +769,23 @@ table StablehloScatterOptions { update_computation_subgraph_index: 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(//tensorflow/compiler/mlir/lite/ir/tfl_op_enums.td) diff --git a/tensorflow/lite/schema/schema_generated.h b/tensorflow/lite/schema/schema_generated.h index 16a18c80dde..222a79609a9 100755 --- a/tensorflow/lite/schema/schema_generated.h +++ b/tensorflow/lite/schema/schema_generated.h @@ -119,6 +119,10 @@ struct StablehloScatterOptions; struct StablehloScatterOptionsBuilder; struct StablehloScatterOptionsT; +struct StablehloRngBitGeneratorOptions; +struct StablehloRngBitGeneratorOptionsBuilder; +struct StablehloRngBitGeneratorOptionsT; + struct Conv2DOptions; struct Conv2DOptionsBuilder; struct Conv2DOptionsT; @@ -1188,11 +1192,12 @@ enum BuiltinOperator : int32_t { BuiltinOperator_STABLEHLO_GATHER = 201, BuiltinOperator_STABLEHLO_TRANSPOSE = 202, BuiltinOperator_DILATE = 203, + BuiltinOperator_STABLEHLO_RNG_BIT_GENERATOR = 204, BuiltinOperator_MIN = BuiltinOperator_ADD, - BuiltinOperator_MAX = BuiltinOperator_DILATE + BuiltinOperator_MAX = BuiltinOperator_STABLEHLO_RNG_BIT_GENERATOR }; -inline const BuiltinOperator (&EnumValuesBuiltinOperator())[204] { +inline const BuiltinOperator (&EnumValuesBuiltinOperator())[205] { static const BuiltinOperator values[] = { BuiltinOperator_ADD, BuiltinOperator_AVERAGE_POOL_2D, @@ -1397,13 +1402,14 @@ inline const BuiltinOperator (&EnumValuesBuiltinOperator())[204] { BuiltinOperator_STABLEHLO_WHILE, BuiltinOperator_STABLEHLO_GATHER, BuiltinOperator_STABLEHLO_TRANSPOSE, - BuiltinOperator_DILATE + BuiltinOperator_DILATE, + BuiltinOperator_STABLEHLO_RNG_BIT_GENERATOR }; return values; } inline const char * const *EnumNamesBuiltinOperator() { - static const char * const names[205] = { + static const char * const names[206] = { "ADD", "AVERAGE_POOL_2D", "CONCATENATION", @@ -1608,13 +1614,14 @@ inline const char * const *EnumNamesBuiltinOperator() { "STABLEHLO_GATHER", "STABLEHLO_TRANSPOSE", "DILATE", + "STABLEHLO_RNG_BIT_GENERATOR", nullptr }; return names; } inline const char *EnumNameBuiltinOperator(BuiltinOperator e) { - if (flatbuffers::IsOutRange(e, BuiltinOperator_ADD, BuiltinOperator_DILATE)) return ""; + if (flatbuffers::IsOutRange(e, BuiltinOperator_ADD, BuiltinOperator_STABLEHLO_RNG_BIT_GENERATOR)) return ""; const size_t index = static_cast(e); return EnumNamesBuiltinOperator()[index]; } @@ -4103,11 +4110,12 @@ enum BuiltinOptions2 : uint8_t { BuiltinOptions2_StablehloGatherOptions = 16, BuiltinOptions2_StablehloTransposeOptions = 17, BuiltinOptions2_DilateOptions = 18, + BuiltinOptions2_StablehloRngBitGeneratorOptions = 19, BuiltinOptions2_MIN = BuiltinOptions2_NONE, - BuiltinOptions2_MAX = BuiltinOptions2_DilateOptions + BuiltinOptions2_MAX = BuiltinOptions2_StablehloRngBitGeneratorOptions }; -inline const BuiltinOptions2 (&EnumValuesBuiltinOptions2())[19] { +inline const BuiltinOptions2 (&EnumValuesBuiltinOptions2())[20] { static const BuiltinOptions2 values[] = { BuiltinOptions2_NONE, BuiltinOptions2_StablehloConcatenateOptions, @@ -4127,13 +4135,14 @@ inline const BuiltinOptions2 (&EnumValuesBuiltinOptions2())[19] { BuiltinOptions2_StablehloWhileOptions, BuiltinOptions2_StablehloGatherOptions, BuiltinOptions2_StablehloTransposeOptions, - BuiltinOptions2_DilateOptions + BuiltinOptions2_DilateOptions, + BuiltinOptions2_StablehloRngBitGeneratorOptions }; return values; } inline const char * const *EnumNamesBuiltinOptions2() { - static const char * const names[20] = { + static const char * const names[21] = { "NONE", "StablehloConcatenateOptions", "StablehloBroadcastInDimOptions", @@ -4153,13 +4162,14 @@ inline const char * const *EnumNamesBuiltinOptions2() { "StablehloGatherOptions", "StablehloTransposeOptions", "DilateOptions", + "StablehloRngBitGeneratorOptions", nullptr }; return names; } inline const char *EnumNameBuiltinOptions2(BuiltinOptions2 e) { - if (flatbuffers::IsOutRange(e, BuiltinOptions2_NONE, BuiltinOptions2_DilateOptions)) return ""; + if (flatbuffers::IsOutRange(e, BuiltinOptions2_NONE, BuiltinOptions2_StablehloRngBitGeneratorOptions)) return ""; const size_t index = static_cast(e); return EnumNamesBuiltinOptions2()[index]; } @@ -4240,6 +4250,10 @@ template<> struct BuiltinOptions2Traits { static const BuiltinOptions2 enum_value = BuiltinOptions2_DilateOptions; }; +template<> struct BuiltinOptions2Traits { + static const BuiltinOptions2 enum_value = BuiltinOptions2_StablehloRngBitGeneratorOptions; +}; + template struct BuiltinOptions2UnionTraits { static const BuiltinOptions2 enum_value = BuiltinOptions2_NONE; }; @@ -4316,6 +4330,10 @@ template<> struct BuiltinOptions2UnionTraits { static const BuiltinOptions2 enum_value = BuiltinOptions2_DilateOptions; }; +template<> struct BuiltinOptions2UnionTraits { + static const BuiltinOptions2 enum_value = BuiltinOptions2_StablehloRngBitGeneratorOptions; +}; + struct BuiltinOptions2Union { BuiltinOptions2 type; void *value; @@ -4490,6 +4508,14 @@ struct BuiltinOptions2Union { return type == BuiltinOptions2_DilateOptions ? reinterpret_cast(value) : nullptr; } + tflite::StablehloRngBitGeneratorOptionsT *AsStablehloRngBitGeneratorOptions() { + return type == BuiltinOptions2_StablehloRngBitGeneratorOptions ? + reinterpret_cast(value) : nullptr; + } + const tflite::StablehloRngBitGeneratorOptionsT *AsStablehloRngBitGeneratorOptions() const { + return type == BuiltinOptions2_StablehloRngBitGeneratorOptions ? + reinterpret_cast(value) : nullptr; + } }; bool VerifyBuiltinOptions2(flatbuffers::Verifier &verifier, const void *obj, BuiltinOptions2 type); @@ -4609,6 +4635,39 @@ inline const char *EnumNameStablehloComparisonType(StablehloComparisonType e) { return EnumNamesStablehloComparisonType()[index]; } +enum RngAlgorithm : int8_t { + RngAlgorithm_DEFAULT = 0, + RngAlgorithm_PHILOX = 1, + RngAlgorithm_THREEFRY = 2, + RngAlgorithm_MIN = RngAlgorithm_DEFAULT, + RngAlgorithm_MAX = RngAlgorithm_THREEFRY +}; + +inline const RngAlgorithm (&EnumValuesRngAlgorithm())[3] { + static const RngAlgorithm values[] = { + RngAlgorithm_DEFAULT, + RngAlgorithm_PHILOX, + RngAlgorithm_THREEFRY + }; + return values; +} + +inline const char * const *EnumNamesRngAlgorithm() { + static const char * const names[4] = { + "DEFAULT", + "PHILOX", + "THREEFRY", + nullptr + }; + return names; +} + +inline const char *EnumNameRngAlgorithm(RngAlgorithm e) { + if (flatbuffers::IsOutRange(e, RngAlgorithm_DEFAULT, RngAlgorithm_THREEFRY)) return ""; + const size_t index = static_cast(e); + return EnumNamesRngAlgorithm()[index]; +} + enum Padding : int8_t { Padding_SAME = 0, Padding_VALID = 1, @@ -7499,6 +7558,58 @@ inline flatbuffers::Offset CreateStablehloScatterOption flatbuffers::Offset CreateStablehloScatterOptions(flatbuffers::FlatBufferBuilder &_fbb, const StablehloScatterOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +struct StablehloRngBitGeneratorOptionsT : public flatbuffers::NativeTable { + typedef StablehloRngBitGeneratorOptions TableType; + tflite::RngAlgorithm algorithm = tflite::RngAlgorithm_DEFAULT; +}; + +struct StablehloRngBitGeneratorOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef StablehloRngBitGeneratorOptionsT NativeTableType; + typedef StablehloRngBitGeneratorOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_ALGORITHM = 4 + }; + tflite::RngAlgorithm algorithm() const { + return static_cast(GetField(VT_ALGORITHM, 0)); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_ALGORITHM, 1) && + verifier.EndTable(); + } + StablehloRngBitGeneratorOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(StablehloRngBitGeneratorOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const StablehloRngBitGeneratorOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct StablehloRngBitGeneratorOptionsBuilder { + typedef StablehloRngBitGeneratorOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_algorithm(tflite::RngAlgorithm algorithm) { + fbb_.AddElement(StablehloRngBitGeneratorOptions::VT_ALGORITHM, static_cast(algorithm), 0); + } + explicit StablehloRngBitGeneratorOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateStablehloRngBitGeneratorOptions( + flatbuffers::FlatBufferBuilder &_fbb, + tflite::RngAlgorithm algorithm = tflite::RngAlgorithm_DEFAULT) { + StablehloRngBitGeneratorOptionsBuilder builder_(_fbb); + builder_.add_algorithm(algorithm); + return builder_.Finish(); +} + +flatbuffers::Offset CreateStablehloRngBitGeneratorOptions(flatbuffers::FlatBufferBuilder &_fbb, const StablehloRngBitGeneratorOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + struct Conv2DOptionsT : public flatbuffers::NativeTable { typedef Conv2DOptions TableType; tflite::Padding padding = tflite::Padding_SAME; @@ -14867,6 +14978,9 @@ struct Operator FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { const tflite::DilateOptions *builtin_options_2_as_DilateOptions() const { return builtin_options_2_type() == tflite::BuiltinOptions2_DilateOptions ? static_cast(builtin_options_2()) : nullptr; } + const tflite::StablehloRngBitGeneratorOptions *builtin_options_2_as_StablehloRngBitGeneratorOptions() const { + return builtin_options_2_type() == tflite::BuiltinOptions2_StablehloRngBitGeneratorOptions ? static_cast(builtin_options_2()) : nullptr; + } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, VT_OPCODE_INDEX, 4) && @@ -15472,6 +15586,10 @@ template<> inline const tflite::DilateOptions *Operator::builtin_options_2_as inline const tflite::StablehloRngBitGeneratorOptions *Operator::builtin_options_2_as() const { + return builtin_options_2_as_StablehloRngBitGeneratorOptions(); +} + struct OperatorBuilder { typedef Operator Table; flatbuffers::FlatBufferBuilder &fbb_; @@ -17192,6 +17310,32 @@ inline flatbuffers::Offset CreateStablehloScatterOption _update_computation_subgraph_index); } +inline StablehloRngBitGeneratorOptionsT *StablehloRngBitGeneratorOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = std::unique_ptr(new StablehloRngBitGeneratorOptionsT()); + UnPackTo(_o.get(), _resolver); + return _o.release(); +} + +inline void StablehloRngBitGeneratorOptions::UnPackTo(StablehloRngBitGeneratorOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = algorithm(); _o->algorithm = _e; } +} + +inline flatbuffers::Offset StablehloRngBitGeneratorOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const StablehloRngBitGeneratorOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateStablehloRngBitGeneratorOptions(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateStablehloRngBitGeneratorOptions(flatbuffers::FlatBufferBuilder &_fbb, const StablehloRngBitGeneratorOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const StablehloRngBitGeneratorOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _algorithm = _o->algorithm; + return tflite::CreateStablehloRngBitGeneratorOptions( + _fbb, + _algorithm); +} + inline Conv2DOptionsT *Conv2DOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = std::unique_ptr(new Conv2DOptionsT()); UnPackTo(_o.get(), _resolver); @@ -23886,6 +24030,10 @@ inline bool VerifyBuiltinOptions2(flatbuffers::Verifier &verifier, const void *o auto ptr = reinterpret_cast(obj); return verifier.VerifyTable(ptr); } + case BuiltinOptions2_StablehloRngBitGeneratorOptions: { + auto ptr = reinterpret_cast(obj); + return verifier.VerifyTable(ptr); + } default: return true; } } @@ -23977,6 +24125,10 @@ inline void *BuiltinOptions2Union::UnPack(const void *obj, BuiltinOptions2 type, auto ptr = reinterpret_cast(obj); return ptr->UnPack(resolver); } + case BuiltinOptions2_StablehloRngBitGeneratorOptions: { + auto ptr = reinterpret_cast(obj); + return ptr->UnPack(resolver); + } default: return nullptr; } } @@ -24056,6 +24208,10 @@ inline flatbuffers::Offset BuiltinOptions2Union::Pack(flatbuffers::FlatBuf auto ptr = reinterpret_cast(value); return CreateDilateOptions(_fbb, ptr, _rehasher).Union(); } + case BuiltinOptions2_StablehloRngBitGeneratorOptions: { + auto ptr = reinterpret_cast(value); + return CreateStablehloRngBitGeneratorOptions(_fbb, ptr, _rehasher).Union(); + } default: return 0; } } @@ -24134,6 +24290,10 @@ inline BuiltinOptions2Union::BuiltinOptions2Union(const BuiltinOptions2Union &u) value = new tflite::DilateOptionsT(*reinterpret_cast(u.value)); break; } + case BuiltinOptions2_StablehloRngBitGeneratorOptions: { + value = new tflite::StablehloRngBitGeneratorOptionsT(*reinterpret_cast(u.value)); + break; + } default: break; } @@ -24231,6 +24391,11 @@ inline void BuiltinOptions2Union::Reset() { delete ptr; break; } + case BuiltinOptions2_StablehloRngBitGeneratorOptions: { + auto ptr = reinterpret_cast(value); + delete ptr; + break; + } default: break; } value = nullptr;