diff --git a/tensorflow/lite/builtin_ops.h b/tensorflow/lite/builtin_ops.h index f9cb41c582d..47695b78645 100644 --- a/tensorflow/lite/builtin_ops.h +++ b/tensorflow/lite/builtin_ops.h @@ -230,6 +230,7 @@ typedef enum { kTfLiteBuiltinStablehloWhile = 200, kTfLiteBuiltinStablehloGather = 201, kTfLiteBuiltinStablehloTranspose = 202, + kTfLiteBuiltinDilate = 203, } TfLiteBuiltinOperator; #ifdef __cplusplus diff --git a/tensorflow/lite/core/api/flatbuffer_conversions.cc b/tensorflow/lite/core/api/flatbuffer_conversions.cc index 51d7903fbc1..9b180e5800b 100644 --- a/tensorflow/lite/core/api/flatbuffer_conversions.cc +++ b/tensorflow/lite/core/api/flatbuffer_conversions.cc @@ -983,6 +983,7 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type, case BuiltinOperator_SIGN: case BuiltinOperator_BITCAST: case BuiltinOperator_WHERE: + case BuiltinOperator_DILATE: return kTfLiteOk; case BuiltinOperator_PLACEHOLDER_FOR_GREATER_OP_CODES: return kTfLiteError; diff --git a/tensorflow/lite/python/schema_py_generated.py b/tensorflow/lite/python/schema_py_generated.py index 7ba69be32bd..6e9bbcfb11e 100755 --- a/tensorflow/lite/python/schema_py_generated.py +++ b/tensorflow/lite/python/schema_py_generated.py @@ -1592,6 +1592,7 @@ class BuiltinOperator(object): STABLEHLO_WHILE = 200 STABLEHLO_GATHER = 201 STABLEHLO_TRANSPOSE = 202 + DILATE = 203 # automatically generated by the FlatBuffers compiler, do not modify # namespace: tflite @@ -2005,6 +2006,7 @@ class BuiltinOptions2(object): StablehloWhileOptions = 15 StablehloGatherOptions = 16 StablehloTransposeOptions = 17 + DilateOptions = 18 def BuiltinOptions2Creator(unionType, table): from flatbuffers.table import Table @@ -2044,6 +2046,8 @@ def BuiltinOptions2Creator(unionType, table): 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) return None # automatically generated by the FlatBuffers compiler, do not modify @@ -3515,6 +3519,70 @@ def Pack(self, builder): from flatbuffers.compat import import_numpy np = import_numpy() +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 Start(builder): + return DilateOptionsStart(builder) +def DilateOptionsEnd(builder): return builder.EndObject() +def End(builder): + return DilateOptionsEnd(builder) + +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 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 +# automatically generated by the FlatBuffers compiler, do not modify + +# namespace: tflite + +from flatbuffers.compat import import_numpy +np = import_numpy() + class DimensionMetadata(object): __slots__ = ['_tab'] @@ -7775,7 +7843,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] + self.builtinOptions2 = None # type: Union[None, StablehloConcatenateOptionsT, StablehloBroadcastInDimOptionsT, StablehloSliceOptionsT, StablehloConvolutionOptionsT, StablehloCustomCallOptionsT, StablehloReduceOptionsT, StablehloScatterOptionsT, StablehloCompareOptionsT, StablehloDynamicSliceOptionsT, StablehloPadOptionsT, StablehloIotaOptionsT, StablehloDotGeneralOptionsT, StablehloReduceWindowOptionsT, StablehloSortOptionsT, StablehloWhileOptionsT, StablehloGatherOptionsT, StablehloTransposeOptionsT, DilateOptionsT] @classmethod def InitFromBuf(cls, buf, pos): diff --git a/tensorflow/lite/schema/schema.fbs b/tensorflow/lite/schema/schema.fbs index fe242dcc43e..d60d8e60abb 100644 --- a/tensorflow/lite/schema/schema.fbs +++ b/tensorflow/lite/schema/schema.fbs @@ -467,6 +467,7 @@ enum BuiltinOperator : int32 { STABLEHLO_WHILE = 200, // WARNING: No runtime support STABLEHLO_GATHER = 201, // WARNING: No runtime support STABLEHLO_TRANSPOSE = 202, // WARNING: No runtime support + DILATE = 203, } // LINT.ThenChange(nnapi_linter/linter.proto) @@ -621,6 +622,7 @@ union BuiltinOptions2{ StablehloWhileOptions, StablehloGatherOptions, StablehloTransposeOptions, + DilateOptions, } table StablehloGatherOptions{ @@ -1410,6 +1412,9 @@ table BitwiseXorOptions { table RightShiftOptions { } +table DilateOptions { +} + // An OperatorCode can be an enum value (BuiltinOperator) if the operator is a // builtin, or a string if the operator is custom. table OperatorCode { diff --git a/tensorflow/lite/schema/schema_generated.h b/tensorflow/lite/schema/schema_generated.h index f400ec57ff5..4eb8092d352 100755 --- a/tensorflow/lite/schema/schema_generated.h +++ b/tensorflow/lite/schema/schema_generated.h @@ -623,6 +623,10 @@ struct RightShiftOptions; struct RightShiftOptionsBuilder; struct RightShiftOptionsT; +struct DilateOptions; +struct DilateOptionsBuilder; +struct DilateOptionsT; + struct OperatorCode; struct OperatorCodeBuilder; struct OperatorCodeT; @@ -1183,11 +1187,12 @@ enum BuiltinOperator : int32_t { BuiltinOperator_STABLEHLO_WHILE = 200, BuiltinOperator_STABLEHLO_GATHER = 201, BuiltinOperator_STABLEHLO_TRANSPOSE = 202, + BuiltinOperator_DILATE = 203, BuiltinOperator_MIN = BuiltinOperator_ADD, - BuiltinOperator_MAX = BuiltinOperator_STABLEHLO_TRANSPOSE + BuiltinOperator_MAX = BuiltinOperator_DILATE }; -inline const BuiltinOperator (&EnumValuesBuiltinOperator())[203] { +inline const BuiltinOperator (&EnumValuesBuiltinOperator())[204] { static const BuiltinOperator values[] = { BuiltinOperator_ADD, BuiltinOperator_AVERAGE_POOL_2D, @@ -1391,13 +1396,14 @@ inline const BuiltinOperator (&EnumValuesBuiltinOperator())[203] { BuiltinOperator_STABLEHLO_SORT, BuiltinOperator_STABLEHLO_WHILE, BuiltinOperator_STABLEHLO_GATHER, - BuiltinOperator_STABLEHLO_TRANSPOSE + BuiltinOperator_STABLEHLO_TRANSPOSE, + BuiltinOperator_DILATE }; return values; } inline const char * const *EnumNamesBuiltinOperator() { - static const char * const names[204] = { + static const char * const names[205] = { "ADD", "AVERAGE_POOL_2D", "CONCATENATION", @@ -1601,13 +1607,14 @@ inline const char * const *EnumNamesBuiltinOperator() { "STABLEHLO_WHILE", "STABLEHLO_GATHER", "STABLEHLO_TRANSPOSE", + "DILATE", nullptr }; return names; } inline const char *EnumNameBuiltinOperator(BuiltinOperator e) { - if (flatbuffers::IsOutRange(e, BuiltinOperator_ADD, BuiltinOperator_STABLEHLO_TRANSPOSE)) return ""; + if (flatbuffers::IsOutRange(e, BuiltinOperator_ADD, BuiltinOperator_DILATE)) return ""; const size_t index = static_cast(e); return EnumNamesBuiltinOperator()[index]; } @@ -4095,11 +4102,12 @@ enum BuiltinOptions2 : uint8_t { BuiltinOptions2_StablehloWhileOptions = 15, BuiltinOptions2_StablehloGatherOptions = 16, BuiltinOptions2_StablehloTransposeOptions = 17, + BuiltinOptions2_DilateOptions = 18, BuiltinOptions2_MIN = BuiltinOptions2_NONE, - BuiltinOptions2_MAX = BuiltinOptions2_StablehloTransposeOptions + BuiltinOptions2_MAX = BuiltinOptions2_DilateOptions }; -inline const BuiltinOptions2 (&EnumValuesBuiltinOptions2())[18] { +inline const BuiltinOptions2 (&EnumValuesBuiltinOptions2())[19] { static const BuiltinOptions2 values[] = { BuiltinOptions2_NONE, BuiltinOptions2_StablehloConcatenateOptions, @@ -4118,13 +4126,14 @@ inline const BuiltinOptions2 (&EnumValuesBuiltinOptions2())[18] { BuiltinOptions2_StablehloSortOptions, BuiltinOptions2_StablehloWhileOptions, BuiltinOptions2_StablehloGatherOptions, - BuiltinOptions2_StablehloTransposeOptions + BuiltinOptions2_StablehloTransposeOptions, + BuiltinOptions2_DilateOptions }; return values; } inline const char * const *EnumNamesBuiltinOptions2() { - static const char * const names[19] = { + static const char * const names[20] = { "NONE", "StablehloConcatenateOptions", "StablehloBroadcastInDimOptions", @@ -4143,13 +4152,14 @@ inline const char * const *EnumNamesBuiltinOptions2() { "StablehloWhileOptions", "StablehloGatherOptions", "StablehloTransposeOptions", + "DilateOptions", nullptr }; return names; } inline const char *EnumNameBuiltinOptions2(BuiltinOptions2 e) { - if (flatbuffers::IsOutRange(e, BuiltinOptions2_NONE, BuiltinOptions2_StablehloTransposeOptions)) return ""; + if (flatbuffers::IsOutRange(e, BuiltinOptions2_NONE, BuiltinOptions2_DilateOptions)) return ""; const size_t index = static_cast(e); return EnumNamesBuiltinOptions2()[index]; } @@ -4226,6 +4236,10 @@ template<> struct BuiltinOptions2Traits { static const BuiltinOptions2 enum_value = BuiltinOptions2_StablehloTransposeOptions; }; +template<> struct BuiltinOptions2Traits { + static const BuiltinOptions2 enum_value = BuiltinOptions2_DilateOptions; +}; + template struct BuiltinOptions2UnionTraits { static const BuiltinOptions2 enum_value = BuiltinOptions2_NONE; }; @@ -4298,6 +4312,10 @@ template<> struct BuiltinOptions2UnionTraits static const BuiltinOptions2 enum_value = BuiltinOptions2_StablehloTransposeOptions; }; +template<> struct BuiltinOptions2UnionTraits { + static const BuiltinOptions2 enum_value = BuiltinOptions2_DilateOptions; +}; + struct BuiltinOptions2Union { BuiltinOptions2 type; void *value; @@ -4464,6 +4482,14 @@ struct BuiltinOptions2Union { return type == BuiltinOptions2_StablehloTransposeOptions ? reinterpret_cast(value) : nullptr; } + tflite::DilateOptionsT *AsDilateOptions() { + return type == BuiltinOptions2_DilateOptions ? + reinterpret_cast(value) : nullptr; + } + const tflite::DilateOptionsT *AsDilateOptions() const { + return type == BuiltinOptions2_DilateOptions ? + reinterpret_cast(value) : nullptr; + } }; bool VerifyBuiltinOptions2(flatbuffers::Verifier &verifier, const void *obj, BuiltinOptions2 type); @@ -14162,6 +14188,45 @@ inline flatbuffers::Offset CreateRightShiftOptions( flatbuffers::Offset CreateRightShiftOptions(flatbuffers::FlatBufferBuilder &_fbb, const RightShiftOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +struct DilateOptionsT : public flatbuffers::NativeTable { + typedef DilateOptions TableType; +}; + +struct DilateOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef DilateOptionsT NativeTableType; + typedef DilateOptionsBuilder Builder; + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + verifier.EndTable(); + } + DilateOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(DilateOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const DilateOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct DilateOptionsBuilder { + typedef DilateOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + explicit DilateOptionsBuilder(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 CreateDilateOptions( + flatbuffers::FlatBufferBuilder &_fbb) { + DilateOptionsBuilder builder_(_fbb); + return builder_.Finish(); +} + +flatbuffers::Offset CreateDilateOptions(flatbuffers::FlatBufferBuilder &_fbb, const DilateOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + struct OperatorCodeT : public flatbuffers::NativeTable { typedef OperatorCode TableType; int8_t deprecated_builtin_code = 0; @@ -14766,6 +14831,9 @@ struct Operator FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { const tflite::StablehloTransposeOptions *builtin_options_2_as_StablehloTransposeOptions() const { return builtin_options_2_type() == tflite::BuiltinOptions2_StablehloTransposeOptions ? static_cast(builtin_options_2()) : nullptr; } + const tflite::DilateOptions *builtin_options_2_as_DilateOptions() const { + return builtin_options_2_type() == tflite::BuiltinOptions2_DilateOptions ? static_cast(builtin_options_2()) : nullptr; + } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, VT_OPCODE_INDEX, 4) && @@ -15367,6 +15435,10 @@ template<> inline const tflite::StablehloTransposeOptions *Operator::builtin_opt return builtin_options_2_as_StablehloTransposeOptions(); } +template<> inline const tflite::DilateOptions *Operator::builtin_options_2_as() const { + return builtin_options_2_as_DilateOptions(); +} + struct OperatorBuilder { typedef Operator Table; flatbuffers::FlatBufferBuilder &fbb_; @@ -20420,6 +20492,29 @@ inline flatbuffers::Offset CreateRightShiftOptions(flatbuffer _fbb); } +inline DilateOptionsT *DilateOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = std::unique_ptr(new DilateOptionsT()); + UnPackTo(_o.get(), _resolver); + return _o.release(); +} + +inline void DilateOptions::UnPackTo(DilateOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; +} + +inline flatbuffers::Offset DilateOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const DilateOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateDilateOptions(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateDilateOptions(flatbuffers::FlatBufferBuilder &_fbb, const DilateOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const DilateOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + return tflite::CreateDilateOptions( + _fbb); +} + inline OperatorCodeT *OperatorCode::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = std::unique_ptr(new OperatorCodeT()); UnPackTo(_o.get(), _resolver); @@ -23745,6 +23840,10 @@ inline bool VerifyBuiltinOptions2(flatbuffers::Verifier &verifier, const void *o auto ptr = reinterpret_cast(obj); return verifier.VerifyTable(ptr); } + case BuiltinOptions2_DilateOptions: { + auto ptr = reinterpret_cast(obj); + return verifier.VerifyTable(ptr); + } default: return true; } } @@ -23832,6 +23931,10 @@ inline void *BuiltinOptions2Union::UnPack(const void *obj, BuiltinOptions2 type, auto ptr = reinterpret_cast(obj); return ptr->UnPack(resolver); } + case BuiltinOptions2_DilateOptions: { + auto ptr = reinterpret_cast(obj); + return ptr->UnPack(resolver); + } default: return nullptr; } } @@ -23907,6 +24010,10 @@ inline flatbuffers::Offset BuiltinOptions2Union::Pack(flatbuffers::FlatBuf auto ptr = reinterpret_cast(value); return CreateStablehloTransposeOptions(_fbb, ptr, _rehasher).Union(); } + case BuiltinOptions2_DilateOptions: { + auto ptr = reinterpret_cast(value); + return CreateDilateOptions(_fbb, ptr, _rehasher).Union(); + } default: return 0; } } @@ -23981,6 +24088,10 @@ inline BuiltinOptions2Union::BuiltinOptions2Union(const BuiltinOptions2Union &u) value = new tflite::StablehloTransposeOptionsT(*reinterpret_cast(u.value)); break; } + case BuiltinOptions2_DilateOptions: { + value = new tflite::DilateOptionsT(*reinterpret_cast(u.value)); + break; + } default: break; } @@ -24073,6 +24184,11 @@ inline void BuiltinOptions2Union::Reset() { delete ptr; break; } + case BuiltinOptions2_DilateOptions: { + auto ptr = reinterpret_cast(value); + delete ptr; + break; + } default: break; } value = nullptr;